]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.11.9-201311242034.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.11.9-201311242034.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 7f9d4f5..6d1afd6 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -1932,6 +1936,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 noexec=on: enable non-executable mappings (default)
248 noexec=off: disable non-executable mappings
249
250 + nopcid [X86-64]
251 + Disable PCID (Process-Context IDentifier) even if it
252 + is supported by the processor.
253 +
254 nosmap [X86]
255 Disable SMAP (Supervisor Mode Access Prevention)
256 even if it is supported by processor.
257 @@ -2199,6 +2207,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
258 the specified number of seconds. This is to be used if
259 your oopses keep scrolling off the screen.
260
261 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
262 + virtualization environments that don't cope well with the
263 + expand down segment used by UDEREF on X86-32 or the frequent
264 + page table updates on X86-64.
265 +
266 + pax_sanitize_slab=
267 + 0/1 to disable/enable slab object sanitization (enabled by
268 + default).
269 +
270 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
271 +
272 + pax_extra_latent_entropy
273 + Enable a very simple form of latent entropy extraction
274 + from the first 4GB of memory as the bootmem allocator
275 + passes the memory pages to the buddy allocator.
276 +
277 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
278 + when the processor supports PCID.
279 +
280 pcbit= [HW,ISDN]
281
282 pcd. [PARIDE]
283 diff --git a/Makefile b/Makefile
284 index 06379bd..abdd9a8 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 # Store (new) KERNELRELEASE string in include/config/kernel.release
403 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -942,6 +1005,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1063,6 +1128,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1224,6 +1290,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1363,17 +1431,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1383,11 +1455,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 0c4132d..88f0d53 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 43594d5..da71e62 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1791,7 +1791,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index 04aeb02..73b70dd 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2095 index 2b8114f..8fe9bcf 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -77,9 +77,9 @@ struct thread_info {
2099 .flags = 0, \
2100 .preempt_count = INIT_PREEMPT_COUNT, \
2101 .addr_limit = KERNEL_DS, \
2102 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2103 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2104 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2105 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2106 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2107 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2108 .restart_block = { \
2109 .fn = do_no_restart_syscall, \
2110 }, \
2111 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2112 #define TIF_SYSCALL_AUDIT 9
2113 #define TIF_SYSCALL_TRACEPOINT 10
2114 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2115 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2116 +/* within 8 bits of TIF_SYSCALL_TRACE
2117 + * to meet flexible second operand requirements
2118 + */
2119 +#define TIF_GRSEC_SETXID 12
2120 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2121 #define TIF_USING_IWMMXT 17
2122 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2123 #define TIF_RESTORE_SIGMASK 20
2124 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2125 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2126 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2127 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2128 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2129
2130 /* Checks for any syscall work in entry-common.S */
2131 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2132 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2133 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2134
2135 /*
2136 * Change these and you break ASM code in entry-common.S
2137 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2138 index 7e1f760..de33b13 100644
2139 --- a/arch/arm/include/asm/uaccess.h
2140 +++ b/arch/arm/include/asm/uaccess.h
2141 @@ -18,6 +18,7 @@
2142 #include <asm/domain.h>
2143 #include <asm/unified.h>
2144 #include <asm/compiler.h>
2145 +#include <asm/pgtable.h>
2146
2147 #define VERIFY_READ 0
2148 #define VERIFY_WRITE 1
2149 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2150 static inline void set_fs(mm_segment_t fs)
2151 {
2152 current_thread_info()->addr_limit = fs;
2153 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2154 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2155 }
2156
2157 #define segment_eq(a,b) ((a) == (b))
2158
2159 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2160 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2161 +
2162 +static inline void pax_open_userland(void)
2163 +{
2164 +
2165 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2166 + if (segment_eq(get_fs(), USER_DS)) {
2167 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2168 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2169 + }
2170 +#endif
2171 +
2172 +}
2173 +
2174 +static inline void pax_close_userland(void)
2175 +{
2176 +
2177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2178 + if (segment_eq(get_fs(), USER_DS)) {
2179 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2180 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2181 + }
2182 +#endif
2183 +
2184 +}
2185 +
2186 #define __addr_ok(addr) ({ \
2187 unsigned long flag; \
2188 __asm__("cmp %2, %0; movlo %0, #0" \
2189 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2190
2191 #define get_user(x,p) \
2192 ({ \
2193 + int __e; \
2194 might_fault(); \
2195 - __get_user_check(x,p); \
2196 + pax_open_userland(); \
2197 + __e = __get_user_check(x,p); \
2198 + pax_close_userland(); \
2199 + __e; \
2200 })
2201
2202 extern int __put_user_1(void *, unsigned int);
2203 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2204
2205 #define put_user(x,p) \
2206 ({ \
2207 + int __e; \
2208 might_fault(); \
2209 - __put_user_check(x,p); \
2210 + pax_open_userland(); \
2211 + __e = __put_user_check(x,p); \
2212 + pax_close_userland(); \
2213 + __e; \
2214 })
2215
2216 #else /* CONFIG_MMU */
2217 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2218 #define __get_user(x,ptr) \
2219 ({ \
2220 long __gu_err = 0; \
2221 + pax_open_userland(); \
2222 __get_user_err((x),(ptr),__gu_err); \
2223 + pax_close_userland(); \
2224 __gu_err; \
2225 })
2226
2227 #define __get_user_error(x,ptr,err) \
2228 ({ \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),err); \
2231 + pax_close_userland(); \
2232 (void) 0; \
2233 })
2234
2235 @@ -312,13 +352,17 @@ do { \
2236 #define __put_user(x,ptr) \
2237 ({ \
2238 long __pu_err = 0; \
2239 + pax_open_userland(); \
2240 __put_user_err((x),(ptr),__pu_err); \
2241 + pax_close_userland(); \
2242 __pu_err; \
2243 })
2244
2245 #define __put_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -418,11 +462,44 @@ do { \
2254
2255
2256 #ifdef CONFIG_MMU
2257 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2258 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2259 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2261 +
2262 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2263 +{
2264 + unsigned long ret;
2265 +
2266 + check_object_size(to, n, false);
2267 + pax_open_userland();
2268 + ret = ___copy_from_user(to, from, n);
2269 + pax_close_userland();
2270 + return ret;
2271 +}
2272 +
2273 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2274 +{
2275 + unsigned long ret;
2276 +
2277 + check_object_size(from, n, true);
2278 + pax_open_userland();
2279 + ret = ___copy_to_user(to, from, n);
2280 + pax_close_userland();
2281 + return ret;
2282 +}
2283 +
2284 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2285 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2286 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2287 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2288 +
2289 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2290 +{
2291 + unsigned long ret;
2292 + pax_open_userland();
2293 + ret = ___clear_user(addr, n);
2294 + pax_close_userland();
2295 + return ret;
2296 +}
2297 +
2298 #else
2299 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2300 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2301 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2302
2303 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2304 {
2305 + if ((long)n < 0)
2306 + return n;
2307 +
2308 if (access_ok(VERIFY_READ, from, n))
2309 n = __copy_from_user(to, from, n);
2310 else /* security hole - plug it */
2311 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2312
2313 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_WRITE, to, n))
2319 n = __copy_to_user(to, from, n);
2320 return n;
2321 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2322 index 5af0ed1..cea83883 100644
2323 --- a/arch/arm/include/uapi/asm/ptrace.h
2324 +++ b/arch/arm/include/uapi/asm/ptrace.h
2325 @@ -92,7 +92,7 @@
2326 * ARMv7 groups of PSR bits
2327 */
2328 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2329 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2330 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2331 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2332 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2333
2334 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2335 index 60d3b73..e5a0f22 100644
2336 --- a/arch/arm/kernel/armksyms.c
2337 +++ b/arch/arm/kernel/armksyms.c
2338 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2339
2340 /* networking */
2341 EXPORT_SYMBOL(csum_partial);
2342 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2343 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2344 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2345 EXPORT_SYMBOL(__csum_ipv6_magic);
2346
2347 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2348 #ifdef CONFIG_MMU
2349 EXPORT_SYMBOL(copy_page);
2350
2351 -EXPORT_SYMBOL(__copy_from_user);
2352 -EXPORT_SYMBOL(__copy_to_user);
2353 -EXPORT_SYMBOL(__clear_user);
2354 +EXPORT_SYMBOL(___copy_from_user);
2355 +EXPORT_SYMBOL(___copy_to_user);
2356 +EXPORT_SYMBOL(___clear_user);
2357
2358 EXPORT_SYMBOL(__get_user_1);
2359 EXPORT_SYMBOL(__get_user_2);
2360 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2361 index 9cbe70c..a7b5e34 100644
2362 --- a/arch/arm/kernel/entry-armv.S
2363 +++ b/arch/arm/kernel/entry-armv.S
2364 @@ -47,6 +47,87 @@
2365 9997:
2366 .endm
2367
2368 + .macro pax_enter_kernel
2369 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2370 + @ make aligned space for saved DACR
2371 + sub sp, sp, #8
2372 + @ save regs
2373 + stmdb sp!, {r1, r2}
2374 + @ read DACR from cpu_domain into r1
2375 + mov r2, sp
2376 + @ assume 8K pages, since we have to split the immediate in two
2377 + bic r2, r2, #(0x1fc0)
2378 + bic r2, r2, #(0x3f)
2379 + ldr r1, [r2, #TI_CPU_DOMAIN]
2380 + @ store old DACR on stack
2381 + str r1, [sp, #8]
2382 +#ifdef CONFIG_PAX_KERNEXEC
2383 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2384 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2385 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2386 +#endif
2387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2388 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2389 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2390 +#endif
2391 + @ write r1 to current_thread_info()->cpu_domain
2392 + str r1, [r2, #TI_CPU_DOMAIN]
2393 + @ write r1 to DACR
2394 + mcr p15, 0, r1, c3, c0, 0
2395 + @ instruction sync
2396 + instr_sync
2397 + @ restore regs
2398 + ldmia sp!, {r1, r2}
2399 +#endif
2400 + .endm
2401 +
2402 + .macro pax_open_userland
2403 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2404 + @ save regs
2405 + stmdb sp!, {r0, r1}
2406 + @ read DACR from cpu_domain into r1
2407 + mov r0, sp
2408 + @ assume 8K pages, since we have to split the immediate in two
2409 + bic r0, r0, #(0x1fc0)
2410 + bic r0, r0, #(0x3f)
2411 + ldr r1, [r0, #TI_CPU_DOMAIN]
2412 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r0, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r0, r1}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_close_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + @ write r1 to current_thread_info()->cpu_domain
2439 + str r1, [r0, #TI_CPU_DOMAIN]
2440 + @ write r1 to DACR
2441 + mcr p15, 0, r1, c3, c0, 0
2442 + @ instruction sync
2443 + instr_sync
2444 + @ restore regs
2445 + ldmia sp!, {r0, r1}
2446 +#endif
2447 + .endm
2448 +
2449 .macro pabt_helper
2450 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2451 #ifdef MULTI_PABORT
2452 @@ -89,11 +170,15 @@
2453 * Invalid mode handlers
2454 */
2455 .macro inv_entry, reason
2456 +
2457 + pax_enter_kernel
2458 +
2459 sub sp, sp, #S_FRAME_SIZE
2460 ARM( stmib sp, {r1 - lr} )
2461 THUMB( stmia sp, {r0 - r12} )
2462 THUMB( str sp, [sp, #S_SP] )
2463 THUMB( str lr, [sp, #S_LR] )
2464 +
2465 mov r1, #\reason
2466 .endm
2467
2468 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2469 .macro svc_entry, stack_hole=0
2470 UNWIND(.fnstart )
2471 UNWIND(.save {r0 - pc} )
2472 +
2473 + pax_enter_kernel
2474 +
2475 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2476 +
2477 #ifdef CONFIG_THUMB2_KERNEL
2478 SPFIX( str r0, [sp] ) @ temporarily saved
2479 SPFIX( mov r0, sp )
2480 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2481 ldmia r0, {r3 - r5}
2482 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2483 mov r6, #-1 @ "" "" "" ""
2484 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2485 + @ offset sp by 8 as done in pax_enter_kernel
2486 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2487 +#else
2488 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2489 +#endif
2490 SPFIX( addeq r2, r2, #4 )
2491 str r3, [sp, #-4]! @ save the "real" r0 copied
2492 @ from the exception stack
2493 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2494 .macro usr_entry
2495 UNWIND(.fnstart )
2496 UNWIND(.cantunwind ) @ don't unwind the user space
2497 +
2498 + pax_enter_kernel_user
2499 +
2500 sub sp, sp, #S_FRAME_SIZE
2501 ARM( stmib sp, {r1 - r12} )
2502 THUMB( stmia sp, {r0 - r12} )
2503 @@ -415,7 +512,9 @@ __und_usr:
2504 tst r3, #PSR_T_BIT @ Thumb mode?
2505 bne __und_usr_thumb
2506 sub r4, r2, #4 @ ARM instr at LR - 4
2507 + pax_open_userland
2508 1: ldrt r0, [r4]
2509 + pax_close_userland
2510 #ifdef CONFIG_CPU_ENDIAN_BE8
2511 rev r0, r0 @ little endian instruction
2512 #endif
2513 @@ -450,10 +549,14 @@ __und_usr_thumb:
2514 */
2515 .arch armv6t2
2516 #endif
2517 + pax_open_userland
2518 2: ldrht r5, [r4]
2519 + pax_close_userland
2520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2521 blo __und_usr_fault_16 @ 16bit undefined instruction
2522 + pax_open_userland
2523 3: ldrht r0, [r2]
2524 + pax_close_userland
2525 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2526 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2527 orr r0, r0, r5, lsl #16
2528 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2529 */
2530 .pushsection .fixup, "ax"
2531 .align 2
2532 -4: mov pc, r9
2533 +4: pax_close_userland
2534 + mov pc, r9
2535 .popsection
2536 .pushsection __ex_table,"a"
2537 .long 1b, 4b
2538 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2539 THUMB( str lr, [ip], #4 )
2540 ldr r4, [r2, #TI_TP_VALUE]
2541 ldr r5, [r2, #TI_TP_VALUE + 4]
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 switch_tls r1, r4, r5, r3, r7
2547 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index 94104bf..e425391 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index de23a9b..94c37c4 100644
2625 --- a/arch/arm/kernel/entry-header.S
2626 +++ b/arch/arm/kernel/entry-header.S
2627 @@ -184,6 +184,60 @@
2628 msr cpsr_c, \rtemp @ switch back to the SVC mode
2629 .endm
2630
2631 + .macro pax_enter_kernel_user
2632 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2633 + @ save regs
2634 + stmdb sp!, {r0, r1}
2635 + @ read DACR from cpu_domain into r1
2636 + mov r0, sp
2637 + @ assume 8K pages, since we have to split the immediate in two
2638 + bic r0, r0, #(0x1fc0)
2639 + bic r0, r0, #(0x3f)
2640 + ldr r1, [r0, #TI_CPU_DOMAIN]
2641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2642 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2643 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2644 +#endif
2645 +#ifdef CONFIG_PAX_KERNEXEC
2646 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2647 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2648 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2649 +#endif
2650 + @ write r1 to current_thread_info()->cpu_domain
2651 + str r1, [r0, #TI_CPU_DOMAIN]
2652 + @ write r1 to DACR
2653 + mcr p15, 0, r1, c3, c0, 0
2654 + @ instruction sync
2655 + instr_sync
2656 + @ restore regs
2657 + ldmia sp!, {r0, r1}
2658 +#endif
2659 + .endm
2660 +
2661 + .macro pax_exit_kernel
2662 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2663 + @ save regs
2664 + stmdb sp!, {r0, r1}
2665 + @ read old DACR from stack into r1
2666 + ldr r1, [sp, #(8 + S_SP)]
2667 + sub r1, r1, #8
2668 + ldr r1, [r1]
2669 +
2670 + @ write r1 to current_thread_info()->cpu_domain
2671 + mov r0, sp
2672 + @ assume 8K pages, since we have to split the immediate in two
2673 + bic r0, r0, #(0x1fc0)
2674 + bic r0, r0, #(0x3f)
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 #ifndef CONFIG_THUMB2_KERNEL
2686 .macro svc_exit, rpsr, irq = 0
2687 .if \irq != 0
2688 @@ -203,6 +257,9 @@
2689 blne trace_hardirqs_off
2690 #endif
2691 .endif
2692 +
2693 + pax_exit_kernel
2694 +
2695 msr spsr_cxsf, \rpsr
2696 #if defined(CONFIG_CPU_V6)
2697 ldr r0, [sp]
2698 @@ -266,6 +323,9 @@
2699 blne trace_hardirqs_off
2700 #endif
2701 .endif
2702 +
2703 + pax_exit_kernel
2704 +
2705 ldr lr, [sp, #S_SP] @ top of the stack
2706 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2707 clrex @ clear the exclusive monitor
2708 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2709 index 918875d..cd5fa27 100644
2710 --- a/arch/arm/kernel/fiq.c
2711 +++ b/arch/arm/kernel/fiq.c
2712 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2713 void *base = vectors_page;
2714 unsigned offset = FIQ_OFFSET;
2715
2716 + pax_open_kernel();
2717 memcpy(base + offset, start, length);
2718 + pax_close_kernel();
2719 +
2720 if (!cache_is_vipt_nonaliasing())
2721 flush_icache_range((unsigned long)base + offset, offset +
2722 length);
2723 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2724 index 2c7cc1e..ab2e911 100644
2725 --- a/arch/arm/kernel/head.S
2726 +++ b/arch/arm/kernel/head.S
2727 @@ -52,7 +52,9 @@
2728 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2729
2730 .macro pgtbl, rd, phys
2731 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2732 + mov \rd, #TEXT_OFFSET
2733 + sub \rd, #PG_DIR_SIZE
2734 + add \rd, \rd, \phys
2735 .endm
2736
2737 /*
2738 @@ -432,7 +434,7 @@ __enable_mmu:
2739 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2740 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2741 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2742 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2743 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2744 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2745 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2746 #endif
2747 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2748 index 85c3fb6..054c2dc 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index afc2489..6372bc8 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 2dc1934..ecf0e21 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index ab517fc..9adf2fa 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 741f66a..8a5615c 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index e9238b5..6ed904a 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index f3fdd6a..3564800 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static unsigned gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index f99f68e..e573e20 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index 7f4db12..0243012 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index 706aa42..f85e9131 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index cad3ca86..1d79e0f 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..4dd9b67 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 4a05444..d21968c 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index c97f794..3e603c4 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,31 @@ __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_MEMORY_UDEREF
3801 + if (addr < TASK_SIZE) {
3802 + if (current->signal->curr_ip)
3803 + 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),
3804 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3805 + else
3806 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3808 + }
3809 +#endif
3810 +
3811 +#ifdef CONFIG_PAX_KERNEXEC
3812 + if ((fsr & FSR_WRITE) &&
3813 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3814 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3815 + {
3816 + if (current->signal->curr_ip)
3817 + 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),
3818 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3819 + else
3820 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3821 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3822 + }
3823 +#endif
3824 +
3825 /*
3826 * No handler, we'll have to terminate things with extreme prejudice.
3827 */
3828 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3829 }
3830 #endif
3831
3832 +#ifdef CONFIG_PAX_PAGEEXEC
3833 + if (fsr & FSR_LNX_PF) {
3834 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3835 + do_group_exit(SIGKILL);
3836 + }
3837 +#endif
3838 +
3839 tsk->thread.address = addr;
3840 tsk->thread.error_code = fsr;
3841 tsk->thread.trap_no = 14;
3842 @@ -398,6 +431,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3843 }
3844 #endif /* CONFIG_MMU */
3845
3846 +#ifdef CONFIG_PAX_PAGEEXEC
3847 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3848 +{
3849 + long i;
3850 +
3851 + printk(KERN_ERR "PAX: bytes at PC: ");
3852 + for (i = 0; i < 20; i++) {
3853 + unsigned char c;
3854 + if (get_user(c, (__force unsigned char __user *)pc+i))
3855 + printk(KERN_CONT "?? ");
3856 + else
3857 + printk(KERN_CONT "%02x ", c);
3858 + }
3859 + printk("\n");
3860 +
3861 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3862 + for (i = -1; i < 20; i++) {
3863 + unsigned long c;
3864 + if (get_user(c, (__force unsigned long __user *)sp+i))
3865 + printk(KERN_CONT "???????? ");
3866 + else
3867 + printk(KERN_CONT "%08lx ", c);
3868 + }
3869 + printk("\n");
3870 +}
3871 +#endif
3872 +
3873 /*
3874 * First Level Translation Fault Handler
3875 *
3876 @@ -545,9 +605,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3877 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3878 struct siginfo info;
3879
3880 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3881 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3882 + if (current->signal->curr_ip)
3883 + 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),
3884 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3885 + else
3886 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3887 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3888 + goto die;
3889 + }
3890 +#endif
3891 +
3892 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3893 return;
3894
3895 +die:
3896 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3897 inf->name, fsr, addr);
3898
3899 @@ -571,15 +644,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3900 ifsr_info[nr].name = name;
3901 }
3902
3903 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3904 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3905 +
3906 asmlinkage void __exception
3907 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3908 {
3909 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3910 struct siginfo info;
3911 + unsigned long pc = instruction_pointer(regs);
3912 +
3913 + if (user_mode(regs)) {
3914 + unsigned long sigpage = current->mm->context.sigpage;
3915 +
3916 + if (sigpage <= pc && pc < sigpage + 7*4) {
3917 + if (pc < sigpage + 3*4)
3918 + sys_sigreturn(regs);
3919 + else
3920 + sys_rt_sigreturn(regs);
3921 + return;
3922 + }
3923 + if (pc == 0xffff0f60UL) {
3924 + /*
3925 + * PaX: __kuser_cmpxchg64 emulation
3926 + */
3927 + // TODO
3928 + //regs->ARM_pc = regs->ARM_lr;
3929 + //return;
3930 + }
3931 + if (pc == 0xffff0fa0UL) {
3932 + /*
3933 + * PaX: __kuser_memory_barrier emulation
3934 + */
3935 + // dmb(); implied by the exception
3936 + regs->ARM_pc = regs->ARM_lr;
3937 + return;
3938 + }
3939 + if (pc == 0xffff0fc0UL) {
3940 + /*
3941 + * PaX: __kuser_cmpxchg emulation
3942 + */
3943 + // TODO
3944 + //regs->ARM_pc = regs->ARM_lr;
3945 + //return;
3946 + }
3947 + if (pc == 0xffff0fe0UL) {
3948 + /*
3949 + * PaX: __kuser_get_tls emulation
3950 + */
3951 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3952 + regs->ARM_pc = regs->ARM_lr;
3953 + return;
3954 + }
3955 + }
3956 +
3957 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3958 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3959 + if (current->signal->curr_ip)
3960 + 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),
3961 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3962 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3963 + else
3964 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3965 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3966 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3967 + goto die;
3968 + }
3969 +#endif
3970 +
3971 +#ifdef CONFIG_PAX_REFCOUNT
3972 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3973 + unsigned int bkpt;
3974 +
3975 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3976 + current->thread.error_code = ifsr;
3977 + current->thread.trap_no = 0;
3978 + pax_report_refcount_overflow(regs);
3979 + fixup_exception(regs);
3980 + return;
3981 + }
3982 + }
3983 +#endif
3984
3985 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3986 return;
3987
3988 +die:
3989 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3990 inf->name, ifsr, addr);
3991
3992 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3993 index cf08bdf..772656c 100644
3994 --- a/arch/arm/mm/fault.h
3995 +++ b/arch/arm/mm/fault.h
3996 @@ -3,6 +3,7 @@
3997
3998 /*
3999 * Fault status register encodings. We steal bit 31 for our own purposes.
4000 + * Set when the FSR value is from an instruction fault.
4001 */
4002 #define FSR_LNX_PF (1 << 31)
4003 #define FSR_WRITE (1 << 11)
4004 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4005 }
4006 #endif
4007
4008 +/* valid for LPAE and !LPAE */
4009 +static inline int is_xn_fault(unsigned int fsr)
4010 +{
4011 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4012 +}
4013 +
4014 +static inline int is_domain_fault(unsigned int fsr)
4015 +{
4016 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4017 +}
4018 +
4019 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4020 unsigned long search_exception_table(unsigned long addr);
4021
4022 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4023 index 15225d8..25e2e3c 100644
4024 --- a/arch/arm/mm/init.c
4025 +++ b/arch/arm/mm/init.c
4026 @@ -30,6 +30,8 @@
4027 #include <asm/setup.h>
4028 #include <asm/tlb.h>
4029 #include <asm/fixmap.h>
4030 +#include <asm/system_info.h>
4031 +#include <asm/cp15.h>
4032
4033 #include <asm/mach/arch.h>
4034 #include <asm/mach/map.h>
4035 @@ -683,7 +685,46 @@ void free_initmem(void)
4036 {
4037 #ifdef CONFIG_HAVE_TCM
4038 extern char __tcm_start, __tcm_end;
4039 +#endif
4040
4041 +#ifdef CONFIG_PAX_KERNEXEC
4042 + unsigned long addr;
4043 + pgd_t *pgd;
4044 + pud_t *pud;
4045 + pmd_t *pmd;
4046 + int cpu_arch = cpu_architecture();
4047 + unsigned int cr = get_cr();
4048 +
4049 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4050 + /* make pages tables, etc before .text NX */
4051 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4052 + pgd = pgd_offset_k(addr);
4053 + pud = pud_offset(pgd, addr);
4054 + pmd = pmd_offset(pud, addr);
4055 + __section_update(pmd, addr, PMD_SECT_XN);
4056 + }
4057 + /* make init NX */
4058 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4059 + pgd = pgd_offset_k(addr);
4060 + pud = pud_offset(pgd, addr);
4061 + pmd = pmd_offset(pud, addr);
4062 + __section_update(pmd, addr, PMD_SECT_XN);
4063 + }
4064 + /* make kernel code/rodata RX */
4065 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4066 + pgd = pgd_offset_k(addr);
4067 + pud = pud_offset(pgd, addr);
4068 + pmd = pmd_offset(pud, addr);
4069 +#ifdef CONFIG_ARM_LPAE
4070 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4071 +#else
4072 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4073 +#endif
4074 + }
4075 + }
4076 +#endif
4077 +
4078 +#ifdef CONFIG_HAVE_TCM
4079 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4080 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4081 #endif
4082 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4083 index f123d6e..04bf569 100644
4084 --- a/arch/arm/mm/ioremap.c
4085 +++ b/arch/arm/mm/ioremap.c
4086 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4087 unsigned int mtype;
4088
4089 if (cached)
4090 - mtype = MT_MEMORY;
4091 + mtype = MT_MEMORY_RX;
4092 else
4093 - mtype = MT_MEMORY_NONCACHED;
4094 + mtype = MT_MEMORY_NONCACHED_RX;
4095
4096 return __arm_ioremap_caller(phys_addr, size, mtype,
4097 __builtin_return_address(0));
4098 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4099 index 0c63562..7128a90 100644
4100 --- a/arch/arm/mm/mmap.c
4101 +++ b/arch/arm/mm/mmap.c
4102 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4103 struct vm_area_struct *vma;
4104 int do_align = 0;
4105 int aliasing = cache_is_vipt_aliasing();
4106 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4107 struct vm_unmapped_area_info info;
4108
4109 /*
4110 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4111 if (len > TASK_SIZE)
4112 return -ENOMEM;
4113
4114 +#ifdef CONFIG_PAX_RANDMMAP
4115 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4116 +#endif
4117 +
4118 if (addr) {
4119 if (do_align)
4120 addr = COLOUR_ALIGN(addr, pgoff);
4121 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4122 addr = PAGE_ALIGN(addr);
4123
4124 vma = find_vma(mm, addr);
4125 - if (TASK_SIZE - len >= addr &&
4126 - (!vma || addr + len <= vma->vm_start))
4127 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4128 return addr;
4129 }
4130
4131 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4132 info.high_limit = TASK_SIZE;
4133 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4134 info.align_offset = pgoff << PAGE_SHIFT;
4135 + info.threadstack_offset = offset;
4136 return vm_unmapped_area(&info);
4137 }
4138
4139 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4140 unsigned long addr = addr0;
4141 int do_align = 0;
4142 int aliasing = cache_is_vipt_aliasing();
4143 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4144 struct vm_unmapped_area_info info;
4145
4146 /*
4147 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 return addr;
4149 }
4150
4151 +#ifdef CONFIG_PAX_RANDMMAP
4152 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4153 +#endif
4154 +
4155 /* requesting a specific address */
4156 if (addr) {
4157 if (do_align)
4158 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4159 else
4160 addr = PAGE_ALIGN(addr);
4161 vma = find_vma(mm, addr);
4162 - if (TASK_SIZE - len >= addr &&
4163 - (!vma || addr + len <= vma->vm_start))
4164 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4165 return addr;
4166 }
4167
4168 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4169 info.high_limit = mm->mmap_base;
4170 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4171 info.align_offset = pgoff << PAGE_SHIFT;
4172 + info.threadstack_offset = offset;
4173 addr = vm_unmapped_area(&info);
4174
4175 /*
4176 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4177 {
4178 unsigned long random_factor = 0UL;
4179
4180 +#ifdef CONFIG_PAX_RANDMMAP
4181 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4182 +#endif
4183 +
4184 /* 8 bits of randomness in 20 address space bits */
4185 if ((current->flags & PF_RANDOMIZE) &&
4186 !(current->personality & ADDR_NO_RANDOMIZE))
4187 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4188
4189 if (mmap_is_legacy()) {
4190 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4191 +
4192 +#ifdef CONFIG_PAX_RANDMMAP
4193 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4194 + mm->mmap_base += mm->delta_mmap;
4195 +#endif
4196 +
4197 mm->get_unmapped_area = arch_get_unmapped_area;
4198 } else {
4199 mm->mmap_base = mmap_base(random_factor);
4200 +
4201 +#ifdef CONFIG_PAX_RANDMMAP
4202 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4203 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4204 +#endif
4205 +
4206 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4207 }
4208 }
4209 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4210 index 53cdbd3..670f177 100644
4211 --- a/arch/arm/mm/mmu.c
4212 +++ b/arch/arm/mm/mmu.c
4213 @@ -36,6 +36,22 @@
4214 #include "mm.h"
4215 #include "tcm.h"
4216
4217 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4218 +void modify_domain(unsigned int dom, unsigned int type)
4219 +{
4220 + struct thread_info *thread = current_thread_info();
4221 + unsigned int domain = thread->cpu_domain;
4222 + /*
4223 + * DOMAIN_MANAGER might be defined to some other value,
4224 + * use the arch-defined constant
4225 + */
4226 + domain &= ~domain_val(dom, 3);
4227 + thread->cpu_domain = domain | domain_val(dom, type);
4228 + set_domain(thread->cpu_domain);
4229 +}
4230 +EXPORT_SYMBOL(modify_domain);
4231 +#endif
4232 +
4233 /*
4234 * empty_zero_page is a special page that is used for
4235 * zero-initialized data and COW.
4236 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4237
4238 #endif /* ifdef CONFIG_CPU_CP15 / else */
4239
4240 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4241 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4242 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4243
4244 -static struct mem_type mem_types[] = {
4245 +#ifdef CONFIG_PAX_KERNEXEC
4246 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4247 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4248 +#else
4249 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4250 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4251 +#endif
4252 +
4253 +static struct mem_type mem_types[] __read_only = {
4254 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4255 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4256 L_PTE_SHARED,
4257 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4258 [MT_UNCACHED] = {
4259 .prot_pte = PROT_PTE_DEVICE,
4260 .prot_l1 = PMD_TYPE_TABLE,
4261 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4262 + .prot_sect = PROT_SECT_DEVICE,
4263 .domain = DOMAIN_IO,
4264 },
4265 [MT_CACHECLEAN] = {
4266 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4267 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4268 .domain = DOMAIN_KERNEL,
4269 },
4270 #ifndef CONFIG_ARM_LPAE
4271 [MT_MINICLEAN] = {
4272 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4273 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4274 .domain = DOMAIN_KERNEL,
4275 },
4276 #endif
4277 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4278 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4279 L_PTE_RDONLY,
4280 .prot_l1 = PMD_TYPE_TABLE,
4281 - .domain = DOMAIN_USER,
4282 + .domain = DOMAIN_VECTORS,
4283 },
4284 [MT_HIGH_VECTORS] = {
4285 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4286 L_PTE_USER | L_PTE_RDONLY,
4287 .prot_l1 = PMD_TYPE_TABLE,
4288 - .domain = DOMAIN_USER,
4289 + .domain = DOMAIN_VECTORS,
4290 },
4291 - [MT_MEMORY] = {
4292 + [MT_MEMORY_RWX] = {
4293 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4294 .prot_l1 = PMD_TYPE_TABLE,
4295 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4296 .domain = DOMAIN_KERNEL,
4297 },
4298 + [MT_MEMORY_RW] = {
4299 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4300 + .prot_l1 = PMD_TYPE_TABLE,
4301 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4302 + .domain = DOMAIN_KERNEL,
4303 + },
4304 + [MT_MEMORY_RX] = {
4305 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4306 + .prot_l1 = PMD_TYPE_TABLE,
4307 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4308 + .domain = DOMAIN_KERNEL,
4309 + },
4310 [MT_ROM] = {
4311 - .prot_sect = PMD_TYPE_SECT,
4312 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4313 .domain = DOMAIN_KERNEL,
4314 },
4315 - [MT_MEMORY_NONCACHED] = {
4316 + [MT_MEMORY_NONCACHED_RW] = {
4317 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4318 L_PTE_MT_BUFFERABLE,
4319 .prot_l1 = PMD_TYPE_TABLE,
4320 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4321 .domain = DOMAIN_KERNEL,
4322 },
4323 + [MT_MEMORY_NONCACHED_RX] = {
4324 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4325 + L_PTE_MT_BUFFERABLE,
4326 + .prot_l1 = PMD_TYPE_TABLE,
4327 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4328 + .domain = DOMAIN_KERNEL,
4329 + },
4330 [MT_MEMORY_DTCM] = {
4331 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4332 - L_PTE_XN,
4333 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4334 .prot_l1 = PMD_TYPE_TABLE,
4335 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4336 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4337 .domain = DOMAIN_KERNEL,
4338 },
4339 [MT_MEMORY_ITCM] = {
4340 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4341 },
4342 [MT_MEMORY_SO] = {
4343 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4344 - L_PTE_MT_UNCACHED | L_PTE_XN,
4345 + L_PTE_MT_UNCACHED,
4346 .prot_l1 = PMD_TYPE_TABLE,
4347 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4348 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4349 + PMD_SECT_UNCACHED,
4350 .domain = DOMAIN_KERNEL,
4351 },
4352 [MT_MEMORY_DMA_READY] = {
4353 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4354 * to prevent speculative instruction fetches.
4355 */
4356 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4357 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4358 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4359 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4360 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4361 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4362 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4364 +
4365 + /* Mark other regions on ARMv6+ as execute-never */
4366 +
4367 +#ifdef CONFIG_PAX_KERNEXEC
4368 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4369 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4370 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4371 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4372 +#ifndef CONFIG_ARM_LPAE
4373 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4375 +#endif
4376 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4378 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4379 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4380 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4381 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4382 +#endif
4383 +
4384 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4386 }
4387 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4388 /*
4389 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4390 * from SVC mode and no access from userspace.
4391 */
4392 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4393 +#ifdef CONFIG_PAX_KERNEXEC
4394 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4395 +#endif
4396 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4397 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4398 #endif
4399 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4400 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4401 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4402 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4403 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4404 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4405 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4406 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4407 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4408 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4409 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4410 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4411 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4412 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4413 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4414 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4415 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4416 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4417 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4418 }
4419 }
4420
4421 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4422 if (cpu_arch >= CPU_ARCH_ARMv6) {
4423 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4424 /* Non-cacheable Normal is XCB = 001 */
4425 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4426 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4427 + PMD_SECT_BUFFERED;
4428 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4429 PMD_SECT_BUFFERED;
4430 } else {
4431 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4432 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4433 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4434 + PMD_SECT_TEX(1);
4435 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4436 PMD_SECT_TEX(1);
4437 }
4438 } else {
4439 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4440 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4442 }
4443
4444 #ifdef CONFIG_ARM_LPAE
4445 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4446 vecs_pgprot |= PTE_EXT_AF;
4447 #endif
4448
4449 + user_pgprot |= __supported_pte_mask;
4450 +
4451 for (i = 0; i < 16; i++) {
4452 pteval_t v = pgprot_val(protection_map[i]);
4453 protection_map[i] = __pgprot(v | user_pgprot);
4454 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4455
4456 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4457 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4458 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4459 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4460 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4461 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4462 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4463 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4464 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4465 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4466 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4467 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4468 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4469 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4470 mem_types[MT_ROM].prot_sect |= cp->pmd;
4471
4472 switch (cp->pmd) {
4473 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4474 * called function. This means you can't use any function or debugging
4475 * method which may touch any device, otherwise the kernel _will_ crash.
4476 */
4477 +
4478 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4479 +
4480 static void __init devicemaps_init(struct machine_desc *mdesc)
4481 {
4482 struct map_desc map;
4483 unsigned long addr;
4484 - void *vectors;
4485
4486 - /*
4487 - * Allocate the vector page early.
4488 - */
4489 - vectors = early_alloc(PAGE_SIZE * 2);
4490 -
4491 - early_trap_init(vectors);
4492 + early_trap_init(&vectors);
4493
4494 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4495 pmd_clear(pmd_off_k(addr));
4496 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4497 * location (0xffff0000). If we aren't using high-vectors, also
4498 * create a mapping at the low-vectors virtual address.
4499 */
4500 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4501 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4502 map.virtual = 0xffff0000;
4503 map.length = PAGE_SIZE;
4504 #ifdef CONFIG_KUSER_HELPERS
4505 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4506 map.pfn = __phys_to_pfn(start);
4507 map.virtual = __phys_to_virt(start);
4508 map.length = end - start;
4509 - map.type = MT_MEMORY;
4510
4511 +#ifdef CONFIG_PAX_KERNEXEC
4512 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4513 + struct map_desc kernel;
4514 + struct map_desc initmap;
4515 +
4516 + /* when freeing initmem we will make this RW */
4517 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4518 + initmap.virtual = (unsigned long)__init_begin;
4519 + initmap.length = _sdata - __init_begin;
4520 + initmap.type = MT_MEMORY_RWX;
4521 + create_mapping(&initmap);
4522 +
4523 + /* when freeing initmem we will make this RX */
4524 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4525 + kernel.virtual = (unsigned long)_stext;
4526 + kernel.length = __init_begin - _stext;
4527 + kernel.type = MT_MEMORY_RWX;
4528 + create_mapping(&kernel);
4529 +
4530 + if (map.virtual < (unsigned long)_stext) {
4531 + map.length = (unsigned long)_stext - map.virtual;
4532 + map.type = MT_MEMORY_RWX;
4533 + create_mapping(&map);
4534 + }
4535 +
4536 + map.pfn = __phys_to_pfn(__pa(_sdata));
4537 + map.virtual = (unsigned long)_sdata;
4538 + map.length = end - __pa(_sdata);
4539 + }
4540 +#endif
4541 +
4542 + map.type = MT_MEMORY_RW;
4543 create_mapping(&map);
4544 }
4545 }
4546 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4547 index a5bc92d..0bb4730 100644
4548 --- a/arch/arm/plat-omap/sram.c
4549 +++ b/arch/arm/plat-omap/sram.c
4550 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4551 * Looks like we need to preserve some bootloader code at the
4552 * beginning of SRAM for jumping to flash for reboot to work...
4553 */
4554 + pax_open_kernel();
4555 memset_io(omap_sram_base + omap_sram_skip, 0,
4556 omap_sram_size - omap_sram_skip);
4557 + pax_close_kernel();
4558 }
4559 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4560 index ce6d763..cfea917 100644
4561 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4562 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4563 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4564 int (*started)(unsigned ch);
4565 int (*flush)(unsigned ch);
4566 int (*stop)(unsigned ch);
4567 -};
4568 +} __no_const;
4569
4570 extern void *samsung_dmadev_get_ops(void);
4571 extern void *s3c_dma_get_ops(void);
4572 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4573 index c3a58a1..78fbf54 100644
4574 --- a/arch/avr32/include/asm/cache.h
4575 +++ b/arch/avr32/include/asm/cache.h
4576 @@ -1,8 +1,10 @@
4577 #ifndef __ASM_AVR32_CACHE_H
4578 #define __ASM_AVR32_CACHE_H
4579
4580 +#include <linux/const.h>
4581 +
4582 #define L1_CACHE_SHIFT 5
4583 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4584 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4585
4586 /*
4587 * Memory returned by kmalloc() may be used for DMA, so we must make
4588 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4589 index d232888..87c8df1 100644
4590 --- a/arch/avr32/include/asm/elf.h
4591 +++ b/arch/avr32/include/asm/elf.h
4592 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4593 the loader. We need to make sure that it is out of the way of the program
4594 that it will "exec", and that there is sufficient room for the brk. */
4595
4596 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4597 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4598
4599 +#ifdef CONFIG_PAX_ASLR
4600 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4601 +
4602 +#define PAX_DELTA_MMAP_LEN 15
4603 +#define PAX_DELTA_STACK_LEN 15
4604 +#endif
4605
4606 /* This yields a mask that user programs can use to figure out what
4607 instruction set this CPU supports. This could be done in user space,
4608 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4609 index 479330b..53717a8 100644
4610 --- a/arch/avr32/include/asm/kmap_types.h
4611 +++ b/arch/avr32/include/asm/kmap_types.h
4612 @@ -2,9 +2,9 @@
4613 #define __ASM_AVR32_KMAP_TYPES_H
4614
4615 #ifdef CONFIG_DEBUG_HIGHMEM
4616 -# define KM_TYPE_NR 29
4617 +# define KM_TYPE_NR 30
4618 #else
4619 -# define KM_TYPE_NR 14
4620 +# define KM_TYPE_NR 15
4621 #endif
4622
4623 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4624 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4625 index b2f2d2d..d1c85cb 100644
4626 --- a/arch/avr32/mm/fault.c
4627 +++ b/arch/avr32/mm/fault.c
4628 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4629
4630 int exception_trace = 1;
4631
4632 +#ifdef CONFIG_PAX_PAGEEXEC
4633 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4634 +{
4635 + unsigned long i;
4636 +
4637 + printk(KERN_ERR "PAX: bytes at PC: ");
4638 + for (i = 0; i < 20; i++) {
4639 + unsigned char c;
4640 + if (get_user(c, (unsigned char *)pc+i))
4641 + printk(KERN_CONT "???????? ");
4642 + else
4643 + printk(KERN_CONT "%02x ", c);
4644 + }
4645 + printk("\n");
4646 +}
4647 +#endif
4648 +
4649 /*
4650 * This routine handles page faults. It determines the address and the
4651 * problem, and then passes it off to one of the appropriate routines.
4652 @@ -174,6 +191,16 @@ bad_area:
4653 up_read(&mm->mmap_sem);
4654
4655 if (user_mode(regs)) {
4656 +
4657 +#ifdef CONFIG_PAX_PAGEEXEC
4658 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4659 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4660 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4661 + do_group_exit(SIGKILL);
4662 + }
4663 + }
4664 +#endif
4665 +
4666 if (exception_trace && printk_ratelimit())
4667 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4668 "sp %08lx ecr %lu\n",
4669 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4670 index 568885a..f8008df 100644
4671 --- a/arch/blackfin/include/asm/cache.h
4672 +++ b/arch/blackfin/include/asm/cache.h
4673 @@ -7,6 +7,7 @@
4674 #ifndef __ARCH_BLACKFIN_CACHE_H
4675 #define __ARCH_BLACKFIN_CACHE_H
4676
4677 +#include <linux/const.h>
4678 #include <linux/linkage.h> /* for asmlinkage */
4679
4680 /*
4681 @@ -14,7 +15,7 @@
4682 * Blackfin loads 32 bytes for cache
4683 */
4684 #define L1_CACHE_SHIFT 5
4685 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4686 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4687 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4688
4689 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4690 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4691 index aea2718..3639a60 100644
4692 --- a/arch/cris/include/arch-v10/arch/cache.h
4693 +++ b/arch/cris/include/arch-v10/arch/cache.h
4694 @@ -1,8 +1,9 @@
4695 #ifndef _ASM_ARCH_CACHE_H
4696 #define _ASM_ARCH_CACHE_H
4697
4698 +#include <linux/const.h>
4699 /* Etrax 100LX have 32-byte cache-lines. */
4700 -#define L1_CACHE_BYTES 32
4701 #define L1_CACHE_SHIFT 5
4702 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4703
4704 #endif /* _ASM_ARCH_CACHE_H */
4705 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4706 index 7caf25d..ee65ac5 100644
4707 --- a/arch/cris/include/arch-v32/arch/cache.h
4708 +++ b/arch/cris/include/arch-v32/arch/cache.h
4709 @@ -1,11 +1,12 @@
4710 #ifndef _ASM_CRIS_ARCH_CACHE_H
4711 #define _ASM_CRIS_ARCH_CACHE_H
4712
4713 +#include <linux/const.h>
4714 #include <arch/hwregs/dma.h>
4715
4716 /* A cache-line is 32 bytes. */
4717 -#define L1_CACHE_BYTES 32
4718 #define L1_CACHE_SHIFT 5
4719 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4720
4721 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4722
4723 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4724 index b86329d..6709906 100644
4725 --- a/arch/frv/include/asm/atomic.h
4726 +++ b/arch/frv/include/asm/atomic.h
4727 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4728 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4729 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4730
4731 +#define atomic64_read_unchecked(v) atomic64_read(v)
4732 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4733 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4734 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4735 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4736 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4737 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4738 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4739 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4740 +
4741 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4742 {
4743 int c, old;
4744 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4745 index 2797163..c2a401d 100644
4746 --- a/arch/frv/include/asm/cache.h
4747 +++ b/arch/frv/include/asm/cache.h
4748 @@ -12,10 +12,11 @@
4749 #ifndef __ASM_CACHE_H
4750 #define __ASM_CACHE_H
4751
4752 +#include <linux/const.h>
4753
4754 /* bytes per L1 cache line */
4755 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4756 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4757 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4758
4759 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4760 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4761 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4762 index 43901f2..0d8b865 100644
4763 --- a/arch/frv/include/asm/kmap_types.h
4764 +++ b/arch/frv/include/asm/kmap_types.h
4765 @@ -2,6 +2,6 @@
4766 #ifndef _ASM_KMAP_TYPES_H
4767 #define _ASM_KMAP_TYPES_H
4768
4769 -#define KM_TYPE_NR 17
4770 +#define KM_TYPE_NR 18
4771
4772 #endif
4773 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4774 index 836f147..4cf23f5 100644
4775 --- a/arch/frv/mm/elf-fdpic.c
4776 +++ b/arch/frv/mm/elf-fdpic.c
4777 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4778 {
4779 struct vm_area_struct *vma;
4780 struct vm_unmapped_area_info info;
4781 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4782
4783 if (len > TASK_SIZE)
4784 return -ENOMEM;
4785 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4786 if (addr) {
4787 addr = PAGE_ALIGN(addr);
4788 vma = find_vma(current->mm, addr);
4789 - if (TASK_SIZE - len >= addr &&
4790 - (!vma || addr + len <= vma->vm_start))
4791 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4792 goto success;
4793 }
4794
4795 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4796 info.high_limit = (current->mm->start_stack - 0x00200000);
4797 info.align_mask = 0;
4798 info.align_offset = 0;
4799 + info.threadstack_offset = offset;
4800 addr = vm_unmapped_area(&info);
4801 if (!(addr & ~PAGE_MASK))
4802 goto success;
4803 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4804 index f4ca594..adc72fd6 100644
4805 --- a/arch/hexagon/include/asm/cache.h
4806 +++ b/arch/hexagon/include/asm/cache.h
4807 @@ -21,9 +21,11 @@
4808 #ifndef __ASM_CACHE_H
4809 #define __ASM_CACHE_H
4810
4811 +#include <linux/const.h>
4812 +
4813 /* Bytes per L1 cache line */
4814 -#define L1_CACHE_SHIFT (5)
4815 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4816 +#define L1_CACHE_SHIFT 5
4817 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4818
4819 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4820 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4821 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4822 index 6e6fe18..a6ae668 100644
4823 --- a/arch/ia64/include/asm/atomic.h
4824 +++ b/arch/ia64/include/asm/atomic.h
4825 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4826 #define atomic64_inc(v) atomic64_add(1, (v))
4827 #define atomic64_dec(v) atomic64_sub(1, (v))
4828
4829 +#define atomic64_read_unchecked(v) atomic64_read(v)
4830 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4831 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4832 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4833 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4834 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4835 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4836 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4837 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4838 +
4839 /* Atomic operations are already serializing */
4840 #define smp_mb__before_atomic_dec() barrier()
4841 #define smp_mb__after_atomic_dec() barrier()
4842 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4843 index 988254a..e1ee885 100644
4844 --- a/arch/ia64/include/asm/cache.h
4845 +++ b/arch/ia64/include/asm/cache.h
4846 @@ -1,6 +1,7 @@
4847 #ifndef _ASM_IA64_CACHE_H
4848 #define _ASM_IA64_CACHE_H
4849
4850 +#include <linux/const.h>
4851
4852 /*
4853 * Copyright (C) 1998-2000 Hewlett-Packard Co
4854 @@ -9,7 +10,7 @@
4855
4856 /* Bytes per L1 (data) cache line. */
4857 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4858 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4859 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4860
4861 #ifdef CONFIG_SMP
4862 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4863 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4864 index 5a83c5c..4d7f553 100644
4865 --- a/arch/ia64/include/asm/elf.h
4866 +++ b/arch/ia64/include/asm/elf.h
4867 @@ -42,6 +42,13 @@
4868 */
4869 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4870
4871 +#ifdef CONFIG_PAX_ASLR
4872 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4873 +
4874 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4875 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4876 +#endif
4877 +
4878 #define PT_IA_64_UNWIND 0x70000001
4879
4880 /* IA-64 relocations: */
4881 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4882 index 96a8d92..617a1cf 100644
4883 --- a/arch/ia64/include/asm/pgalloc.h
4884 +++ b/arch/ia64/include/asm/pgalloc.h
4885 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4886 pgd_val(*pgd_entry) = __pa(pud);
4887 }
4888
4889 +static inline void
4890 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4891 +{
4892 + pgd_populate(mm, pgd_entry, pud);
4893 +}
4894 +
4895 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4896 {
4897 return quicklist_alloc(0, GFP_KERNEL, NULL);
4898 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4899 pud_val(*pud_entry) = __pa(pmd);
4900 }
4901
4902 +static inline void
4903 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4904 +{
4905 + pud_populate(mm, pud_entry, pmd);
4906 +}
4907 +
4908 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4909 {
4910 return quicklist_alloc(0, GFP_KERNEL, NULL);
4911 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4912 index 7935115..c0eca6a 100644
4913 --- a/arch/ia64/include/asm/pgtable.h
4914 +++ b/arch/ia64/include/asm/pgtable.h
4915 @@ -12,7 +12,7 @@
4916 * David Mosberger-Tang <davidm@hpl.hp.com>
4917 */
4918
4919 -
4920 +#include <linux/const.h>
4921 #include <asm/mman.h>
4922 #include <asm/page.h>
4923 #include <asm/processor.h>
4924 @@ -142,6 +142,17 @@
4925 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4926 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4927 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4928 +
4929 +#ifdef CONFIG_PAX_PAGEEXEC
4930 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4931 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4932 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4933 +#else
4934 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4935 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4936 +# define PAGE_COPY_NOEXEC PAGE_COPY
4937 +#endif
4938 +
4939 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4940 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4941 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4942 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4943 index 54ff557..70c88b7 100644
4944 --- a/arch/ia64/include/asm/spinlock.h
4945 +++ b/arch/ia64/include/asm/spinlock.h
4946 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4947 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4948
4949 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4950 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4951 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4952 }
4953
4954 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4955 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4956 index 449c8c0..18965fb 100644
4957 --- a/arch/ia64/include/asm/uaccess.h
4958 +++ b/arch/ia64/include/asm/uaccess.h
4959 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4960 static inline unsigned long
4961 __copy_to_user (void __user *to, const void *from, unsigned long count)
4962 {
4963 + if (count > INT_MAX)
4964 + return count;
4965 +
4966 + if (!__builtin_constant_p(count))
4967 + check_object_size(from, count, true);
4968 +
4969 return __copy_user(to, (__force void __user *) from, count);
4970 }
4971
4972 static inline unsigned long
4973 __copy_from_user (void *to, const void __user *from, unsigned long count)
4974 {
4975 + if (count > INT_MAX)
4976 + return count;
4977 +
4978 + if (!__builtin_constant_p(count))
4979 + check_object_size(to, count, false);
4980 +
4981 return __copy_user((__force void __user *) to, from, count);
4982 }
4983
4984 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4985 ({ \
4986 void __user *__cu_to = (to); \
4987 const void *__cu_from = (from); \
4988 - long __cu_len = (n); \
4989 + unsigned long __cu_len = (n); \
4990 \
4991 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4992 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4993 + if (!__builtin_constant_p(n)) \
4994 + check_object_size(__cu_from, __cu_len, true); \
4995 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4996 + } \
4997 __cu_len; \
4998 })
4999
5000 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5001 ({ \
5002 void *__cu_to = (to); \
5003 const void __user *__cu_from = (from); \
5004 - long __cu_len = (n); \
5005 + unsigned long __cu_len = (n); \
5006 \
5007 __chk_user_ptr(__cu_from); \
5008 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5009 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5010 + if (!__builtin_constant_p(n)) \
5011 + check_object_size(__cu_to, __cu_len, false); \
5012 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5013 + } \
5014 __cu_len; \
5015 })
5016
5017 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5018 index 24603be..948052d 100644
5019 --- a/arch/ia64/kernel/module.c
5020 +++ b/arch/ia64/kernel/module.c
5021 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5022 void
5023 module_free (struct module *mod, void *module_region)
5024 {
5025 - if (mod && mod->arch.init_unw_table &&
5026 - module_region == mod->module_init) {
5027 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5028 unw_remove_unwind_table(mod->arch.init_unw_table);
5029 mod->arch.init_unw_table = NULL;
5030 }
5031 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5032 }
5033
5034 static inline int
5035 +in_init_rx (const struct module *mod, uint64_t addr)
5036 +{
5037 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5038 +}
5039 +
5040 +static inline int
5041 +in_init_rw (const struct module *mod, uint64_t addr)
5042 +{
5043 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5044 +}
5045 +
5046 +static inline int
5047 in_init (const struct module *mod, uint64_t addr)
5048 {
5049 - return addr - (uint64_t) mod->module_init < mod->init_size;
5050 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5051 +}
5052 +
5053 +static inline int
5054 +in_core_rx (const struct module *mod, uint64_t addr)
5055 +{
5056 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5057 +}
5058 +
5059 +static inline int
5060 +in_core_rw (const struct module *mod, uint64_t addr)
5061 +{
5062 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5063 }
5064
5065 static inline int
5066 in_core (const struct module *mod, uint64_t addr)
5067 {
5068 - return addr - (uint64_t) mod->module_core < mod->core_size;
5069 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5070 }
5071
5072 static inline int
5073 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5074 break;
5075
5076 case RV_BDREL:
5077 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5078 + if (in_init_rx(mod, val))
5079 + val -= (uint64_t) mod->module_init_rx;
5080 + else if (in_init_rw(mod, val))
5081 + val -= (uint64_t) mod->module_init_rw;
5082 + else if (in_core_rx(mod, val))
5083 + val -= (uint64_t) mod->module_core_rx;
5084 + else if (in_core_rw(mod, val))
5085 + val -= (uint64_t) mod->module_core_rw;
5086 break;
5087
5088 case RV_LTV:
5089 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5090 * addresses have been selected...
5091 */
5092 uint64_t gp;
5093 - if (mod->core_size > MAX_LTOFF)
5094 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5095 /*
5096 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5097 * at the end of the module.
5098 */
5099 - gp = mod->core_size - MAX_LTOFF / 2;
5100 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5101 else
5102 - gp = mod->core_size / 2;
5103 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5104 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5105 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5106 mod->arch.gp = gp;
5107 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5108 }
5109 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5110 index ab33328..f39506c 100644
5111 --- a/arch/ia64/kernel/palinfo.c
5112 +++ b/arch/ia64/kernel/palinfo.c
5113 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5114 return NOTIFY_OK;
5115 }
5116
5117 -static struct notifier_block __refdata palinfo_cpu_notifier =
5118 +static struct notifier_block palinfo_cpu_notifier =
5119 {
5120 .notifier_call = palinfo_cpu_callback,
5121 .priority = 0,
5122 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5123 index 41e33f8..65180b2 100644
5124 --- a/arch/ia64/kernel/sys_ia64.c
5125 +++ b/arch/ia64/kernel/sys_ia64.c
5126 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5127 unsigned long align_mask = 0;
5128 struct mm_struct *mm = current->mm;
5129 struct vm_unmapped_area_info info;
5130 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5131
5132 if (len > RGN_MAP_LIMIT)
5133 return -ENOMEM;
5134 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5135 if (REGION_NUMBER(addr) == RGN_HPAGE)
5136 addr = 0;
5137 #endif
5138 +
5139 +#ifdef CONFIG_PAX_RANDMMAP
5140 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5141 + addr = mm->free_area_cache;
5142 + else
5143 +#endif
5144 +
5145 if (!addr)
5146 addr = TASK_UNMAPPED_BASE;
5147
5148 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5149 info.high_limit = TASK_SIZE;
5150 info.align_mask = align_mask;
5151 info.align_offset = 0;
5152 + info.threadstack_offset = offset;
5153 return vm_unmapped_area(&info);
5154 }
5155
5156 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5157 index 0ccb28f..8992469 100644
5158 --- a/arch/ia64/kernel/vmlinux.lds.S
5159 +++ b/arch/ia64/kernel/vmlinux.lds.S
5160 @@ -198,7 +198,7 @@ SECTIONS {
5161 /* Per-cpu data: */
5162 . = ALIGN(PERCPU_PAGE_SIZE);
5163 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5164 - __phys_per_cpu_start = __per_cpu_load;
5165 + __phys_per_cpu_start = per_cpu_load;
5166 /*
5167 * ensure percpu data fits
5168 * into percpu page size
5169 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5170 index 6cf0341..d352594 100644
5171 --- a/arch/ia64/mm/fault.c
5172 +++ b/arch/ia64/mm/fault.c
5173 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5174 return pte_present(pte);
5175 }
5176
5177 +#ifdef CONFIG_PAX_PAGEEXEC
5178 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5179 +{
5180 + unsigned long i;
5181 +
5182 + printk(KERN_ERR "PAX: bytes at PC: ");
5183 + for (i = 0; i < 8; i++) {
5184 + unsigned int c;
5185 + if (get_user(c, (unsigned int *)pc+i))
5186 + printk(KERN_CONT "???????? ");
5187 + else
5188 + printk(KERN_CONT "%08x ", c);
5189 + }
5190 + printk("\n");
5191 +}
5192 +#endif
5193 +
5194 # define VM_READ_BIT 0
5195 # define VM_WRITE_BIT 1
5196 # define VM_EXEC_BIT 2
5197 @@ -149,8 +166,21 @@ retry:
5198 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5199 goto bad_area;
5200
5201 - if ((vma->vm_flags & mask) != mask)
5202 + if ((vma->vm_flags & mask) != mask) {
5203 +
5204 +#ifdef CONFIG_PAX_PAGEEXEC
5205 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5206 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5207 + goto bad_area;
5208 +
5209 + up_read(&mm->mmap_sem);
5210 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5211 + do_group_exit(SIGKILL);
5212 + }
5213 +#endif
5214 +
5215 goto bad_area;
5216 + }
5217
5218 /*
5219 * If for any reason at all we couldn't handle the fault, make
5220 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5221 index 76069c1..c2aa816 100644
5222 --- a/arch/ia64/mm/hugetlbpage.c
5223 +++ b/arch/ia64/mm/hugetlbpage.c
5224 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5225 unsigned long pgoff, unsigned long flags)
5226 {
5227 struct vm_unmapped_area_info info;
5228 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5229
5230 if (len > RGN_MAP_LIMIT)
5231 return -ENOMEM;
5232 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5233 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5234 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5235 info.align_offset = 0;
5236 + info.threadstack_offset = offset;
5237 return vm_unmapped_area(&info);
5238 }
5239
5240 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5241 index b6f7f43..c04320d 100644
5242 --- a/arch/ia64/mm/init.c
5243 +++ b/arch/ia64/mm/init.c
5244 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5245 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5246 vma->vm_end = vma->vm_start + PAGE_SIZE;
5247 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5248 +
5249 +#ifdef CONFIG_PAX_PAGEEXEC
5250 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5251 + vma->vm_flags &= ~VM_EXEC;
5252 +
5253 +#ifdef CONFIG_PAX_MPROTECT
5254 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5255 + vma->vm_flags &= ~VM_MAYEXEC;
5256 +#endif
5257 +
5258 + }
5259 +#endif
5260 +
5261 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5262 down_write(&current->mm->mmap_sem);
5263 if (insert_vm_struct(current->mm, vma)) {
5264 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5265 index 40b3ee9..8c2c112 100644
5266 --- a/arch/m32r/include/asm/cache.h
5267 +++ b/arch/m32r/include/asm/cache.h
5268 @@ -1,8 +1,10 @@
5269 #ifndef _ASM_M32R_CACHE_H
5270 #define _ASM_M32R_CACHE_H
5271
5272 +#include <linux/const.h>
5273 +
5274 /* L1 cache line size */
5275 #define L1_CACHE_SHIFT 4
5276 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5277 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5278
5279 #endif /* _ASM_M32R_CACHE_H */
5280 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5281 index 82abd15..d95ae5d 100644
5282 --- a/arch/m32r/lib/usercopy.c
5283 +++ b/arch/m32r/lib/usercopy.c
5284 @@ -14,6 +14,9 @@
5285 unsigned long
5286 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5287 {
5288 + if ((long)n < 0)
5289 + return n;
5290 +
5291 prefetch(from);
5292 if (access_ok(VERIFY_WRITE, to, n))
5293 __copy_user(to,from,n);
5294 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5295 unsigned long
5296 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5297 {
5298 + if ((long)n < 0)
5299 + return n;
5300 +
5301 prefetchw(to);
5302 if (access_ok(VERIFY_READ, from, n))
5303 __copy_user_zeroing(to,from,n);
5304 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5305 index 0395c51..5f26031 100644
5306 --- a/arch/m68k/include/asm/cache.h
5307 +++ b/arch/m68k/include/asm/cache.h
5308 @@ -4,9 +4,11 @@
5309 #ifndef __ARCH_M68K_CACHE_H
5310 #define __ARCH_M68K_CACHE_H
5311
5312 +#include <linux/const.h>
5313 +
5314 /* bytes per L1 cache line */
5315 #define L1_CACHE_SHIFT 4
5316 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5317 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5318
5319 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5320
5321 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5322 index 3c52fa6..11b2ad8 100644
5323 --- a/arch/metag/mm/hugetlbpage.c
5324 +++ b/arch/metag/mm/hugetlbpage.c
5325 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5326 info.high_limit = TASK_SIZE;
5327 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5328 info.align_offset = 0;
5329 + info.threadstack_offset = 0;
5330 return vm_unmapped_area(&info);
5331 }
5332
5333 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5334 index 4efe96a..60e8699 100644
5335 --- a/arch/microblaze/include/asm/cache.h
5336 +++ b/arch/microblaze/include/asm/cache.h
5337 @@ -13,11 +13,12 @@
5338 #ifndef _ASM_MICROBLAZE_CACHE_H
5339 #define _ASM_MICROBLAZE_CACHE_H
5340
5341 +#include <linux/const.h>
5342 #include <asm/registers.h>
5343
5344 #define L1_CACHE_SHIFT 5
5345 /* word-granular cache in microblaze */
5346 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5347 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5348
5349 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5350
5351 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5352 index 08b6079..8b554d2 100644
5353 --- a/arch/mips/include/asm/atomic.h
5354 +++ b/arch/mips/include/asm/atomic.h
5355 @@ -21,15 +21,39 @@
5356 #include <asm/cmpxchg.h>
5357 #include <asm/war.h>
5358
5359 +#ifdef CONFIG_GENERIC_ATOMIC64
5360 +#include <asm-generic/atomic64.h>
5361 +#endif
5362 +
5363 #define ATOMIC_INIT(i) { (i) }
5364
5365 +#ifdef CONFIG_64BIT
5366 +#define _ASM_EXTABLE(from, to) \
5367 +" .section __ex_table,\"a\"\n" \
5368 +" .dword " #from ", " #to"\n" \
5369 +" .previous\n"
5370 +#else
5371 +#define _ASM_EXTABLE(from, to) \
5372 +" .section __ex_table,\"a\"\n" \
5373 +" .word " #from ", " #to"\n" \
5374 +" .previous\n"
5375 +#endif
5376 +
5377 /*
5378 * atomic_read - read atomic variable
5379 * @v: pointer of type atomic_t
5380 *
5381 * Atomically reads the value of @v.
5382 */
5383 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5384 +static inline int atomic_read(const atomic_t *v)
5385 +{
5386 + return (*(volatile const int *) &v->counter);
5387 +}
5388 +
5389 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5390 +{
5391 + return (*(volatile const int *) &v->counter);
5392 +}
5393
5394 /*
5395 * atomic_set - set atomic variable
5396 @@ -38,7 +62,15 @@
5397 *
5398 * Atomically sets the value of @v to @i.
5399 */
5400 -#define atomic_set(v, i) ((v)->counter = (i))
5401 +static inline void atomic_set(atomic_t *v, int i)
5402 +{
5403 + v->counter = i;
5404 +}
5405 +
5406 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5407 +{
5408 + v->counter = i;
5409 +}
5410
5411 /*
5412 * atomic_add - add integer to atomic variable
5413 @@ -47,7 +79,67 @@
5414 *
5415 * Atomically adds @i to @v.
5416 */
5417 -static __inline__ void atomic_add(int i, atomic_t * v)
5418 +static __inline__ void atomic_add(int i, atomic_t *v)
5419 +{
5420 + int temp;
5421 +
5422 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5423 + __asm__ __volatile__(
5424 + " .set mips3 \n"
5425 + "1: ll %0, %1 # atomic_add \n"
5426 +#ifdef CONFIG_PAX_REFCOUNT
5427 + /* Exception on overflow. */
5428 + "2: add %0, %2 \n"
5429 +#else
5430 + " addu %0, %2 \n"
5431 +#endif
5432 + " sc %0, %1 \n"
5433 + " beqzl %0, 1b \n"
5434 +#ifdef CONFIG_PAX_REFCOUNT
5435 + "3: \n"
5436 + _ASM_EXTABLE(2b, 3b)
5437 +#endif
5438 + " .set mips0 \n"
5439 + : "=&r" (temp), "+m" (v->counter)
5440 + : "Ir" (i));
5441 + } else if (kernel_uses_llsc) {
5442 + __asm__ __volatile__(
5443 + " .set mips3 \n"
5444 + "1: ll %0, %1 # atomic_add \n"
5445 +#ifdef CONFIG_PAX_REFCOUNT
5446 + /* Exception on overflow. */
5447 + "2: add %0, %2 \n"
5448 +#else
5449 + " addu %0, %2 \n"
5450 +#endif
5451 + " sc %0, %1 \n"
5452 + " beqz %0, 1b \n"
5453 +#ifdef CONFIG_PAX_REFCOUNT
5454 + "3: \n"
5455 + _ASM_EXTABLE(2b, 3b)
5456 +#endif
5457 + " .set mips0 \n"
5458 + : "=&r" (temp), "+m" (v->counter)
5459 + : "Ir" (i));
5460 + } else {
5461 + unsigned long flags;
5462 +
5463 + raw_local_irq_save(flags);
5464 + __asm__ __volatile__(
5465 +#ifdef CONFIG_PAX_REFCOUNT
5466 + /* Exception on overflow. */
5467 + "1: add %0, %1 \n"
5468 + "2: \n"
5469 + _ASM_EXTABLE(1b, 2b)
5470 +#else
5471 + " addu %0, %1 \n"
5472 +#endif
5473 + : "+r" (v->counter) : "Ir" (i));
5474 + raw_local_irq_restore(flags);
5475 + }
5476 +}
5477 +
5478 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5479 {
5480 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5481 int temp;
5482 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5483 *
5484 * Atomically subtracts @i from @v.
5485 */
5486 -static __inline__ void atomic_sub(int i, atomic_t * v)
5487 +static __inline__ void atomic_sub(int i, atomic_t *v)
5488 +{
5489 + int temp;
5490 +
5491 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5492 + __asm__ __volatile__(
5493 + " .set mips3 \n"
5494 + "1: ll %0, %1 # atomic64_sub \n"
5495 +#ifdef CONFIG_PAX_REFCOUNT
5496 + /* Exception on overflow. */
5497 + "2: sub %0, %2 \n"
5498 +#else
5499 + " subu %0, %2 \n"
5500 +#endif
5501 + " sc %0, %1 \n"
5502 + " beqzl %0, 1b \n"
5503 +#ifdef CONFIG_PAX_REFCOUNT
5504 + "3: \n"
5505 + _ASM_EXTABLE(2b, 3b)
5506 +#endif
5507 + " .set mips0 \n"
5508 + : "=&r" (temp), "+m" (v->counter)
5509 + : "Ir" (i));
5510 + } else if (kernel_uses_llsc) {
5511 + __asm__ __volatile__(
5512 + " .set mips3 \n"
5513 + "1: ll %0, %1 # atomic64_sub \n"
5514 +#ifdef CONFIG_PAX_REFCOUNT
5515 + /* Exception on overflow. */
5516 + "2: sub %0, %2 \n"
5517 +#else
5518 + " subu %0, %2 \n"
5519 +#endif
5520 + " sc %0, %1 \n"
5521 + " beqz %0, 1b \n"
5522 +#ifdef CONFIG_PAX_REFCOUNT
5523 + "3: \n"
5524 + _ASM_EXTABLE(2b, 3b)
5525 +#endif
5526 + " .set mips0 \n"
5527 + : "=&r" (temp), "+m" (v->counter)
5528 + : "Ir" (i));
5529 + } else {
5530 + unsigned long flags;
5531 +
5532 + raw_local_irq_save(flags);
5533 + __asm__ __volatile__(
5534 +#ifdef CONFIG_PAX_REFCOUNT
5535 + /* Exception on overflow. */
5536 + "1: sub %0, %1 \n"
5537 + "2: \n"
5538 + _ASM_EXTABLE(1b, 2b)
5539 +#else
5540 + " subu %0, %1 \n"
5541 +#endif
5542 + : "+r" (v->counter) : "Ir" (i));
5543 + raw_local_irq_restore(flags);
5544 + }
5545 +}
5546 +
5547 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5548 {
5549 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5550 int temp;
5551 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5552 /*
5553 * Same as above, but return the result value
5554 */
5555 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5556 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5557 +{
5558 + int result;
5559 + int temp;
5560 +
5561 + smp_mb__before_llsc();
5562 +
5563 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5564 + __asm__ __volatile__(
5565 + " .set mips3 \n"
5566 + "1: ll %1, %2 # atomic_add_return \n"
5567 +#ifdef CONFIG_PAX_REFCOUNT
5568 + "2: add %0, %1, %3 \n"
5569 +#else
5570 + " addu %0, %1, %3 \n"
5571 +#endif
5572 + " sc %0, %2 \n"
5573 + " beqzl %0, 1b \n"
5574 +#ifdef CONFIG_PAX_REFCOUNT
5575 + " b 4f \n"
5576 + " .set noreorder \n"
5577 + "3: b 5f \n"
5578 + " move %0, %1 \n"
5579 + " .set reorder \n"
5580 + _ASM_EXTABLE(2b, 3b)
5581 +#endif
5582 + "4: addu %0, %1, %3 \n"
5583 +#ifdef CONFIG_PAX_REFCOUNT
5584 + "5: \n"
5585 +#endif
5586 + " .set mips0 \n"
5587 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5588 + : "Ir" (i));
5589 + } else if (kernel_uses_llsc) {
5590 + __asm__ __volatile__(
5591 + " .set mips3 \n"
5592 + "1: ll %1, %2 # atomic_add_return \n"
5593 +#ifdef CONFIG_PAX_REFCOUNT
5594 + "2: add %0, %1, %3 \n"
5595 +#else
5596 + " addu %0, %1, %3 \n"
5597 +#endif
5598 + " sc %0, %2 \n"
5599 + " bnez %0, 4f \n"
5600 + " b 1b \n"
5601 +#ifdef CONFIG_PAX_REFCOUNT
5602 + " .set noreorder \n"
5603 + "3: b 5f \n"
5604 + " move %0, %1 \n"
5605 + " .set reorder \n"
5606 + _ASM_EXTABLE(2b, 3b)
5607 +#endif
5608 + "4: addu %0, %1, %3 \n"
5609 +#ifdef CONFIG_PAX_REFCOUNT
5610 + "5: \n"
5611 +#endif
5612 + " .set mips0 \n"
5613 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5614 + : "Ir" (i));
5615 + } else {
5616 + unsigned long flags;
5617 +
5618 + raw_local_irq_save(flags);
5619 + __asm__ __volatile__(
5620 + " lw %0, %1 \n"
5621 +#ifdef CONFIG_PAX_REFCOUNT
5622 + /* Exception on overflow. */
5623 + "1: add %0, %2 \n"
5624 +#else
5625 + " addu %0, %2 \n"
5626 +#endif
5627 + " sw %0, %1 \n"
5628 +#ifdef CONFIG_PAX_REFCOUNT
5629 + /* Note: Dest reg is not modified on overflow */
5630 + "2: \n"
5631 + _ASM_EXTABLE(1b, 2b)
5632 +#endif
5633 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5634 + raw_local_irq_restore(flags);
5635 + }
5636 +
5637 + smp_llsc_mb();
5638 +
5639 + return result;
5640 +}
5641 +
5642 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5643 {
5644 int result;
5645
5646 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5647 return result;
5648 }
5649
5650 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5651 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5652 +{
5653 + int result;
5654 + int temp;
5655 +
5656 + smp_mb__before_llsc();
5657 +
5658 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5659 + __asm__ __volatile__(
5660 + " .set mips3 \n"
5661 + "1: ll %1, %2 # atomic_sub_return \n"
5662 +#ifdef CONFIG_PAX_REFCOUNT
5663 + "2: sub %0, %1, %3 \n"
5664 +#else
5665 + " subu %0, %1, %3 \n"
5666 +#endif
5667 + " sc %0, %2 \n"
5668 + " beqzl %0, 1b \n"
5669 +#ifdef CONFIG_PAX_REFCOUNT
5670 + " b 4f \n"
5671 + " .set noreorder \n"
5672 + "3: b 5f \n"
5673 + " move %0, %1 \n"
5674 + " .set reorder \n"
5675 + _ASM_EXTABLE(2b, 3b)
5676 +#endif
5677 + "4: subu %0, %1, %3 \n"
5678 +#ifdef CONFIG_PAX_REFCOUNT
5679 + "5: \n"
5680 +#endif
5681 + " .set mips0 \n"
5682 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5683 + : "Ir" (i), "m" (v->counter)
5684 + : "memory");
5685 + } else if (kernel_uses_llsc) {
5686 + __asm__ __volatile__(
5687 + " .set mips3 \n"
5688 + "1: ll %1, %2 # atomic_sub_return \n"
5689 +#ifdef CONFIG_PAX_REFCOUNT
5690 + "2: sub %0, %1, %3 \n"
5691 +#else
5692 + " subu %0, %1, %3 \n"
5693 +#endif
5694 + " sc %0, %2 \n"
5695 + " bnez %0, 4f \n"
5696 + " b 1b \n"
5697 +#ifdef CONFIG_PAX_REFCOUNT
5698 + " .set noreorder \n"
5699 + "3: b 5f \n"
5700 + " move %0, %1 \n"
5701 + " .set reorder \n"
5702 + _ASM_EXTABLE(2b, 3b)
5703 +#endif
5704 + "4: subu %0, %1, %3 \n"
5705 +#ifdef CONFIG_PAX_REFCOUNT
5706 + "5: \n"
5707 +#endif
5708 + " .set mips0 \n"
5709 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5710 + : "Ir" (i));
5711 + } else {
5712 + unsigned long flags;
5713 +
5714 + raw_local_irq_save(flags);
5715 + __asm__ __volatile__(
5716 + " lw %0, %1 \n"
5717 +#ifdef CONFIG_PAX_REFCOUNT
5718 + /* Exception on overflow. */
5719 + "1: sub %0, %2 \n"
5720 +#else
5721 + " subu %0, %2 \n"
5722 +#endif
5723 + " sw %0, %1 \n"
5724 +#ifdef CONFIG_PAX_REFCOUNT
5725 + /* Note: Dest reg is not modified on overflow */
5726 + "2: \n"
5727 + _ASM_EXTABLE(1b, 2b)
5728 +#endif
5729 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5730 + raw_local_irq_restore(flags);
5731 + }
5732 +
5733 + smp_llsc_mb();
5734 +
5735 + return result;
5736 +}
5737 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5738 {
5739 int result;
5740
5741 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5742 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5743 * The function returns the old value of @v minus @i.
5744 */
5745 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5746 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5747 {
5748 int result;
5749
5750 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5751 return result;
5752 }
5753
5754 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5755 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5756 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5757 +{
5758 + return cmpxchg(&v->counter, old, new);
5759 +}
5760 +
5761 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5762 + int new)
5763 +{
5764 + return cmpxchg(&(v->counter), old, new);
5765 +}
5766 +
5767 +static inline int atomic_xchg(atomic_t *v, int new)
5768 +{
5769 + return xchg(&v->counter, new);
5770 +}
5771 +
5772 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5773 +{
5774 + return xchg(&(v->counter), new);
5775 +}
5776
5777 /**
5778 * __atomic_add_unless - add unless the number is a given value
5779 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5780
5781 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5782 #define atomic_inc_return(v) atomic_add_return(1, (v))
5783 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5784 +{
5785 + return atomic_add_return_unchecked(1, v);
5786 +}
5787
5788 /*
5789 * atomic_sub_and_test - subtract value from variable and test result
5790 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5791 * other cases.
5792 */
5793 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5794 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5795 +{
5796 + return atomic_add_return_unchecked(1, v) == 0;
5797 +}
5798
5799 /*
5800 * atomic_dec_and_test - decrement by 1 and test
5801 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5802 * Atomically increments @v by 1.
5803 */
5804 #define atomic_inc(v) atomic_add(1, (v))
5805 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5806 +{
5807 + atomic_add_unchecked(1, v);
5808 +}
5809
5810 /*
5811 * atomic_dec - decrement and test
5812 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5813 * Atomically decrements @v by 1.
5814 */
5815 #define atomic_dec(v) atomic_sub(1, (v))
5816 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5817 +{
5818 + atomic_sub_unchecked(1, v);
5819 +}
5820
5821 /*
5822 * atomic_add_negative - add and test if negative
5823 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5824 * @v: pointer of type atomic64_t
5825 *
5826 */
5827 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5828 +static inline long atomic64_read(const atomic64_t *v)
5829 +{
5830 + return (*(volatile const long *) &v->counter);
5831 +}
5832 +
5833 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5834 +{
5835 + return (*(volatile const long *) &v->counter);
5836 +}
5837
5838 /*
5839 * atomic64_set - set atomic variable
5840 * @v: pointer of type atomic64_t
5841 * @i: required value
5842 */
5843 -#define atomic64_set(v, i) ((v)->counter = (i))
5844 +static inline void atomic64_set(atomic64_t *v, long i)
5845 +{
5846 + v->counter = i;
5847 +}
5848 +
5849 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5850 +{
5851 + v->counter = i;
5852 +}
5853
5854 /*
5855 * atomic64_add - add integer to atomic variable
5856 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5857 *
5858 * Atomically adds @i to @v.
5859 */
5860 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5861 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5862 +{
5863 + long temp;
5864 +
5865 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5866 + __asm__ __volatile__(
5867 + " .set mips3 \n"
5868 + "1: lld %0, %1 # atomic64_add \n"
5869 +#ifdef CONFIG_PAX_REFCOUNT
5870 + /* Exception on overflow. */
5871 + "2: dadd %0, %2 \n"
5872 +#else
5873 + " daddu %0, %2 \n"
5874 +#endif
5875 + " scd %0, %1 \n"
5876 + " beqzl %0, 1b \n"
5877 +#ifdef CONFIG_PAX_REFCOUNT
5878 + "3: \n"
5879 + _ASM_EXTABLE(2b, 3b)
5880 +#endif
5881 + " .set mips0 \n"
5882 + : "=&r" (temp), "+m" (v->counter)
5883 + : "Ir" (i));
5884 + } else if (kernel_uses_llsc) {
5885 + __asm__ __volatile__(
5886 + " .set mips3 \n"
5887 + "1: lld %0, %1 # atomic64_add \n"
5888 +#ifdef CONFIG_PAX_REFCOUNT
5889 + /* Exception on overflow. */
5890 + "2: dadd %0, %2 \n"
5891 +#else
5892 + " daddu %0, %2 \n"
5893 +#endif
5894 + " scd %0, %1 \n"
5895 + " beqz %0, 1b \n"
5896 +#ifdef CONFIG_PAX_REFCOUNT
5897 + "3: \n"
5898 + _ASM_EXTABLE(2b, 3b)
5899 +#endif
5900 + " .set mips0 \n"
5901 + : "=&r" (temp), "+m" (v->counter)
5902 + : "Ir" (i));
5903 + } else {
5904 + unsigned long flags;
5905 +
5906 + raw_local_irq_save(flags);
5907 + __asm__ __volatile__(
5908 +#ifdef CONFIG_PAX_REFCOUNT
5909 + /* Exception on overflow. */
5910 + "1: dadd %0, %1 \n"
5911 + "2: \n"
5912 + _ASM_EXTABLE(1b, 2b)
5913 +#else
5914 + " daddu %0, %1 \n"
5915 +#endif
5916 + : "+r" (v->counter) : "Ir" (i));
5917 + raw_local_irq_restore(flags);
5918 + }
5919 +}
5920 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5921 {
5922 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5923 long temp;
5924 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5925 *
5926 * Atomically subtracts @i from @v.
5927 */
5928 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5929 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5930 +{
5931 + long temp;
5932 +
5933 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5934 + __asm__ __volatile__(
5935 + " .set mips3 \n"
5936 + "1: lld %0, %1 # atomic64_sub \n"
5937 +#ifdef CONFIG_PAX_REFCOUNT
5938 + /* Exception on overflow. */
5939 + "2: dsub %0, %2 \n"
5940 +#else
5941 + " dsubu %0, %2 \n"
5942 +#endif
5943 + " scd %0, %1 \n"
5944 + " beqzl %0, 1b \n"
5945 +#ifdef CONFIG_PAX_REFCOUNT
5946 + "3: \n"
5947 + _ASM_EXTABLE(2b, 3b)
5948 +#endif
5949 + " .set mips0 \n"
5950 + : "=&r" (temp), "+m" (v->counter)
5951 + : "Ir" (i));
5952 + } else if (kernel_uses_llsc) {
5953 + __asm__ __volatile__(
5954 + " .set mips3 \n"
5955 + "1: lld %0, %1 # atomic64_sub \n"
5956 +#ifdef CONFIG_PAX_REFCOUNT
5957 + /* Exception on overflow. */
5958 + "2: dsub %0, %2 \n"
5959 +#else
5960 + " dsubu %0, %2 \n"
5961 +#endif
5962 + " scd %0, %1 \n"
5963 + " beqz %0, 1b \n"
5964 +#ifdef CONFIG_PAX_REFCOUNT
5965 + "3: \n"
5966 + _ASM_EXTABLE(2b, 3b)
5967 +#endif
5968 + " .set mips0 \n"
5969 + : "=&r" (temp), "+m" (v->counter)
5970 + : "Ir" (i));
5971 + } else {
5972 + unsigned long flags;
5973 +
5974 + raw_local_irq_save(flags);
5975 + __asm__ __volatile__(
5976 +#ifdef CONFIG_PAX_REFCOUNT
5977 + /* Exception on overflow. */
5978 + "1: dsub %0, %1 \n"
5979 + "2: \n"
5980 + _ASM_EXTABLE(1b, 2b)
5981 +#else
5982 + " dsubu %0, %1 \n"
5983 +#endif
5984 + : "+r" (v->counter) : "Ir" (i));
5985 + raw_local_irq_restore(flags);
5986 + }
5987 +}
5988 +
5989 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5990 {
5991 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5992 long temp;
5993 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
5994 /*
5995 * Same as above, but return the result value
5996 */
5997 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
5998 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
5999 +{
6000 + long result;
6001 + long temp;
6002 +
6003 + smp_mb__before_llsc();
6004 +
6005 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6006 + __asm__ __volatile__(
6007 + " .set mips3 \n"
6008 + "1: lld %1, %2 # atomic64_add_return \n"
6009 +#ifdef CONFIG_PAX_REFCOUNT
6010 + "2: dadd %0, %1, %3 \n"
6011 +#else
6012 + " daddu %0, %1, %3 \n"
6013 +#endif
6014 + " scd %0, %2 \n"
6015 + " beqzl %0, 1b \n"
6016 +#ifdef CONFIG_PAX_REFCOUNT
6017 + " b 4f \n"
6018 + " .set noreorder \n"
6019 + "3: b 5f \n"
6020 + " move %0, %1 \n"
6021 + " .set reorder \n"
6022 + _ASM_EXTABLE(2b, 3b)
6023 +#endif
6024 + "4: daddu %0, %1, %3 \n"
6025 +#ifdef CONFIG_PAX_REFCOUNT
6026 + "5: \n"
6027 +#endif
6028 + " .set mips0 \n"
6029 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6030 + : "Ir" (i));
6031 + } else if (kernel_uses_llsc) {
6032 + __asm__ __volatile__(
6033 + " .set mips3 \n"
6034 + "1: lld %1, %2 # atomic64_add_return \n"
6035 +#ifdef CONFIG_PAX_REFCOUNT
6036 + "2: dadd %0, %1, %3 \n"
6037 +#else
6038 + " daddu %0, %1, %3 \n"
6039 +#endif
6040 + " scd %0, %2 \n"
6041 + " bnez %0, 4f \n"
6042 + " b 1b \n"
6043 +#ifdef CONFIG_PAX_REFCOUNT
6044 + " .set noreorder \n"
6045 + "3: b 5f \n"
6046 + " move %0, %1 \n"
6047 + " .set reorder \n"
6048 + _ASM_EXTABLE(2b, 3b)
6049 +#endif
6050 + "4: daddu %0, %1, %3 \n"
6051 +#ifdef CONFIG_PAX_REFCOUNT
6052 + "5: \n"
6053 +#endif
6054 + " .set mips0 \n"
6055 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6056 + : "Ir" (i), "m" (v->counter)
6057 + : "memory");
6058 + } else {
6059 + unsigned long flags;
6060 +
6061 + raw_local_irq_save(flags);
6062 + __asm__ __volatile__(
6063 + " ld %0, %1 \n"
6064 +#ifdef CONFIG_PAX_REFCOUNT
6065 + /* Exception on overflow. */
6066 + "1: dadd %0, %2 \n"
6067 +#else
6068 + " daddu %0, %2 \n"
6069 +#endif
6070 + " sd %0, %1 \n"
6071 +#ifdef CONFIG_PAX_REFCOUNT
6072 + /* Note: Dest reg is not modified on overflow */
6073 + "2: \n"
6074 + _ASM_EXTABLE(1b, 2b)
6075 +#endif
6076 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6077 + raw_local_irq_restore(flags);
6078 + }
6079 +
6080 + smp_llsc_mb();
6081 +
6082 + return result;
6083 +}
6084 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6085 {
6086 long result;
6087
6088 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6089 return result;
6090 }
6091
6092 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6093 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6094 +{
6095 + long result;
6096 + long temp;
6097 +
6098 + smp_mb__before_llsc();
6099 +
6100 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6101 + long temp;
6102 +
6103 + __asm__ __volatile__(
6104 + " .set mips3 \n"
6105 + "1: lld %1, %2 # atomic64_sub_return \n"
6106 +#ifdef CONFIG_PAX_REFCOUNT
6107 + "2: dsub %0, %1, %3 \n"
6108 +#else
6109 + " dsubu %0, %1, %3 \n"
6110 +#endif
6111 + " scd %0, %2 \n"
6112 + " beqzl %0, 1b \n"
6113 +#ifdef CONFIG_PAX_REFCOUNT
6114 + " b 4f \n"
6115 + " .set noreorder \n"
6116 + "3: b 5f \n"
6117 + " move %0, %1 \n"
6118 + " .set reorder \n"
6119 + _ASM_EXTABLE(2b, 3b)
6120 +#endif
6121 + "4: dsubu %0, %1, %3 \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + "5: \n"
6124 +#endif
6125 + " .set mips0 \n"
6126 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6127 + : "Ir" (i), "m" (v->counter)
6128 + : "memory");
6129 + } else if (kernel_uses_llsc) {
6130 + __asm__ __volatile__(
6131 + " .set mips3 \n"
6132 + "1: lld %1, %2 # atomic64_sub_return \n"
6133 +#ifdef CONFIG_PAX_REFCOUNT
6134 + "2: dsub %0, %1, %3 \n"
6135 +#else
6136 + " dsubu %0, %1, %3 \n"
6137 +#endif
6138 + " scd %0, %2 \n"
6139 + " bnez %0, 4f \n"
6140 + " b 1b \n"
6141 +#ifdef CONFIG_PAX_REFCOUNT
6142 + " .set noreorder \n"
6143 + "3: b 5f \n"
6144 + " move %0, %1 \n"
6145 + " .set reorder \n"
6146 + _ASM_EXTABLE(2b, 3b)
6147 +#endif
6148 + "4: dsubu %0, %1, %3 \n"
6149 +#ifdef CONFIG_PAX_REFCOUNT
6150 + "5: \n"
6151 +#endif
6152 + " .set mips0 \n"
6153 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6154 + : "Ir" (i), "m" (v->counter)
6155 + : "memory");
6156 + } else {
6157 + unsigned long flags;
6158 +
6159 + raw_local_irq_save(flags);
6160 + __asm__ __volatile__(
6161 + " ld %0, %1 \n"
6162 +#ifdef CONFIG_PAX_REFCOUNT
6163 + /* Exception on overflow. */
6164 + "1: dsub %0, %2 \n"
6165 +#else
6166 + " dsubu %0, %2 \n"
6167 +#endif
6168 + " sd %0, %1 \n"
6169 +#ifdef CONFIG_PAX_REFCOUNT
6170 + /* Note: Dest reg is not modified on overflow */
6171 + "2: \n"
6172 + _ASM_EXTABLE(1b, 2b)
6173 +#endif
6174 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6175 + raw_local_irq_restore(flags);
6176 + }
6177 +
6178 + smp_llsc_mb();
6179 +
6180 + return result;
6181 +}
6182 +
6183 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6184 {
6185 long result;
6186
6187 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6188 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6189 * The function returns the old value of @v minus @i.
6190 */
6191 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6192 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6193 {
6194 long result;
6195
6196 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6197 return result;
6198 }
6199
6200 -#define atomic64_cmpxchg(v, o, n) \
6201 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6202 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6203 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6204 +{
6205 + return cmpxchg(&v->counter, old, new);
6206 +}
6207 +
6208 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6209 + long new)
6210 +{
6211 + return cmpxchg(&(v->counter), old, new);
6212 +}
6213 +
6214 +static inline long atomic64_xchg(atomic64_t *v, long new)
6215 +{
6216 + return xchg(&v->counter, new);
6217 +}
6218 +
6219 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6220 +{
6221 + return xchg(&(v->counter), new);
6222 +}
6223
6224 /**
6225 * atomic64_add_unless - add unless the number is a given value
6226 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6227
6228 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6229 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6230 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6231
6232 /*
6233 * atomic64_sub_and_test - subtract value from variable and test result
6234 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6235 * other cases.
6236 */
6237 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6238 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6239
6240 /*
6241 * atomic64_dec_and_test - decrement by 1 and test
6242 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6243 * Atomically increments @v by 1.
6244 */
6245 #define atomic64_inc(v) atomic64_add(1, (v))
6246 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6247
6248 /*
6249 * atomic64_dec - decrement and test
6250 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6251 * Atomically decrements @v by 1.
6252 */
6253 #define atomic64_dec(v) atomic64_sub(1, (v))
6254 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6255
6256 /*
6257 * atomic64_add_negative - add and test if negative
6258 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6259 index b4db69f..8f3b093 100644
6260 --- a/arch/mips/include/asm/cache.h
6261 +++ b/arch/mips/include/asm/cache.h
6262 @@ -9,10 +9,11 @@
6263 #ifndef _ASM_CACHE_H
6264 #define _ASM_CACHE_H
6265
6266 +#include <linux/const.h>
6267 #include <kmalloc.h>
6268
6269 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6270 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6271 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6272
6273 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6274 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6275 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6276 index cf3ae24..238d22f 100644
6277 --- a/arch/mips/include/asm/elf.h
6278 +++ b/arch/mips/include/asm/elf.h
6279 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6280 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6281 #endif
6282
6283 +#ifdef CONFIG_PAX_ASLR
6284 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6285 +
6286 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6287 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6288 +#endif
6289 +
6290 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6291 struct linux_binprm;
6292 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6293 int uses_interp);
6294
6295 -struct mm_struct;
6296 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6297 -#define arch_randomize_brk arch_randomize_brk
6298 -
6299 #endif /* _ASM_ELF_H */
6300 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6301 index c1f6afa..38cc6e9 100644
6302 --- a/arch/mips/include/asm/exec.h
6303 +++ b/arch/mips/include/asm/exec.h
6304 @@ -12,6 +12,6 @@
6305 #ifndef _ASM_EXEC_H
6306 #define _ASM_EXEC_H
6307
6308 -extern unsigned long arch_align_stack(unsigned long sp);
6309 +#define arch_align_stack(x) ((x) & ~0xfUL)
6310
6311 #endif /* _ASM_EXEC_H */
6312 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6313 index d44622c..64990d2 100644
6314 --- a/arch/mips/include/asm/local.h
6315 +++ b/arch/mips/include/asm/local.h
6316 @@ -12,15 +12,25 @@ typedef struct
6317 atomic_long_t a;
6318 } local_t;
6319
6320 +typedef struct {
6321 + atomic_long_unchecked_t a;
6322 +} local_unchecked_t;
6323 +
6324 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6325
6326 #define local_read(l) atomic_long_read(&(l)->a)
6327 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6328 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6329 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6330
6331 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6332 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6333 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6334 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6335 #define local_inc(l) atomic_long_inc(&(l)->a)
6336 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6337 #define local_dec(l) atomic_long_dec(&(l)->a)
6338 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6339
6340 /*
6341 * Same as above, but return the result value
6342 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6343 return result;
6344 }
6345
6346 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6347 +{
6348 + unsigned long result;
6349 +
6350 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6351 + unsigned long temp;
6352 +
6353 + __asm__ __volatile__(
6354 + " .set mips3 \n"
6355 + "1:" __LL "%1, %2 # local_add_return \n"
6356 + " addu %0, %1, %3 \n"
6357 + __SC "%0, %2 \n"
6358 + " beqzl %0, 1b \n"
6359 + " addu %0, %1, %3 \n"
6360 + " .set mips0 \n"
6361 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6362 + : "Ir" (i), "m" (l->a.counter)
6363 + : "memory");
6364 + } else if (kernel_uses_llsc) {
6365 + unsigned long temp;
6366 +
6367 + __asm__ __volatile__(
6368 + " .set mips3 \n"
6369 + "1:" __LL "%1, %2 # local_add_return \n"
6370 + " addu %0, %1, %3 \n"
6371 + __SC "%0, %2 \n"
6372 + " beqz %0, 1b \n"
6373 + " addu %0, %1, %3 \n"
6374 + " .set mips0 \n"
6375 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6376 + : "Ir" (i), "m" (l->a.counter)
6377 + : "memory");
6378 + } else {
6379 + unsigned long flags;
6380 +
6381 + local_irq_save(flags);
6382 + result = l->a.counter;
6383 + result += i;
6384 + l->a.counter = result;
6385 + local_irq_restore(flags);
6386 + }
6387 +
6388 + return result;
6389 +}
6390 +
6391 static __inline__ long local_sub_return(long i, local_t * l)
6392 {
6393 unsigned long result;
6394 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6395
6396 #define local_cmpxchg(l, o, n) \
6397 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6398 +#define local_cmpxchg_unchecked(l, o, n) \
6399 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6400 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6401
6402 /**
6403 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6404 index f6be474..12ad554 100644
6405 --- a/arch/mips/include/asm/page.h
6406 +++ b/arch/mips/include/asm/page.h
6407 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6408 #ifdef CONFIG_CPU_MIPS32
6409 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6410 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6411 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6412 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6413 #else
6414 typedef struct { unsigned long long pte; } pte_t;
6415 #define pte_val(x) ((x).pte)
6416 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6417 index 881d18b..cea38bc 100644
6418 --- a/arch/mips/include/asm/pgalloc.h
6419 +++ b/arch/mips/include/asm/pgalloc.h
6420 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6421 {
6422 set_pud(pud, __pud((unsigned long)pmd));
6423 }
6424 +
6425 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6426 +{
6427 + pud_populate(mm, pud, pmd);
6428 +}
6429 #endif
6430
6431 /*
6432 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6433 index 25da651..ae2a259 100644
6434 --- a/arch/mips/include/asm/smtc_proc.h
6435 +++ b/arch/mips/include/asm/smtc_proc.h
6436 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6437
6438 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6439
6440 -extern atomic_t smtc_fpu_recoveries;
6441 +extern atomic_unchecked_t smtc_fpu_recoveries;
6442
6443 #endif /* __ASM_SMTC_PROC_H */
6444 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6445 index 61215a3..213ee0e 100644
6446 --- a/arch/mips/include/asm/thread_info.h
6447 +++ b/arch/mips/include/asm/thread_info.h
6448 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6449 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6450 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6451 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6452 +/* li takes a 32bit immediate */
6453 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6454 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6455
6456 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6457 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6458 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6459 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6460 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6461 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6462
6463 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6464 - _TIF_SYSCALL_AUDIT)
6465 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6466
6467 /* work to do in syscall_trace_leave() */
6468 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6469 - _TIF_SYSCALL_AUDIT)
6470 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6471
6472 /* work to do on interrupt/exception return */
6473 #define _TIF_WORK_MASK \
6474 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6475 /* work to do on any return to u-space */
6476 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6477 - _TIF_WORK_SYSCALL_EXIT)
6478 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6479
6480 #endif /* __KERNEL__ */
6481
6482 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6483 index 1188e00..41cf144 100644
6484 --- a/arch/mips/kernel/binfmt_elfn32.c
6485 +++ b/arch/mips/kernel/binfmt_elfn32.c
6486 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6487 #undef ELF_ET_DYN_BASE
6488 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6489
6490 +#ifdef CONFIG_PAX_ASLR
6491 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6492 +
6493 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6494 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6495 +#endif
6496 +
6497 #include <asm/processor.h>
6498 #include <linux/module.h>
6499 #include <linux/elfcore.h>
6500 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6501 index 202e581..689ca79 100644
6502 --- a/arch/mips/kernel/binfmt_elfo32.c
6503 +++ b/arch/mips/kernel/binfmt_elfo32.c
6504 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6505 #undef ELF_ET_DYN_BASE
6506 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6507
6508 +#ifdef CONFIG_PAX_ASLR
6509 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6510 +
6511 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6512 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6513 +#endif
6514 +
6515 #include <asm/processor.h>
6516
6517 /*
6518 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6519 index d1fea7a..45602ea 100644
6520 --- a/arch/mips/kernel/irq.c
6521 +++ b/arch/mips/kernel/irq.c
6522 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6523 printk("unexpected IRQ # %d\n", irq);
6524 }
6525
6526 -atomic_t irq_err_count;
6527 +atomic_unchecked_t irq_err_count;
6528
6529 int arch_show_interrupts(struct seq_file *p, int prec)
6530 {
6531 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6532 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6533 return 0;
6534 }
6535
6536 asmlinkage void spurious_interrupt(void)
6537 {
6538 - atomic_inc(&irq_err_count);
6539 + atomic_inc_unchecked(&irq_err_count);
6540 }
6541
6542 void __init init_IRQ(void)
6543 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6544 index ddc7610..8c58f17 100644
6545 --- a/arch/mips/kernel/process.c
6546 +++ b/arch/mips/kernel/process.c
6547 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6548 out:
6549 return pc;
6550 }
6551 -
6552 -/*
6553 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6554 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6555 - */
6556 -unsigned long arch_align_stack(unsigned long sp)
6557 -{
6558 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6559 - sp -= get_random_int() & ~PAGE_MASK;
6560 -
6561 - return sp & ALMASK;
6562 -}
6563 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6564 index 8ae1ebe..1bcbf47 100644
6565 --- a/arch/mips/kernel/ptrace.c
6566 +++ b/arch/mips/kernel/ptrace.c
6567 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6568 return arch;
6569 }
6570
6571 +#ifdef CONFIG_GRKERNSEC_SETXID
6572 +extern void gr_delayed_cred_worker(void);
6573 +#endif
6574 +
6575 /*
6576 * Notification of system call entry/exit
6577 * - triggered by current->work.syscall_trace
6578 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6579 /* do the secure computing check first */
6580 secure_computing_strict(regs->regs[2]);
6581
6582 +#ifdef CONFIG_GRKERNSEC_SETXID
6583 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6584 + gr_delayed_cred_worker();
6585 +#endif
6586 +
6587 if (!(current->ptrace & PT_PTRACED))
6588 goto out;
6589
6590 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6591 index c10aa84..9ec2e60 100644
6592 --- a/arch/mips/kernel/smtc-proc.c
6593 +++ b/arch/mips/kernel/smtc-proc.c
6594 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6595
6596 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6597
6598 -atomic_t smtc_fpu_recoveries;
6599 +atomic_unchecked_t smtc_fpu_recoveries;
6600
6601 static int smtc_proc_show(struct seq_file *m, void *v)
6602 {
6603 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6604 for(i = 0; i < NR_CPUS; i++)
6605 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6606 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6607 - atomic_read(&smtc_fpu_recoveries));
6608 + atomic_read_unchecked(&smtc_fpu_recoveries));
6609 return 0;
6610 }
6611
6612 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6613 smtc_cpu_stats[i].selfipis = 0;
6614 }
6615
6616 - atomic_set(&smtc_fpu_recoveries, 0);
6617 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6618
6619 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6620 }
6621 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6622 index dfc1b91..11a2c07 100644
6623 --- a/arch/mips/kernel/smtc.c
6624 +++ b/arch/mips/kernel/smtc.c
6625 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6626 }
6627 smtc_ipi_qdump();
6628 printk("%d Recoveries of \"stolen\" FPU\n",
6629 - atomic_read(&smtc_fpu_recoveries));
6630 + atomic_read_unchecked(&smtc_fpu_recoveries));
6631 }
6632
6633
6634 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6635 index 84536bf..79caa4d 100644
6636 --- a/arch/mips/kernel/sync-r4k.c
6637 +++ b/arch/mips/kernel/sync-r4k.c
6638 @@ -21,8 +21,8 @@
6639 #include <asm/mipsregs.h>
6640
6641 static atomic_t count_start_flag = ATOMIC_INIT(0);
6642 -static atomic_t count_count_start = ATOMIC_INIT(0);
6643 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6644 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6645 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6646 static atomic_t count_reference = ATOMIC_INIT(0);
6647
6648 #define COUNTON 100
6649 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6650
6651 for (i = 0; i < NR_LOOPS; i++) {
6652 /* slaves loop on '!= 2' */
6653 - while (atomic_read(&count_count_start) != 1)
6654 + while (atomic_read_unchecked(&count_count_start) != 1)
6655 mb();
6656 - atomic_set(&count_count_stop, 0);
6657 + atomic_set_unchecked(&count_count_stop, 0);
6658 smp_wmb();
6659
6660 /* this lets the slaves write their count register */
6661 - atomic_inc(&count_count_start);
6662 + atomic_inc_unchecked(&count_count_start);
6663
6664 /*
6665 * Everyone initialises count in the last loop:
6666 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6667 /*
6668 * Wait for all slaves to leave the synchronization point:
6669 */
6670 - while (atomic_read(&count_count_stop) != 1)
6671 + while (atomic_read_unchecked(&count_count_stop) != 1)
6672 mb();
6673 - atomic_set(&count_count_start, 0);
6674 + atomic_set_unchecked(&count_count_start, 0);
6675 smp_wmb();
6676 - atomic_inc(&count_count_stop);
6677 + atomic_inc_unchecked(&count_count_stop);
6678 }
6679 /* Arrange for an interrupt in a short while */
6680 write_c0_compare(read_c0_count() + COUNTON);
6681 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6682 initcount = atomic_read(&count_reference);
6683
6684 for (i = 0; i < NR_LOOPS; i++) {
6685 - atomic_inc(&count_count_start);
6686 - while (atomic_read(&count_count_start) != 2)
6687 + atomic_inc_unchecked(&count_count_start);
6688 + while (atomic_read_unchecked(&count_count_start) != 2)
6689 mb();
6690
6691 /*
6692 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6693 if (i == NR_LOOPS-1)
6694 write_c0_count(initcount);
6695
6696 - atomic_inc(&count_count_stop);
6697 - while (atomic_read(&count_count_stop) != 2)
6698 + atomic_inc_unchecked(&count_count_stop);
6699 + while (atomic_read_unchecked(&count_count_stop) != 2)
6700 mb();
6701 }
6702 /* Arrange for an interrupt in a short while */
6703 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6704 index aec3408..74d79d3 100644
6705 --- a/arch/mips/kernel/traps.c
6706 +++ b/arch/mips/kernel/traps.c
6707 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6708 siginfo_t info;
6709
6710 prev_state = exception_enter();
6711 - die_if_kernel("Integer overflow", regs);
6712 + if (unlikely(!user_mode(regs))) {
6713 +
6714 +#ifdef CONFIG_PAX_REFCOUNT
6715 + if (fixup_exception(regs)) {
6716 + pax_report_refcount_overflow(regs);
6717 + exception_exit(prev_state);
6718 + return;
6719 + }
6720 +#endif
6721 +
6722 + die("Integer overflow", regs);
6723 + }
6724
6725 info.si_code = FPE_INTOVF;
6726 info.si_signo = SIGFPE;
6727 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6728 index 85df1cd..4f0a4de 100644
6729 --- a/arch/mips/mm/fault.c
6730 +++ b/arch/mips/mm/fault.c
6731 @@ -28,6 +28,23 @@
6732 #include <asm/highmem.h> /* For VMALLOC_END */
6733 #include <linux/kdebug.h>
6734
6735 +#ifdef CONFIG_PAX_PAGEEXEC
6736 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6737 +{
6738 + unsigned long i;
6739 +
6740 + printk(KERN_ERR "PAX: bytes at PC: ");
6741 + for (i = 0; i < 5; i++) {
6742 + unsigned int c;
6743 + if (get_user(c, (unsigned int *)pc+i))
6744 + printk(KERN_CONT "???????? ");
6745 + else
6746 + printk(KERN_CONT "%08x ", c);
6747 + }
6748 + printk("\n");
6749 +}
6750 +#endif
6751 +
6752 /*
6753 * This routine handles page faults. It determines the address,
6754 * and the problem, and then passes it off to one of the appropriate
6755 @@ -197,6 +214,14 @@ bad_area:
6756 bad_area_nosemaphore:
6757 /* User mode accesses just cause a SIGSEGV */
6758 if (user_mode(regs)) {
6759 +
6760 +#ifdef CONFIG_PAX_PAGEEXEC
6761 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6762 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6763 + do_group_exit(SIGKILL);
6764 + }
6765 +#endif
6766 +
6767 tsk->thread.cp0_badvaddr = address;
6768 tsk->thread.error_code = write;
6769 #if 0
6770 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6771 index f1baadd..8537544 100644
6772 --- a/arch/mips/mm/mmap.c
6773 +++ b/arch/mips/mm/mmap.c
6774 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6775 struct vm_area_struct *vma;
6776 unsigned long addr = addr0;
6777 int do_color_align;
6778 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6779 struct vm_unmapped_area_info info;
6780
6781 if (unlikely(len > TASK_SIZE))
6782 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6783 do_color_align = 1;
6784
6785 /* requesting a specific address */
6786 +
6787 +#ifdef CONFIG_PAX_RANDMMAP
6788 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6789 +#endif
6790 +
6791 if (addr) {
6792 if (do_color_align)
6793 addr = COLOUR_ALIGN(addr, pgoff);
6794 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6795 addr = PAGE_ALIGN(addr);
6796
6797 vma = find_vma(mm, addr);
6798 - if (TASK_SIZE - len >= addr &&
6799 - (!vma || addr + len <= vma->vm_start))
6800 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6801 return addr;
6802 }
6803
6804 info.length = len;
6805 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6806 info.align_offset = pgoff << PAGE_SHIFT;
6807 + info.threadstack_offset = offset;
6808
6809 if (dir == DOWN) {
6810 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6811 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6812 {
6813 unsigned long random_factor = 0UL;
6814
6815 +#ifdef CONFIG_PAX_RANDMMAP
6816 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6817 +#endif
6818 +
6819 if (current->flags & PF_RANDOMIZE) {
6820 random_factor = get_random_int();
6821 random_factor = random_factor << PAGE_SHIFT;
6822 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6823
6824 if (mmap_is_legacy()) {
6825 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6826 +
6827 +#ifdef CONFIG_PAX_RANDMMAP
6828 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6829 + mm->mmap_base += mm->delta_mmap;
6830 +#endif
6831 +
6832 mm->get_unmapped_area = arch_get_unmapped_area;
6833 } else {
6834 mm->mmap_base = mmap_base(random_factor);
6835 +
6836 +#ifdef CONFIG_PAX_RANDMMAP
6837 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6838 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6839 +#endif
6840 +
6841 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6842 }
6843 }
6844
6845 -static inline unsigned long brk_rnd(void)
6846 -{
6847 - unsigned long rnd = get_random_int();
6848 -
6849 - rnd = rnd << PAGE_SHIFT;
6850 - /* 8MB for 32bit, 256MB for 64bit */
6851 - if (TASK_IS_32BIT_ADDR)
6852 - rnd = rnd & 0x7ffffful;
6853 - else
6854 - rnd = rnd & 0xffffffful;
6855 -
6856 - return rnd;
6857 -}
6858 -
6859 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6860 -{
6861 - unsigned long base = mm->brk;
6862 - unsigned long ret;
6863 -
6864 - ret = PAGE_ALIGN(base + brk_rnd());
6865 -
6866 - if (ret < mm->brk)
6867 - return mm->brk;
6868 -
6869 - return ret;
6870 -}
6871 -
6872 int __virt_addr_valid(const volatile void *kaddr)
6873 {
6874 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6875 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6876 index a2358b4..7cead4f 100644
6877 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6878 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6879 @@ -187,9 +187,9 @@ void
6880 cont_nmi_dump(void)
6881 {
6882 #ifndef REAL_NMI_SIGNAL
6883 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6884 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6885
6886 - atomic_inc(&nmied_cpus);
6887 + atomic_inc_unchecked(&nmied_cpus);
6888 #endif
6889 /*
6890 * Only allow 1 cpu to proceed
6891 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6892 udelay(10000);
6893 }
6894 #else
6895 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6896 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6897 #endif
6898
6899 /*
6900 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6901 index 967d144..db12197 100644
6902 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6903 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6904 @@ -11,12 +11,14 @@
6905 #ifndef _ASM_PROC_CACHE_H
6906 #define _ASM_PROC_CACHE_H
6907
6908 +#include <linux/const.h>
6909 +
6910 /* L1 cache */
6911
6912 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6913 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6914 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6915 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6916 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6917 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6918
6919 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6920 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6921 index bcb5df2..84fabd2 100644
6922 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6923 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6924 @@ -16,13 +16,15 @@
6925 #ifndef _ASM_PROC_CACHE_H
6926 #define _ASM_PROC_CACHE_H
6927
6928 +#include <linux/const.h>
6929 +
6930 /*
6931 * L1 cache
6932 */
6933 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6934 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6935 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6936 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6937 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6938 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6939
6940 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6941 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6942 index 4ce7a01..449202a 100644
6943 --- a/arch/openrisc/include/asm/cache.h
6944 +++ b/arch/openrisc/include/asm/cache.h
6945 @@ -19,11 +19,13 @@
6946 #ifndef __ASM_OPENRISC_CACHE_H
6947 #define __ASM_OPENRISC_CACHE_H
6948
6949 +#include <linux/const.h>
6950 +
6951 /* FIXME: How can we replace these with values from the CPU...
6952 * they shouldn't be hard-coded!
6953 */
6954
6955 -#define L1_CACHE_BYTES 16
6956 #define L1_CACHE_SHIFT 4
6957 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6958
6959 #endif /* __ASM_OPENRISC_CACHE_H */
6960 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6961 index 472886c..00e7df9 100644
6962 --- a/arch/parisc/include/asm/atomic.h
6963 +++ b/arch/parisc/include/asm/atomic.h
6964 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6965 return dec;
6966 }
6967
6968 +#define atomic64_read_unchecked(v) atomic64_read(v)
6969 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6970 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6971 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6972 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6973 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6974 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6975 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6976 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6977 +
6978 #endif /* !CONFIG_64BIT */
6979
6980
6981 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6982 index 47f11c7..3420df2 100644
6983 --- a/arch/parisc/include/asm/cache.h
6984 +++ b/arch/parisc/include/asm/cache.h
6985 @@ -5,6 +5,7 @@
6986 #ifndef __ARCH_PARISC_CACHE_H
6987 #define __ARCH_PARISC_CACHE_H
6988
6989 +#include <linux/const.h>
6990
6991 /*
6992 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6993 @@ -15,13 +16,13 @@
6994 * just ruin performance.
6995 */
6996 #ifdef CONFIG_PA20
6997 -#define L1_CACHE_BYTES 64
6998 #define L1_CACHE_SHIFT 6
6999 #else
7000 -#define L1_CACHE_BYTES 32
7001 #define L1_CACHE_SHIFT 5
7002 #endif
7003
7004 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7005 +
7006 #ifndef __ASSEMBLY__
7007
7008 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7009 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7010 index ad2b503..bdf1651 100644
7011 --- a/arch/parisc/include/asm/elf.h
7012 +++ b/arch/parisc/include/asm/elf.h
7013 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7014
7015 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7016
7017 +#ifdef CONFIG_PAX_ASLR
7018 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7019 +
7020 +#define PAX_DELTA_MMAP_LEN 16
7021 +#define PAX_DELTA_STACK_LEN 16
7022 +#endif
7023 +
7024 /* This yields a mask that user programs can use to figure out what
7025 instruction set this CPU supports. This could be done in user space,
7026 but it's not easy, and we've already done it here. */
7027 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7028 index fc987a1..6e068ef 100644
7029 --- a/arch/parisc/include/asm/pgalloc.h
7030 +++ b/arch/parisc/include/asm/pgalloc.h
7031 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7032 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7033 }
7034
7035 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7036 +{
7037 + pgd_populate(mm, pgd, pmd);
7038 +}
7039 +
7040 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7041 {
7042 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7043 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7044 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7045 #define pmd_free(mm, x) do { } while (0)
7046 #define pgd_populate(mm, pmd, pte) BUG()
7047 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7048
7049 #endif
7050
7051 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7052 index 34899b5..02dd060 100644
7053 --- a/arch/parisc/include/asm/pgtable.h
7054 +++ b/arch/parisc/include/asm/pgtable.h
7055 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7056 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7057 #define PAGE_COPY PAGE_EXECREAD
7058 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7059 +
7060 +#ifdef CONFIG_PAX_PAGEEXEC
7061 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7062 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7063 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7064 +#else
7065 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7066 +# define PAGE_COPY_NOEXEC PAGE_COPY
7067 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7068 +#endif
7069 +
7070 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7071 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7072 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7073 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7074 index e0a8235..ce2f1e1 100644
7075 --- a/arch/parisc/include/asm/uaccess.h
7076 +++ b/arch/parisc/include/asm/uaccess.h
7077 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7078 const void __user *from,
7079 unsigned long n)
7080 {
7081 - int sz = __compiletime_object_size(to);
7082 + size_t sz = __compiletime_object_size(to);
7083 int ret = -EFAULT;
7084
7085 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7086 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7087 ret = __copy_from_user(to, from, n);
7088 else
7089 copy_from_user_overflow();
7090 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7091 index 2a625fb..9908930 100644
7092 --- a/arch/parisc/kernel/module.c
7093 +++ b/arch/parisc/kernel/module.c
7094 @@ -98,16 +98,38 @@
7095
7096 /* three functions to determine where in the module core
7097 * or init pieces the location is */
7098 +static inline int in_init_rx(struct module *me, void *loc)
7099 +{
7100 + return (loc >= me->module_init_rx &&
7101 + loc < (me->module_init_rx + me->init_size_rx));
7102 +}
7103 +
7104 +static inline int in_init_rw(struct module *me, void *loc)
7105 +{
7106 + return (loc >= me->module_init_rw &&
7107 + loc < (me->module_init_rw + me->init_size_rw));
7108 +}
7109 +
7110 static inline int in_init(struct module *me, void *loc)
7111 {
7112 - return (loc >= me->module_init &&
7113 - loc <= (me->module_init + me->init_size));
7114 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7115 +}
7116 +
7117 +static inline int in_core_rx(struct module *me, void *loc)
7118 +{
7119 + return (loc >= me->module_core_rx &&
7120 + loc < (me->module_core_rx + me->core_size_rx));
7121 +}
7122 +
7123 +static inline int in_core_rw(struct module *me, void *loc)
7124 +{
7125 + return (loc >= me->module_core_rw &&
7126 + loc < (me->module_core_rw + me->core_size_rw));
7127 }
7128
7129 static inline int in_core(struct module *me, void *loc)
7130 {
7131 - return (loc >= me->module_core &&
7132 - loc <= (me->module_core + me->core_size));
7133 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7134 }
7135
7136 static inline int in_local(struct module *me, void *loc)
7137 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7138 }
7139
7140 /* align things a bit */
7141 - me->core_size = ALIGN(me->core_size, 16);
7142 - me->arch.got_offset = me->core_size;
7143 - me->core_size += gots * sizeof(struct got_entry);
7144 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7145 + me->arch.got_offset = me->core_size_rw;
7146 + me->core_size_rw += gots * sizeof(struct got_entry);
7147
7148 - me->core_size = ALIGN(me->core_size, 16);
7149 - me->arch.fdesc_offset = me->core_size;
7150 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7151 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7152 + me->arch.fdesc_offset = me->core_size_rw;
7153 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7154
7155 me->arch.got_max = gots;
7156 me->arch.fdesc_max = fdescs;
7157 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7158
7159 BUG_ON(value == 0);
7160
7161 - got = me->module_core + me->arch.got_offset;
7162 + got = me->module_core_rw + me->arch.got_offset;
7163 for (i = 0; got[i].addr; i++)
7164 if (got[i].addr == value)
7165 goto out;
7166 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7167 #ifdef CONFIG_64BIT
7168 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7169 {
7170 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7171 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7172
7173 if (!value) {
7174 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7175 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7176
7177 /* Create new one */
7178 fdesc->addr = value;
7179 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7180 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7181 return (Elf_Addr)fdesc;
7182 }
7183 #endif /* CONFIG_64BIT */
7184 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7185
7186 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7187 end = table + sechdrs[me->arch.unwind_section].sh_size;
7188 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7189 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7190
7191 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7192 me->arch.unwind_section, table, end, gp);
7193 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7194 index 5dfd248..64914ac 100644
7195 --- a/arch/parisc/kernel/sys_parisc.c
7196 +++ b/arch/parisc/kernel/sys_parisc.c
7197 @@ -33,9 +33,11 @@
7198 #include <linux/utsname.h>
7199 #include <linux/personality.h>
7200
7201 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7202 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7203 + unsigned long flags)
7204 {
7205 struct vm_unmapped_area_info info;
7206 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7207
7208 info.flags = 0;
7209 info.length = len;
7210 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7211 info.high_limit = TASK_SIZE;
7212 info.align_mask = 0;
7213 info.align_offset = 0;
7214 + info.threadstack_offset = offset;
7215 return vm_unmapped_area(&info);
7216 }
7217
7218 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7219 return (unsigned long) mapping >> 8;
7220 }
7221
7222 -static unsigned long get_shared_area(struct address_space *mapping,
7223 - unsigned long addr, unsigned long len, unsigned long pgoff)
7224 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7225 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7226 {
7227 struct vm_unmapped_area_info info;
7228 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7229
7230 info.flags = 0;
7231 info.length = len;
7232 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7233 info.high_limit = TASK_SIZE;
7234 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7235 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7236 + info.threadstack_offset = offset;
7237 return vm_unmapped_area(&info);
7238 }
7239
7240 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7241 return -EINVAL;
7242 return addr;
7243 }
7244 - if (!addr)
7245 + if (!addr) {
7246 addr = TASK_UNMAPPED_BASE;
7247
7248 +#ifdef CONFIG_PAX_RANDMMAP
7249 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7250 + addr += current->mm->delta_mmap;
7251 +#endif
7252 +
7253 + }
7254 +
7255 if (filp) {
7256 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7257 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7258 } else if(flags & MAP_SHARED) {
7259 - addr = get_shared_area(NULL, addr, len, pgoff);
7260 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7261 } else {
7262 - addr = get_unshared_area(addr, len);
7263 + addr = get_unshared_area(filp, addr, len, flags);
7264 }
7265 return addr;
7266 }
7267 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7268 index b3f87a3..5d5d03d 100644
7269 --- a/arch/parisc/kernel/traps.c
7270 +++ b/arch/parisc/kernel/traps.c
7271 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7272
7273 down_read(&current->mm->mmap_sem);
7274 vma = find_vma(current->mm,regs->iaoq[0]);
7275 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7276 - && (vma->vm_flags & VM_EXEC)) {
7277 -
7278 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7279 fault_address = regs->iaoq[0];
7280 fault_space = regs->iasq[0];
7281
7282 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7283 index f247a34..dc0f219 100644
7284 --- a/arch/parisc/mm/fault.c
7285 +++ b/arch/parisc/mm/fault.c
7286 @@ -15,6 +15,7 @@
7287 #include <linux/sched.h>
7288 #include <linux/interrupt.h>
7289 #include <linux/module.h>
7290 +#include <linux/unistd.h>
7291
7292 #include <asm/uaccess.h>
7293 #include <asm/traps.h>
7294 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7295 static unsigned long
7296 parisc_acctyp(unsigned long code, unsigned int inst)
7297 {
7298 - if (code == 6 || code == 16)
7299 + if (code == 6 || code == 7 || code == 16)
7300 return VM_EXEC;
7301
7302 switch (inst & 0xf0000000) {
7303 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7304 }
7305 #endif
7306
7307 +#ifdef CONFIG_PAX_PAGEEXEC
7308 +/*
7309 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7310 + *
7311 + * returns 1 when task should be killed
7312 + * 2 when rt_sigreturn trampoline was detected
7313 + * 3 when unpatched PLT trampoline was detected
7314 + */
7315 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7316 +{
7317 +
7318 +#ifdef CONFIG_PAX_EMUPLT
7319 + int err;
7320 +
7321 + do { /* PaX: unpatched PLT emulation */
7322 + unsigned int bl, depwi;
7323 +
7324 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7325 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7326 +
7327 + if (err)
7328 + break;
7329 +
7330 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7331 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7332 +
7333 + err = get_user(ldw, (unsigned int *)addr);
7334 + err |= get_user(bv, (unsigned int *)(addr+4));
7335 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7336 +
7337 + if (err)
7338 + break;
7339 +
7340 + if (ldw == 0x0E801096U &&
7341 + bv == 0xEAC0C000U &&
7342 + ldw2 == 0x0E881095U)
7343 + {
7344 + unsigned int resolver, map;
7345 +
7346 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7347 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7348 + if (err)
7349 + break;
7350 +
7351 + regs->gr[20] = instruction_pointer(regs)+8;
7352 + regs->gr[21] = map;
7353 + regs->gr[22] = resolver;
7354 + regs->iaoq[0] = resolver | 3UL;
7355 + regs->iaoq[1] = regs->iaoq[0] + 4;
7356 + return 3;
7357 + }
7358 + }
7359 + } while (0);
7360 +#endif
7361 +
7362 +#ifdef CONFIG_PAX_EMUTRAMP
7363 +
7364 +#ifndef CONFIG_PAX_EMUSIGRT
7365 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7366 + return 1;
7367 +#endif
7368 +
7369 + do { /* PaX: rt_sigreturn emulation */
7370 + unsigned int ldi1, ldi2, bel, nop;
7371 +
7372 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7373 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7374 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7375 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7376 +
7377 + if (err)
7378 + break;
7379 +
7380 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7381 + ldi2 == 0x3414015AU &&
7382 + bel == 0xE4008200U &&
7383 + nop == 0x08000240U)
7384 + {
7385 + regs->gr[25] = (ldi1 & 2) >> 1;
7386 + regs->gr[20] = __NR_rt_sigreturn;
7387 + regs->gr[31] = regs->iaoq[1] + 16;
7388 + regs->sr[0] = regs->iasq[1];
7389 + regs->iaoq[0] = 0x100UL;
7390 + regs->iaoq[1] = regs->iaoq[0] + 4;
7391 + regs->iasq[0] = regs->sr[2];
7392 + regs->iasq[1] = regs->sr[2];
7393 + return 2;
7394 + }
7395 + } while (0);
7396 +#endif
7397 +
7398 + return 1;
7399 +}
7400 +
7401 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7402 +{
7403 + unsigned long i;
7404 +
7405 + printk(KERN_ERR "PAX: bytes at PC: ");
7406 + for (i = 0; i < 5; i++) {
7407 + unsigned int c;
7408 + if (get_user(c, (unsigned int *)pc+i))
7409 + printk(KERN_CONT "???????? ");
7410 + else
7411 + printk(KERN_CONT "%08x ", c);
7412 + }
7413 + printk("\n");
7414 +}
7415 +#endif
7416 +
7417 int fixup_exception(struct pt_regs *regs)
7418 {
7419 const struct exception_table_entry *fix;
7420 @@ -194,8 +305,33 @@ good_area:
7421
7422 acc_type = parisc_acctyp(code,regs->iir);
7423
7424 - if ((vma->vm_flags & acc_type) != acc_type)
7425 + if ((vma->vm_flags & acc_type) != acc_type) {
7426 +
7427 +#ifdef CONFIG_PAX_PAGEEXEC
7428 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7429 + (address & ~3UL) == instruction_pointer(regs))
7430 + {
7431 + up_read(&mm->mmap_sem);
7432 + switch (pax_handle_fetch_fault(regs)) {
7433 +
7434 +#ifdef CONFIG_PAX_EMUPLT
7435 + case 3:
7436 + return;
7437 +#endif
7438 +
7439 +#ifdef CONFIG_PAX_EMUTRAMP
7440 + case 2:
7441 + return;
7442 +#endif
7443 +
7444 + }
7445 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7446 + do_group_exit(SIGKILL);
7447 + }
7448 +#endif
7449 +
7450 goto bad_area;
7451 + }
7452
7453 /*
7454 * If for any reason at all we couldn't handle the fault, make
7455 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7456 index e3b1d41..8e81edf 100644
7457 --- a/arch/powerpc/include/asm/atomic.h
7458 +++ b/arch/powerpc/include/asm/atomic.h
7459 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7460 return t1;
7461 }
7462
7463 +#define atomic64_read_unchecked(v) atomic64_read(v)
7464 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7465 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7466 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7467 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7468 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7469 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7470 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7471 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7472 +
7473 #endif /* __powerpc64__ */
7474
7475 #endif /* __KERNEL__ */
7476 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7477 index 9e495c9..b6878e5 100644
7478 --- a/arch/powerpc/include/asm/cache.h
7479 +++ b/arch/powerpc/include/asm/cache.h
7480 @@ -3,6 +3,7 @@
7481
7482 #ifdef __KERNEL__
7483
7484 +#include <linux/const.h>
7485
7486 /* bytes per L1 cache line */
7487 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7488 @@ -22,7 +23,7 @@
7489 #define L1_CACHE_SHIFT 7
7490 #endif
7491
7492 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7493 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7494
7495 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7496
7497 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7498 index cc0655a..13eac2e 100644
7499 --- a/arch/powerpc/include/asm/elf.h
7500 +++ b/arch/powerpc/include/asm/elf.h
7501 @@ -28,8 +28,19 @@
7502 the loader. We need to make sure that it is out of the way of the program
7503 that it will "exec", and that there is sufficient room for the brk. */
7504
7505 -extern unsigned long randomize_et_dyn(unsigned long base);
7506 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7507 +#define ELF_ET_DYN_BASE (0x20000000)
7508 +
7509 +#ifdef CONFIG_PAX_ASLR
7510 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7511 +
7512 +#ifdef __powerpc64__
7513 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7514 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7515 +#else
7516 +#define PAX_DELTA_MMAP_LEN 15
7517 +#define PAX_DELTA_STACK_LEN 15
7518 +#endif
7519 +#endif
7520
7521 /*
7522 * Our registers are always unsigned longs, whether we're a 32 bit
7523 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7524 (0x7ff >> (PAGE_SHIFT - 12)) : \
7525 (0x3ffff >> (PAGE_SHIFT - 12)))
7526
7527 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7528 -#define arch_randomize_brk arch_randomize_brk
7529 -
7530 -
7531 #ifdef CONFIG_SPU_BASE
7532 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7533 #define NT_SPU 1
7534 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7535 index 8196e9c..d83a9f3 100644
7536 --- a/arch/powerpc/include/asm/exec.h
7537 +++ b/arch/powerpc/include/asm/exec.h
7538 @@ -4,6 +4,6 @@
7539 #ifndef _ASM_POWERPC_EXEC_H
7540 #define _ASM_POWERPC_EXEC_H
7541
7542 -extern unsigned long arch_align_stack(unsigned long sp);
7543 +#define arch_align_stack(x) ((x) & ~0xfUL)
7544
7545 #endif /* _ASM_POWERPC_EXEC_H */
7546 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7547 index 5acabbd..7ea14fa 100644
7548 --- a/arch/powerpc/include/asm/kmap_types.h
7549 +++ b/arch/powerpc/include/asm/kmap_types.h
7550 @@ -10,7 +10,7 @@
7551 * 2 of the License, or (at your option) any later version.
7552 */
7553
7554 -#define KM_TYPE_NR 16
7555 +#define KM_TYPE_NR 17
7556
7557 #endif /* __KERNEL__ */
7558 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7559 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7560 index 8565c25..2865190 100644
7561 --- a/arch/powerpc/include/asm/mman.h
7562 +++ b/arch/powerpc/include/asm/mman.h
7563 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7564 }
7565 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7566
7567 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7568 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7569 {
7570 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7571 }
7572 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7573 index b9f4262..dcf04f7 100644
7574 --- a/arch/powerpc/include/asm/page.h
7575 +++ b/arch/powerpc/include/asm/page.h
7576 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7577 * and needs to be executable. This means the whole heap ends
7578 * up being executable.
7579 */
7580 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7581 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7582 +#define VM_DATA_DEFAULT_FLAGS32 \
7583 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7584 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7585
7586 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7587 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7588 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7589 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7590 #endif
7591
7592 +#define ktla_ktva(addr) (addr)
7593 +#define ktva_ktla(addr) (addr)
7594 +
7595 #ifndef CONFIG_PPC_BOOK3S_64
7596 /*
7597 * Use the top bit of the higher-level page table entries to indicate whether
7598 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7599 index 88693ce..ac6f9ab 100644
7600 --- a/arch/powerpc/include/asm/page_64.h
7601 +++ b/arch/powerpc/include/asm/page_64.h
7602 @@ -153,15 +153,18 @@ do { \
7603 * stack by default, so in the absence of a PT_GNU_STACK program header
7604 * we turn execute permission off.
7605 */
7606 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7607 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7608 +#define VM_STACK_DEFAULT_FLAGS32 \
7609 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7610 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7611
7612 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7613 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7614
7615 +#ifndef CONFIG_PAX_PAGEEXEC
7616 #define VM_STACK_DEFAULT_FLAGS \
7617 (is_32bit_task() ? \
7618 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7619 +#endif
7620
7621 #include <asm-generic/getorder.h>
7622
7623 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7624 index f65e27b..23ffb5b 100644
7625 --- a/arch/powerpc/include/asm/pgalloc-64.h
7626 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7627 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7628 #ifndef CONFIG_PPC_64K_PAGES
7629
7630 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7631 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7632
7633 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7634 {
7635 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7636 pud_set(pud, (unsigned long)pmd);
7637 }
7638
7639 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7640 +{
7641 + pud_populate(mm, pud, pmd);
7642 +}
7643 +
7644 #define pmd_populate(mm, pmd, pte_page) \
7645 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7646 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7647 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7648 #endif
7649
7650 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7651 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7652
7653 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7654 pte_t *pte)
7655 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7656 index 7d6eacf..14c0240 100644
7657 --- a/arch/powerpc/include/asm/pgtable.h
7658 +++ b/arch/powerpc/include/asm/pgtable.h
7659 @@ -2,6 +2,7 @@
7660 #define _ASM_POWERPC_PGTABLE_H
7661 #ifdef __KERNEL__
7662
7663 +#include <linux/const.h>
7664 #ifndef __ASSEMBLY__
7665 #include <asm/processor.h> /* For TASK_SIZE */
7666 #include <asm/mmu.h>
7667 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7668 index 4aad413..85d86bf 100644
7669 --- a/arch/powerpc/include/asm/pte-hash32.h
7670 +++ b/arch/powerpc/include/asm/pte-hash32.h
7671 @@ -21,6 +21,7 @@
7672 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7673 #define _PAGE_USER 0x004 /* usermode access allowed */
7674 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7675 +#define _PAGE_EXEC _PAGE_GUARDED
7676 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7677 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7678 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7679 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7680 index 99222e2..f629aef 100644
7681 --- a/arch/powerpc/include/asm/reg.h
7682 +++ b/arch/powerpc/include/asm/reg.h
7683 @@ -234,6 +234,7 @@
7684 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7685 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7686 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7687 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7688 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7689 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7690 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7691 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7692 index 48cfc85..891382f 100644
7693 --- a/arch/powerpc/include/asm/smp.h
7694 +++ b/arch/powerpc/include/asm/smp.h
7695 @@ -50,7 +50,7 @@ struct smp_ops_t {
7696 int (*cpu_disable)(void);
7697 void (*cpu_die)(unsigned int nr);
7698 int (*cpu_bootable)(unsigned int nr);
7699 -};
7700 +} __no_const;
7701
7702 extern void smp_send_debugger_break(void);
7703 extern void start_secondary_resume(void);
7704 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7705 index ba7b197..d292e26 100644
7706 --- a/arch/powerpc/include/asm/thread_info.h
7707 +++ b/arch/powerpc/include/asm/thread_info.h
7708 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7709 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7710 TIF_NEED_RESCHED */
7711 #define TIF_32BIT 4 /* 32 bit binary */
7712 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7713 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7714 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7715 #define TIF_SINGLESTEP 8 /* singlestepping active */
7716 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7717 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7718 for stack store? */
7719 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7720 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7721 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7722 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7723
7724 /* as above, but as bit values */
7725 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7726 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7727 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7728 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7729 #define _TIF_NOHZ (1<<TIF_NOHZ)
7730 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7731 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7732 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7733 - _TIF_NOHZ)
7734 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7735
7736 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7737 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7738 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7739 index 9485b43..4718d50 100644
7740 --- a/arch/powerpc/include/asm/uaccess.h
7741 +++ b/arch/powerpc/include/asm/uaccess.h
7742 @@ -318,52 +318,6 @@ do { \
7743 extern unsigned long __copy_tofrom_user(void __user *to,
7744 const void __user *from, unsigned long size);
7745
7746 -#ifndef __powerpc64__
7747 -
7748 -static inline unsigned long copy_from_user(void *to,
7749 - const void __user *from, unsigned long n)
7750 -{
7751 - unsigned long over;
7752 -
7753 - if (access_ok(VERIFY_READ, from, n))
7754 - return __copy_tofrom_user((__force void __user *)to, from, n);
7755 - if ((unsigned long)from < TASK_SIZE) {
7756 - over = (unsigned long)from + n - TASK_SIZE;
7757 - return __copy_tofrom_user((__force void __user *)to, from,
7758 - n - over) + over;
7759 - }
7760 - return n;
7761 -}
7762 -
7763 -static inline unsigned long copy_to_user(void __user *to,
7764 - const void *from, unsigned long n)
7765 -{
7766 - unsigned long over;
7767 -
7768 - if (access_ok(VERIFY_WRITE, to, n))
7769 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7770 - if ((unsigned long)to < TASK_SIZE) {
7771 - over = (unsigned long)to + n - TASK_SIZE;
7772 - return __copy_tofrom_user(to, (__force void __user *)from,
7773 - n - over) + over;
7774 - }
7775 - return n;
7776 -}
7777 -
7778 -#else /* __powerpc64__ */
7779 -
7780 -#define __copy_in_user(to, from, size) \
7781 - __copy_tofrom_user((to), (from), (size))
7782 -
7783 -extern unsigned long copy_from_user(void *to, const void __user *from,
7784 - unsigned long n);
7785 -extern unsigned long copy_to_user(void __user *to, const void *from,
7786 - unsigned long n);
7787 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7788 - unsigned long n);
7789 -
7790 -#endif /* __powerpc64__ */
7791 -
7792 static inline unsigned long __copy_from_user_inatomic(void *to,
7793 const void __user *from, unsigned long n)
7794 {
7795 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7796 if (ret == 0)
7797 return 0;
7798 }
7799 +
7800 + if (!__builtin_constant_p(n))
7801 + check_object_size(to, n, false);
7802 +
7803 return __copy_tofrom_user((__force void __user *)to, from, n);
7804 }
7805
7806 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7807 if (ret == 0)
7808 return 0;
7809 }
7810 +
7811 + if (!__builtin_constant_p(n))
7812 + check_object_size(from, n, true);
7813 +
7814 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7815 }
7816
7817 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7818 return __copy_to_user_inatomic(to, from, size);
7819 }
7820
7821 +#ifndef __powerpc64__
7822 +
7823 +static inline unsigned long __must_check copy_from_user(void *to,
7824 + const void __user *from, unsigned long n)
7825 +{
7826 + unsigned long over;
7827 +
7828 + if ((long)n < 0)
7829 + return n;
7830 +
7831 + if (access_ok(VERIFY_READ, from, n)) {
7832 + if (!__builtin_constant_p(n))
7833 + check_object_size(to, n, false);
7834 + return __copy_tofrom_user((__force void __user *)to, from, n);
7835 + }
7836 + if ((unsigned long)from < TASK_SIZE) {
7837 + over = (unsigned long)from + n - TASK_SIZE;
7838 + if (!__builtin_constant_p(n - over))
7839 + check_object_size(to, n - over, false);
7840 + return __copy_tofrom_user((__force void __user *)to, from,
7841 + n - over) + over;
7842 + }
7843 + return n;
7844 +}
7845 +
7846 +static inline unsigned long __must_check copy_to_user(void __user *to,
7847 + const void *from, unsigned long n)
7848 +{
7849 + unsigned long over;
7850 +
7851 + if ((long)n < 0)
7852 + return n;
7853 +
7854 + if (access_ok(VERIFY_WRITE, to, n)) {
7855 + if (!__builtin_constant_p(n))
7856 + check_object_size(from, n, true);
7857 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7858 + }
7859 + if ((unsigned long)to < TASK_SIZE) {
7860 + over = (unsigned long)to + n - TASK_SIZE;
7861 + if (!__builtin_constant_p(n))
7862 + check_object_size(from, n - over, true);
7863 + return __copy_tofrom_user(to, (__force void __user *)from,
7864 + n - over) + over;
7865 + }
7866 + return n;
7867 +}
7868 +
7869 +#else /* __powerpc64__ */
7870 +
7871 +#define __copy_in_user(to, from, size) \
7872 + __copy_tofrom_user((to), (from), (size))
7873 +
7874 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7875 +{
7876 + if ((long)n < 0 || n > INT_MAX)
7877 + return n;
7878 +
7879 + if (!__builtin_constant_p(n))
7880 + check_object_size(to, n, false);
7881 +
7882 + if (likely(access_ok(VERIFY_READ, from, n)))
7883 + n = __copy_from_user(to, from, n);
7884 + else
7885 + memset(to, 0, n);
7886 + return n;
7887 +}
7888 +
7889 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7890 +{
7891 + if ((long)n < 0 || n > INT_MAX)
7892 + return n;
7893 +
7894 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7895 + if (!__builtin_constant_p(n))
7896 + check_object_size(from, n, true);
7897 + n = __copy_to_user(to, from, n);
7898 + }
7899 + return n;
7900 +}
7901 +
7902 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7903 + unsigned long n);
7904 +
7905 +#endif /* __powerpc64__ */
7906 +
7907 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7908
7909 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7910 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7911 index 645170a..6cf0271 100644
7912 --- a/arch/powerpc/kernel/exceptions-64e.S
7913 +++ b/arch/powerpc/kernel/exceptions-64e.S
7914 @@ -757,6 +757,7 @@ storage_fault_common:
7915 std r14,_DAR(r1)
7916 std r15,_DSISR(r1)
7917 addi r3,r1,STACK_FRAME_OVERHEAD
7918 + bl .save_nvgprs
7919 mr r4,r14
7920 mr r5,r15
7921 ld r14,PACA_EXGEN+EX_R14(r13)
7922 @@ -765,8 +766,7 @@ storage_fault_common:
7923 cmpdi r3,0
7924 bne- 1f
7925 b .ret_from_except_lite
7926 -1: bl .save_nvgprs
7927 - mr r5,r3
7928 +1: mr r5,r3
7929 addi r3,r1,STACK_FRAME_OVERHEAD
7930 ld r4,_DAR(r1)
7931 bl .bad_page_fault
7932 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7933 index 902ca3c..e942155 100644
7934 --- a/arch/powerpc/kernel/exceptions-64s.S
7935 +++ b/arch/powerpc/kernel/exceptions-64s.S
7936 @@ -1357,10 +1357,10 @@ handle_page_fault:
7937 11: ld r4,_DAR(r1)
7938 ld r5,_DSISR(r1)
7939 addi r3,r1,STACK_FRAME_OVERHEAD
7940 + bl .save_nvgprs
7941 bl .do_page_fault
7942 cmpdi r3,0
7943 beq+ 12f
7944 - bl .save_nvgprs
7945 mr r5,r3
7946 addi r3,r1,STACK_FRAME_OVERHEAD
7947 lwz r4,_DAR(r1)
7948 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7949 index 2e3200c..72095ce 100644
7950 --- a/arch/powerpc/kernel/module_32.c
7951 +++ b/arch/powerpc/kernel/module_32.c
7952 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7953 me->arch.core_plt_section = i;
7954 }
7955 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7956 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7957 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7958 return -ENOEXEC;
7959 }
7960
7961 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7962
7963 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7964 /* Init, or core PLT? */
7965 - if (location >= mod->module_core
7966 - && location < mod->module_core + mod->core_size)
7967 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7968 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7969 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7970 - else
7971 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7972 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7973 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7974 + else {
7975 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7976 + return ~0UL;
7977 + }
7978
7979 /* Find this entry, or if that fails, the next avail. entry */
7980 while (entry->jump[0]) {
7981 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7982 index 8083be2..10aa352 100644
7983 --- a/arch/powerpc/kernel/process.c
7984 +++ b/arch/powerpc/kernel/process.c
7985 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7986 * Lookup NIP late so we have the best change of getting the
7987 * above info out without failing
7988 */
7989 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7990 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7991 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7992 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7993 #endif
7994 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
7995 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
7996 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7997 newsp = stack[0];
7998 ip = stack[STACK_FRAME_LR_SAVE];
7999 if (!firstframe || ip != lr) {
8000 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8001 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8002 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8003 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8004 - printk(" (%pS)",
8005 + printk(" (%pA)",
8006 (void *)current->ret_stack[curr_frame].ret);
8007 curr_frame--;
8008 }
8009 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8010 struct pt_regs *regs = (struct pt_regs *)
8011 (sp + STACK_FRAME_OVERHEAD);
8012 lr = regs->link;
8013 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8014 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8015 regs->trap, (void *)regs->nip, (void *)lr);
8016 firstframe = 1;
8017 }
8018 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8019 mtspr(SPRN_CTRLT, ctrl);
8020 }
8021 #endif /* CONFIG_PPC64 */
8022 -
8023 -unsigned long arch_align_stack(unsigned long sp)
8024 -{
8025 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8026 - sp -= get_random_int() & ~PAGE_MASK;
8027 - return sp & ~0xf;
8028 -}
8029 -
8030 -static inline unsigned long brk_rnd(void)
8031 -{
8032 - unsigned long rnd = 0;
8033 -
8034 - /* 8MB for 32bit, 1GB for 64bit */
8035 - if (is_32bit_task())
8036 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8037 - else
8038 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8039 -
8040 - return rnd << PAGE_SHIFT;
8041 -}
8042 -
8043 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8044 -{
8045 - unsigned long base = mm->brk;
8046 - unsigned long ret;
8047 -
8048 -#ifdef CONFIG_PPC_STD_MMU_64
8049 - /*
8050 - * If we are using 1TB segments and we are allowed to randomise
8051 - * the heap, we can put it above 1TB so it is backed by a 1TB
8052 - * segment. Otherwise the heap will be in the bottom 1TB
8053 - * which always uses 256MB segments and this may result in a
8054 - * performance penalty.
8055 - */
8056 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8057 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8058 -#endif
8059 -
8060 - ret = PAGE_ALIGN(base + brk_rnd());
8061 -
8062 - if (ret < mm->brk)
8063 - return mm->brk;
8064 -
8065 - return ret;
8066 -}
8067 -
8068 -unsigned long randomize_et_dyn(unsigned long base)
8069 -{
8070 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8071 -
8072 - if (ret < base)
8073 - return base;
8074 -
8075 - return ret;
8076 -}
8077 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8078 index 9a0d24c..e7fbedf 100644
8079 --- a/arch/powerpc/kernel/ptrace.c
8080 +++ b/arch/powerpc/kernel/ptrace.c
8081 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8082 return ret;
8083 }
8084
8085 +#ifdef CONFIG_GRKERNSEC_SETXID
8086 +extern void gr_delayed_cred_worker(void);
8087 +#endif
8088 +
8089 /*
8090 * We must return the syscall number to actually look up in the table.
8091 * This can be -1L to skip running any syscall at all.
8092 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8093
8094 secure_computing_strict(regs->gpr[0]);
8095
8096 +#ifdef CONFIG_GRKERNSEC_SETXID
8097 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8098 + gr_delayed_cred_worker();
8099 +#endif
8100 +
8101 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8102 tracehook_report_syscall_entry(regs))
8103 /*
8104 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8105 {
8106 int step;
8107
8108 +#ifdef CONFIG_GRKERNSEC_SETXID
8109 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8110 + gr_delayed_cred_worker();
8111 +#endif
8112 +
8113 audit_syscall_exit(regs);
8114
8115 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8116 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8117 index 0f83122..c0aca6a 100644
8118 --- a/arch/powerpc/kernel/signal_32.c
8119 +++ b/arch/powerpc/kernel/signal_32.c
8120 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8121 /* Save user registers on the stack */
8122 frame = &rt_sf->uc.uc_mcontext;
8123 addr = frame;
8124 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8125 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8126 sigret = 0;
8127 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8128 } else {
8129 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8130 index 887e99d..310bc11 100644
8131 --- a/arch/powerpc/kernel/signal_64.c
8132 +++ b/arch/powerpc/kernel/signal_64.c
8133 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8134 #endif
8135
8136 /* Set up to return from userspace. */
8137 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8138 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8139 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8140 } else {
8141 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8142 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8143 index e435bc0..41c2964 100644
8144 --- a/arch/powerpc/kernel/traps.c
8145 +++ b/arch/powerpc/kernel/traps.c
8146 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8147 return flags;
8148 }
8149
8150 +extern void gr_handle_kernel_exploit(void);
8151 +
8152 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8153 int signr)
8154 {
8155 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8156 panic("Fatal exception in interrupt");
8157 if (panic_on_oops)
8158 panic("Fatal exception");
8159 +
8160 + gr_handle_kernel_exploit();
8161 +
8162 do_exit(signr);
8163 }
8164
8165 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8166 index 1d9c926..25f4741 100644
8167 --- a/arch/powerpc/kernel/vdso.c
8168 +++ b/arch/powerpc/kernel/vdso.c
8169 @@ -34,6 +34,7 @@
8170 #include <asm/firmware.h>
8171 #include <asm/vdso.h>
8172 #include <asm/vdso_datapage.h>
8173 +#include <asm/mman.h>
8174
8175 #include "setup.h"
8176
8177 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8178 vdso_base = VDSO32_MBASE;
8179 #endif
8180
8181 - current->mm->context.vdso_base = 0;
8182 + current->mm->context.vdso_base = ~0UL;
8183
8184 /* vDSO has a problem and was disabled, just don't "enable" it for the
8185 * process
8186 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8187 vdso_base = get_unmapped_area(NULL, vdso_base,
8188 (vdso_pages << PAGE_SHIFT) +
8189 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8190 - 0, 0);
8191 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8192 if (IS_ERR_VALUE(vdso_base)) {
8193 rc = vdso_base;
8194 goto fail_mmapsem;
8195 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8196 index 5eea6f3..5d10396 100644
8197 --- a/arch/powerpc/lib/usercopy_64.c
8198 +++ b/arch/powerpc/lib/usercopy_64.c
8199 @@ -9,22 +9,6 @@
8200 #include <linux/module.h>
8201 #include <asm/uaccess.h>
8202
8203 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8204 -{
8205 - if (likely(access_ok(VERIFY_READ, from, n)))
8206 - n = __copy_from_user(to, from, n);
8207 - else
8208 - memset(to, 0, n);
8209 - return n;
8210 -}
8211 -
8212 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8213 -{
8214 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8215 - n = __copy_to_user(to, from, n);
8216 - return n;
8217 -}
8218 -
8219 unsigned long copy_in_user(void __user *to, const void __user *from,
8220 unsigned long n)
8221 {
8222 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8223 return n;
8224 }
8225
8226 -EXPORT_SYMBOL(copy_from_user);
8227 -EXPORT_SYMBOL(copy_to_user);
8228 EXPORT_SYMBOL(copy_in_user);
8229
8230 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8231 index 8726779..a33c512 100644
8232 --- a/arch/powerpc/mm/fault.c
8233 +++ b/arch/powerpc/mm/fault.c
8234 @@ -33,6 +33,10 @@
8235 #include <linux/magic.h>
8236 #include <linux/ratelimit.h>
8237 #include <linux/context_tracking.h>
8238 +#include <linux/slab.h>
8239 +#include <linux/pagemap.h>
8240 +#include <linux/compiler.h>
8241 +#include <linux/unistd.h>
8242
8243 #include <asm/firmware.h>
8244 #include <asm/page.h>
8245 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8246 }
8247 #endif
8248
8249 +#ifdef CONFIG_PAX_PAGEEXEC
8250 +/*
8251 + * PaX: decide what to do with offenders (regs->nip = fault address)
8252 + *
8253 + * returns 1 when task should be killed
8254 + */
8255 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8256 +{
8257 + return 1;
8258 +}
8259 +
8260 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8261 +{
8262 + unsigned long i;
8263 +
8264 + printk(KERN_ERR "PAX: bytes at PC: ");
8265 + for (i = 0; i < 5; i++) {
8266 + unsigned int c;
8267 + if (get_user(c, (unsigned int __user *)pc+i))
8268 + printk(KERN_CONT "???????? ");
8269 + else
8270 + printk(KERN_CONT "%08x ", c);
8271 + }
8272 + printk("\n");
8273 +}
8274 +#endif
8275 +
8276 /*
8277 * Check whether the instruction at regs->nip is a store using
8278 * an update addressing form which will update r1.
8279 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8280 * indicate errors in DSISR but can validly be set in SRR1.
8281 */
8282 if (trap == 0x400)
8283 - error_code &= 0x48200000;
8284 + error_code &= 0x58200000;
8285 else
8286 is_write = error_code & DSISR_ISSTORE;
8287 #else
8288 @@ -371,7 +402,7 @@ good_area:
8289 * "undefined". Of those that can be set, this is the only
8290 * one which seems bad.
8291 */
8292 - if (error_code & 0x10000000)
8293 + if (error_code & DSISR_GUARDED)
8294 /* Guarded storage error. */
8295 goto bad_area;
8296 #endif /* CONFIG_8xx */
8297 @@ -386,7 +417,7 @@ good_area:
8298 * processors use the same I/D cache coherency mechanism
8299 * as embedded.
8300 */
8301 - if (error_code & DSISR_PROTFAULT)
8302 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8303 goto bad_area;
8304 #endif /* CONFIG_PPC_STD_MMU */
8305
8306 @@ -471,6 +502,23 @@ bad_area:
8307 bad_area_nosemaphore:
8308 /* User mode accesses cause a SIGSEGV */
8309 if (user_mode(regs)) {
8310 +
8311 +#ifdef CONFIG_PAX_PAGEEXEC
8312 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8313 +#ifdef CONFIG_PPC_STD_MMU
8314 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8315 +#else
8316 + if (is_exec && regs->nip == address) {
8317 +#endif
8318 + switch (pax_handle_fetch_fault(regs)) {
8319 + }
8320 +
8321 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8322 + do_group_exit(SIGKILL);
8323 + }
8324 + }
8325 +#endif
8326 +
8327 _exception(SIGSEGV, regs, code, address);
8328 goto bail;
8329 }
8330 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8331 index cb8bdbe..d770680 100644
8332 --- a/arch/powerpc/mm/mmap.c
8333 +++ b/arch/powerpc/mm/mmap.c
8334 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8335 {
8336 unsigned long rnd = 0;
8337
8338 +#ifdef CONFIG_PAX_RANDMMAP
8339 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8340 +#endif
8341 +
8342 if (current->flags & PF_RANDOMIZE) {
8343 /* 8MB for 32bit, 1GB for 64bit */
8344 if (is_32bit_task())
8345 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8346 */
8347 if (mmap_is_legacy()) {
8348 mm->mmap_base = TASK_UNMAPPED_BASE;
8349 +
8350 +#ifdef CONFIG_PAX_RANDMMAP
8351 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8352 + mm->mmap_base += mm->delta_mmap;
8353 +#endif
8354 +
8355 mm->get_unmapped_area = arch_get_unmapped_area;
8356 } else {
8357 mm->mmap_base = mmap_base();
8358 +
8359 +#ifdef CONFIG_PAX_RANDMMAP
8360 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8361 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8362 +#endif
8363 +
8364 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8365 }
8366 }
8367 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8368 index 3e99c14..f00953c 100644
8369 --- a/arch/powerpc/mm/slice.c
8370 +++ b/arch/powerpc/mm/slice.c
8371 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8372 if ((mm->task_size - len) < addr)
8373 return 0;
8374 vma = find_vma(mm, addr);
8375 - return (!vma || (addr + len) <= vma->vm_start);
8376 + return check_heap_stack_gap(vma, addr, len, 0);
8377 }
8378
8379 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8380 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8381 info.align_offset = 0;
8382
8383 addr = TASK_UNMAPPED_BASE;
8384 +
8385 +#ifdef CONFIG_PAX_RANDMMAP
8386 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8387 + addr += mm->delta_mmap;
8388 +#endif
8389 +
8390 while (addr < TASK_SIZE) {
8391 info.low_limit = addr;
8392 if (!slice_scan_available(addr, available, 1, &addr))
8393 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8394 if (fixed && addr > (mm->task_size - len))
8395 return -EINVAL;
8396
8397 +#ifdef CONFIG_PAX_RANDMMAP
8398 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8399 + addr = 0;
8400 +#endif
8401 +
8402 /* If hint, make sure it matches our alignment restrictions */
8403 if (!fixed && addr) {
8404 addr = _ALIGN_UP(addr, 1ul << pshift);
8405 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8406 index 9098692..3d54cd1 100644
8407 --- a/arch/powerpc/platforms/cell/spufs/file.c
8408 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8409 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8410 return VM_FAULT_NOPAGE;
8411 }
8412
8413 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8414 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8415 unsigned long address,
8416 - void *buf, int len, int write)
8417 + void *buf, size_t len, int write)
8418 {
8419 struct spu_context *ctx = vma->vm_file->private_data;
8420 unsigned long offset = address - vma->vm_start;
8421 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8422 index c797832..ce575c8 100644
8423 --- a/arch/s390/include/asm/atomic.h
8424 +++ b/arch/s390/include/asm/atomic.h
8425 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8426 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8427 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8428
8429 +#define atomic64_read_unchecked(v) atomic64_read(v)
8430 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8431 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8432 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8433 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8434 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8435 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8436 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8437 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8438 +
8439 #define smp_mb__before_atomic_dec() smp_mb()
8440 #define smp_mb__after_atomic_dec() smp_mb()
8441 #define smp_mb__before_atomic_inc() smp_mb()
8442 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8443 index 4d7ccac..d03d0ad 100644
8444 --- a/arch/s390/include/asm/cache.h
8445 +++ b/arch/s390/include/asm/cache.h
8446 @@ -9,8 +9,10 @@
8447 #ifndef __ARCH_S390_CACHE_H
8448 #define __ARCH_S390_CACHE_H
8449
8450 -#define L1_CACHE_BYTES 256
8451 +#include <linux/const.h>
8452 +
8453 #define L1_CACHE_SHIFT 8
8454 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8455 #define NET_SKB_PAD 32
8456
8457 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8458 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8459 index 78f4f87..598ce39 100644
8460 --- a/arch/s390/include/asm/elf.h
8461 +++ b/arch/s390/include/asm/elf.h
8462 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8463 the loader. We need to make sure that it is out of the way of the program
8464 that it will "exec", and that there is sufficient room for the brk. */
8465
8466 -extern unsigned long randomize_et_dyn(unsigned long base);
8467 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8468 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8469 +
8470 +#ifdef CONFIG_PAX_ASLR
8471 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8472 +
8473 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8474 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8475 +#endif
8476
8477 /* This yields a mask that user programs can use to figure out what
8478 instruction set this CPU supports. */
8479 @@ -222,9 +228,6 @@ struct linux_binprm;
8480 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8481 int arch_setup_additional_pages(struct linux_binprm *, int);
8482
8483 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8484 -#define arch_randomize_brk arch_randomize_brk
8485 -
8486 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8487
8488 #endif
8489 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8490 index c4a93d6..4d2a9b4 100644
8491 --- a/arch/s390/include/asm/exec.h
8492 +++ b/arch/s390/include/asm/exec.h
8493 @@ -7,6 +7,6 @@
8494 #ifndef __ASM_EXEC_H
8495 #define __ASM_EXEC_H
8496
8497 -extern unsigned long arch_align_stack(unsigned long sp);
8498 +#define arch_align_stack(x) ((x) & ~0xfUL)
8499
8500 #endif /* __ASM_EXEC_H */
8501 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8502 index 9c33ed4..e40cbef 100644
8503 --- a/arch/s390/include/asm/uaccess.h
8504 +++ b/arch/s390/include/asm/uaccess.h
8505 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8506 copy_to_user(void __user *to, const void *from, unsigned long n)
8507 {
8508 might_fault();
8509 +
8510 + if ((long)n < 0)
8511 + return n;
8512 +
8513 return __copy_to_user(to, from, n);
8514 }
8515
8516 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8517 static inline unsigned long __must_check
8518 __copy_from_user(void *to, const void __user *from, unsigned long n)
8519 {
8520 + if ((long)n < 0)
8521 + return n;
8522 +
8523 if (__builtin_constant_p(n) && (n <= 256))
8524 return uaccess.copy_from_user_small(n, from, to);
8525 else
8526 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8527 static inline unsigned long __must_check
8528 copy_from_user(void *to, const void __user *from, unsigned long n)
8529 {
8530 - unsigned int sz = __compiletime_object_size(to);
8531 + size_t sz = __compiletime_object_size(to);
8532
8533 might_fault();
8534 - if (unlikely(sz != -1 && sz < n)) {
8535 +
8536 + if ((long)n < 0)
8537 + return n;
8538 +
8539 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8540 copy_from_user_overflow();
8541 return n;
8542 }
8543 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8544 index 7845e15..59c4353 100644
8545 --- a/arch/s390/kernel/module.c
8546 +++ b/arch/s390/kernel/module.c
8547 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8548
8549 /* Increase core size by size of got & plt and set start
8550 offsets for got and plt. */
8551 - me->core_size = ALIGN(me->core_size, 4);
8552 - me->arch.got_offset = me->core_size;
8553 - me->core_size += me->arch.got_size;
8554 - me->arch.plt_offset = me->core_size;
8555 - me->core_size += me->arch.plt_size;
8556 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8557 + me->arch.got_offset = me->core_size_rw;
8558 + me->core_size_rw += me->arch.got_size;
8559 + me->arch.plt_offset = me->core_size_rx;
8560 + me->core_size_rx += me->arch.plt_size;
8561 return 0;
8562 }
8563
8564 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8565 if (info->got_initialized == 0) {
8566 Elf_Addr *gotent;
8567
8568 - gotent = me->module_core + me->arch.got_offset +
8569 + gotent = me->module_core_rw + me->arch.got_offset +
8570 info->got_offset;
8571 *gotent = val;
8572 info->got_initialized = 1;
8573 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8574 rc = apply_rela_bits(loc, val, 0, 64, 0);
8575 else if (r_type == R_390_GOTENT ||
8576 r_type == R_390_GOTPLTENT) {
8577 - val += (Elf_Addr) me->module_core - loc;
8578 + val += (Elf_Addr) me->module_core_rw - loc;
8579 rc = apply_rela_bits(loc, val, 1, 32, 1);
8580 }
8581 break;
8582 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8583 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8584 if (info->plt_initialized == 0) {
8585 unsigned int *ip;
8586 - ip = me->module_core + me->arch.plt_offset +
8587 + ip = me->module_core_rx + me->arch.plt_offset +
8588 info->plt_offset;
8589 #ifndef CONFIG_64BIT
8590 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8591 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8592 val - loc + 0xffffUL < 0x1ffffeUL) ||
8593 (r_type == R_390_PLT32DBL &&
8594 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8595 - val = (Elf_Addr) me->module_core +
8596 + val = (Elf_Addr) me->module_core_rx +
8597 me->arch.plt_offset +
8598 info->plt_offset;
8599 val += rela->r_addend - loc;
8600 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8601 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8602 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8603 val = val + rela->r_addend -
8604 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8605 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8606 if (r_type == R_390_GOTOFF16)
8607 rc = apply_rela_bits(loc, val, 0, 16, 0);
8608 else if (r_type == R_390_GOTOFF32)
8609 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8610 break;
8611 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8612 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8613 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8614 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8615 rela->r_addend - loc;
8616 if (r_type == R_390_GOTPC)
8617 rc = apply_rela_bits(loc, val, 1, 32, 0);
8618 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8619 index 2bc3edd..ab9d598 100644
8620 --- a/arch/s390/kernel/process.c
8621 +++ b/arch/s390/kernel/process.c
8622 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8623 }
8624 return 0;
8625 }
8626 -
8627 -unsigned long arch_align_stack(unsigned long sp)
8628 -{
8629 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8630 - sp -= get_random_int() & ~PAGE_MASK;
8631 - return sp & ~0xf;
8632 -}
8633 -
8634 -static inline unsigned long brk_rnd(void)
8635 -{
8636 - /* 8MB for 32bit, 1GB for 64bit */
8637 - if (is_32bit_task())
8638 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8639 - else
8640 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8641 -}
8642 -
8643 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8644 -{
8645 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8646 -
8647 - if (ret < mm->brk)
8648 - return mm->brk;
8649 - return ret;
8650 -}
8651 -
8652 -unsigned long randomize_et_dyn(unsigned long base)
8653 -{
8654 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8655 -
8656 - if (!(current->flags & PF_RANDOMIZE))
8657 - return base;
8658 - if (ret < base)
8659 - return base;
8660 - return ret;
8661 -}
8662 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8663 index 4002329..99b67cb 100644
8664 --- a/arch/s390/mm/mmap.c
8665 +++ b/arch/s390/mm/mmap.c
8666 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8667 */
8668 if (mmap_is_legacy()) {
8669 mm->mmap_base = TASK_UNMAPPED_BASE;
8670 +
8671 +#ifdef CONFIG_PAX_RANDMMAP
8672 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8673 + mm->mmap_base += mm->delta_mmap;
8674 +#endif
8675 +
8676 mm->get_unmapped_area = arch_get_unmapped_area;
8677 } else {
8678 mm->mmap_base = mmap_base();
8679 +
8680 +#ifdef CONFIG_PAX_RANDMMAP
8681 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8682 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8683 +#endif
8684 +
8685 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8686 }
8687 }
8688 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8689 */
8690 if (mmap_is_legacy()) {
8691 mm->mmap_base = TASK_UNMAPPED_BASE;
8692 +
8693 +#ifdef CONFIG_PAX_RANDMMAP
8694 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8695 + mm->mmap_base += mm->delta_mmap;
8696 +#endif
8697 +
8698 mm->get_unmapped_area = s390_get_unmapped_area;
8699 } else {
8700 mm->mmap_base = mmap_base();
8701 +
8702 +#ifdef CONFIG_PAX_RANDMMAP
8703 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8704 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8705 +#endif
8706 +
8707 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8708 }
8709 }
8710 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8711 index ae3d59f..f65f075 100644
8712 --- a/arch/score/include/asm/cache.h
8713 +++ b/arch/score/include/asm/cache.h
8714 @@ -1,7 +1,9 @@
8715 #ifndef _ASM_SCORE_CACHE_H
8716 #define _ASM_SCORE_CACHE_H
8717
8718 +#include <linux/const.h>
8719 +
8720 #define L1_CACHE_SHIFT 4
8721 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8722 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8723
8724 #endif /* _ASM_SCORE_CACHE_H */
8725 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8726 index f9f3cd5..58ff438 100644
8727 --- a/arch/score/include/asm/exec.h
8728 +++ b/arch/score/include/asm/exec.h
8729 @@ -1,6 +1,6 @@
8730 #ifndef _ASM_SCORE_EXEC_H
8731 #define _ASM_SCORE_EXEC_H
8732
8733 -extern unsigned long arch_align_stack(unsigned long sp);
8734 +#define arch_align_stack(x) (x)
8735
8736 #endif /* _ASM_SCORE_EXEC_H */
8737 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8738 index f4c6d02..e9355c3 100644
8739 --- a/arch/score/kernel/process.c
8740 +++ b/arch/score/kernel/process.c
8741 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8742
8743 return task_pt_regs(task)->cp0_epc;
8744 }
8745 -
8746 -unsigned long arch_align_stack(unsigned long sp)
8747 -{
8748 - return sp;
8749 -}
8750 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8751 index ef9e555..331bd29 100644
8752 --- a/arch/sh/include/asm/cache.h
8753 +++ b/arch/sh/include/asm/cache.h
8754 @@ -9,10 +9,11 @@
8755 #define __ASM_SH_CACHE_H
8756 #ifdef __KERNEL__
8757
8758 +#include <linux/const.h>
8759 #include <linux/init.h>
8760 #include <cpu/cache.h>
8761
8762 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8763 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8764
8765 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8766
8767 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8768 index 6777177..cb5e44f 100644
8769 --- a/arch/sh/mm/mmap.c
8770 +++ b/arch/sh/mm/mmap.c
8771 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8772 struct mm_struct *mm = current->mm;
8773 struct vm_area_struct *vma;
8774 int do_colour_align;
8775 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8776 struct vm_unmapped_area_info info;
8777
8778 if (flags & MAP_FIXED) {
8779 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8780 if (filp || (flags & MAP_SHARED))
8781 do_colour_align = 1;
8782
8783 +#ifdef CONFIG_PAX_RANDMMAP
8784 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8785 +#endif
8786 +
8787 if (addr) {
8788 if (do_colour_align)
8789 addr = COLOUR_ALIGN(addr, pgoff);
8790 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8791 addr = PAGE_ALIGN(addr);
8792
8793 vma = find_vma(mm, addr);
8794 - if (TASK_SIZE - len >= addr &&
8795 - (!vma || addr + len <= vma->vm_start))
8796 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8797 return addr;
8798 }
8799
8800 info.flags = 0;
8801 info.length = len;
8802 - info.low_limit = TASK_UNMAPPED_BASE;
8803 + info.low_limit = mm->mmap_base;
8804 info.high_limit = TASK_SIZE;
8805 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8806 info.align_offset = pgoff << PAGE_SHIFT;
8807 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8808 struct mm_struct *mm = current->mm;
8809 unsigned long addr = addr0;
8810 int do_colour_align;
8811 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8812 struct vm_unmapped_area_info info;
8813
8814 if (flags & MAP_FIXED) {
8815 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8816 if (filp || (flags & MAP_SHARED))
8817 do_colour_align = 1;
8818
8819 +#ifdef CONFIG_PAX_RANDMMAP
8820 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8821 +#endif
8822 +
8823 /* requesting a specific address */
8824 if (addr) {
8825 if (do_colour_align)
8826 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8827 addr = PAGE_ALIGN(addr);
8828
8829 vma = find_vma(mm, addr);
8830 - if (TASK_SIZE - len >= addr &&
8831 - (!vma || addr + len <= vma->vm_start))
8832 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8833 return addr;
8834 }
8835
8836 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8837 VM_BUG_ON(addr != -ENOMEM);
8838 info.flags = 0;
8839 info.low_limit = TASK_UNMAPPED_BASE;
8840 +
8841 +#ifdef CONFIG_PAX_RANDMMAP
8842 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8843 + info.low_limit += mm->delta_mmap;
8844 +#endif
8845 +
8846 info.high_limit = TASK_SIZE;
8847 addr = vm_unmapped_area(&info);
8848 }
8849 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8850 index be56a24..443328f 100644
8851 --- a/arch/sparc/include/asm/atomic_64.h
8852 +++ b/arch/sparc/include/asm/atomic_64.h
8853 @@ -14,18 +14,40 @@
8854 #define ATOMIC64_INIT(i) { (i) }
8855
8856 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8857 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8858 +{
8859 + return v->counter;
8860 +}
8861 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8862 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8863 +{
8864 + return v->counter;
8865 +}
8866
8867 #define atomic_set(v, i) (((v)->counter) = i)
8868 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8869 +{
8870 + v->counter = i;
8871 +}
8872 #define atomic64_set(v, i) (((v)->counter) = i)
8873 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8874 +{
8875 + v->counter = i;
8876 +}
8877
8878 extern void atomic_add(int, atomic_t *);
8879 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8880 extern void atomic64_add(long, atomic64_t *);
8881 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8882 extern void atomic_sub(int, atomic_t *);
8883 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8884 extern void atomic64_sub(long, atomic64_t *);
8885 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8886
8887 extern int atomic_add_ret(int, atomic_t *);
8888 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8889 extern long atomic64_add_ret(long, atomic64_t *);
8890 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8891 extern int atomic_sub_ret(int, atomic_t *);
8892 extern long atomic64_sub_ret(long, atomic64_t *);
8893
8894 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8895 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8896
8897 #define atomic_inc_return(v) atomic_add_ret(1, v)
8898 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8899 +{
8900 + return atomic_add_ret_unchecked(1, v);
8901 +}
8902 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8903 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8904 +{
8905 + return atomic64_add_ret_unchecked(1, v);
8906 +}
8907
8908 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8909 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8910
8911 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8912 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8913 +{
8914 + return atomic_add_ret_unchecked(i, v);
8915 +}
8916 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8917 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8918 +{
8919 + return atomic64_add_ret_unchecked(i, v);
8920 +}
8921
8922 /*
8923 * atomic_inc_and_test - increment and test
8924 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8925 * other cases.
8926 */
8927 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8928 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8929 +{
8930 + return atomic_inc_return_unchecked(v) == 0;
8931 +}
8932 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8933
8934 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8935 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8936 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8937
8938 #define atomic_inc(v) atomic_add(1, v)
8939 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8940 +{
8941 + atomic_add_unchecked(1, v);
8942 +}
8943 #define atomic64_inc(v) atomic64_add(1, v)
8944 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8945 +{
8946 + atomic64_add_unchecked(1, v);
8947 +}
8948
8949 #define atomic_dec(v) atomic_sub(1, v)
8950 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8951 +{
8952 + atomic_sub_unchecked(1, v);
8953 +}
8954 #define atomic64_dec(v) atomic64_sub(1, v)
8955 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8956 +{
8957 + atomic64_sub_unchecked(1, v);
8958 +}
8959
8960 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8961 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8962
8963 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8964 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8965 +{
8966 + return cmpxchg(&v->counter, old, new);
8967 +}
8968 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8969 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8970 +{
8971 + return xchg(&v->counter, new);
8972 +}
8973
8974 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8975 {
8976 - int c, old;
8977 + int c, old, new;
8978 c = atomic_read(v);
8979 for (;;) {
8980 - if (unlikely(c == (u)))
8981 + if (unlikely(c == u))
8982 break;
8983 - old = atomic_cmpxchg((v), c, c + (a));
8984 +
8985 + asm volatile("addcc %2, %0, %0\n"
8986 +
8987 +#ifdef CONFIG_PAX_REFCOUNT
8988 + "tvs %%icc, 6\n"
8989 +#endif
8990 +
8991 + : "=r" (new)
8992 + : "0" (c), "ir" (a)
8993 + : "cc");
8994 +
8995 + old = atomic_cmpxchg(v, c, new);
8996 if (likely(old == c))
8997 break;
8998 c = old;
8999 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9000 #define atomic64_cmpxchg(v, o, n) \
9001 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9002 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9003 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9004 +{
9005 + return xchg(&v->counter, new);
9006 +}
9007
9008 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9009 {
9010 - long c, old;
9011 + long c, old, new;
9012 c = atomic64_read(v);
9013 for (;;) {
9014 - if (unlikely(c == (u)))
9015 + if (unlikely(c == u))
9016 break;
9017 - old = atomic64_cmpxchg((v), c, c + (a));
9018 +
9019 + asm volatile("addcc %2, %0, %0\n"
9020 +
9021 +#ifdef CONFIG_PAX_REFCOUNT
9022 + "tvs %%xcc, 6\n"
9023 +#endif
9024 +
9025 + : "=r" (new)
9026 + : "0" (c), "ir" (a)
9027 + : "cc");
9028 +
9029 + old = atomic64_cmpxchg(v, c, new);
9030 if (likely(old == c))
9031 break;
9032 c = old;
9033 }
9034 - return c != (u);
9035 + return c != u;
9036 }
9037
9038 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9039 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9040 index 5bb6991..5c2132e 100644
9041 --- a/arch/sparc/include/asm/cache.h
9042 +++ b/arch/sparc/include/asm/cache.h
9043 @@ -7,10 +7,12 @@
9044 #ifndef _SPARC_CACHE_H
9045 #define _SPARC_CACHE_H
9046
9047 +#include <linux/const.h>
9048 +
9049 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9050
9051 #define L1_CACHE_SHIFT 5
9052 -#define L1_CACHE_BYTES 32
9053 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9054
9055 #ifdef CONFIG_SPARC32
9056 #define SMP_CACHE_BYTES_SHIFT 5
9057 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9058 index a24e41f..47677ff 100644
9059 --- a/arch/sparc/include/asm/elf_32.h
9060 +++ b/arch/sparc/include/asm/elf_32.h
9061 @@ -114,6 +114,13 @@ typedef struct {
9062
9063 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9064
9065 +#ifdef CONFIG_PAX_ASLR
9066 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9067 +
9068 +#define PAX_DELTA_MMAP_LEN 16
9069 +#define PAX_DELTA_STACK_LEN 16
9070 +#endif
9071 +
9072 /* This yields a mask that user programs can use to figure out what
9073 instruction set this cpu supports. This can NOT be done in userspace
9074 on Sparc. */
9075 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9076 index 370ca1e..d4f4a98 100644
9077 --- a/arch/sparc/include/asm/elf_64.h
9078 +++ b/arch/sparc/include/asm/elf_64.h
9079 @@ -189,6 +189,13 @@ typedef struct {
9080 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9081 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9082
9083 +#ifdef CONFIG_PAX_ASLR
9084 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9085 +
9086 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9087 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9088 +#endif
9089 +
9090 extern unsigned long sparc64_elf_hwcap;
9091 #define ELF_HWCAP sparc64_elf_hwcap
9092
9093 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9094 index 9b1c36d..209298b 100644
9095 --- a/arch/sparc/include/asm/pgalloc_32.h
9096 +++ b/arch/sparc/include/asm/pgalloc_32.h
9097 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9098 }
9099
9100 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9101 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9102
9103 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9104 unsigned long address)
9105 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9106 index bcfe063..b333142 100644
9107 --- a/arch/sparc/include/asm/pgalloc_64.h
9108 +++ b/arch/sparc/include/asm/pgalloc_64.h
9109 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9110 }
9111
9112 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9113 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9114
9115 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9116 {
9117 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9118 index 502f632..da1917f 100644
9119 --- a/arch/sparc/include/asm/pgtable_32.h
9120 +++ b/arch/sparc/include/asm/pgtable_32.h
9121 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9122 #define PAGE_SHARED SRMMU_PAGE_SHARED
9123 #define PAGE_COPY SRMMU_PAGE_COPY
9124 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9125 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9126 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9127 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9128 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9129
9130 /* Top-level page directory - dummy used by init-mm.
9131 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9132
9133 /* xwr */
9134 #define __P000 PAGE_NONE
9135 -#define __P001 PAGE_READONLY
9136 -#define __P010 PAGE_COPY
9137 -#define __P011 PAGE_COPY
9138 +#define __P001 PAGE_READONLY_NOEXEC
9139 +#define __P010 PAGE_COPY_NOEXEC
9140 +#define __P011 PAGE_COPY_NOEXEC
9141 #define __P100 PAGE_READONLY
9142 #define __P101 PAGE_READONLY
9143 #define __P110 PAGE_COPY
9144 #define __P111 PAGE_COPY
9145
9146 #define __S000 PAGE_NONE
9147 -#define __S001 PAGE_READONLY
9148 -#define __S010 PAGE_SHARED
9149 -#define __S011 PAGE_SHARED
9150 +#define __S001 PAGE_READONLY_NOEXEC
9151 +#define __S010 PAGE_SHARED_NOEXEC
9152 +#define __S011 PAGE_SHARED_NOEXEC
9153 #define __S100 PAGE_READONLY
9154 #define __S101 PAGE_READONLY
9155 #define __S110 PAGE_SHARED
9156 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9157 index 79da178..c2eede8 100644
9158 --- a/arch/sparc/include/asm/pgtsrmmu.h
9159 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9160 @@ -115,6 +115,11 @@
9161 SRMMU_EXEC | SRMMU_REF)
9162 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9163 SRMMU_EXEC | SRMMU_REF)
9164 +
9165 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9166 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9167 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9168 +
9169 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9170 SRMMU_DIRTY | SRMMU_REF)
9171
9172 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9173 index 9689176..63c18ea 100644
9174 --- a/arch/sparc/include/asm/spinlock_64.h
9175 +++ b/arch/sparc/include/asm/spinlock_64.h
9176 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9177
9178 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9179
9180 -static void inline arch_read_lock(arch_rwlock_t *lock)
9181 +static inline void arch_read_lock(arch_rwlock_t *lock)
9182 {
9183 unsigned long tmp1, tmp2;
9184
9185 __asm__ __volatile__ (
9186 "1: ldsw [%2], %0\n"
9187 " brlz,pn %0, 2f\n"
9188 -"4: add %0, 1, %1\n"
9189 +"4: addcc %0, 1, %1\n"
9190 +
9191 +#ifdef CONFIG_PAX_REFCOUNT
9192 +" tvs %%icc, 6\n"
9193 +#endif
9194 +
9195 " cas [%2], %0, %1\n"
9196 " cmp %0, %1\n"
9197 " bne,pn %%icc, 1b\n"
9198 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9199 " .previous"
9200 : "=&r" (tmp1), "=&r" (tmp2)
9201 : "r" (lock)
9202 - : "memory");
9203 + : "memory", "cc");
9204 }
9205
9206 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9207 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9208 {
9209 int tmp1, tmp2;
9210
9211 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9212 "1: ldsw [%2], %0\n"
9213 " brlz,a,pn %0, 2f\n"
9214 " mov 0, %0\n"
9215 -" add %0, 1, %1\n"
9216 +" addcc %0, 1, %1\n"
9217 +
9218 +#ifdef CONFIG_PAX_REFCOUNT
9219 +" tvs %%icc, 6\n"
9220 +#endif
9221 +
9222 " cas [%2], %0, %1\n"
9223 " cmp %0, %1\n"
9224 " bne,pn %%icc, 1b\n"
9225 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9226 return tmp1;
9227 }
9228
9229 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9230 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9231 {
9232 unsigned long tmp1, tmp2;
9233
9234 __asm__ __volatile__(
9235 "1: lduw [%2], %0\n"
9236 -" sub %0, 1, %1\n"
9237 +" subcc %0, 1, %1\n"
9238 +
9239 +#ifdef CONFIG_PAX_REFCOUNT
9240 +" tvs %%icc, 6\n"
9241 +#endif
9242 +
9243 " cas [%2], %0, %1\n"
9244 " cmp %0, %1\n"
9245 " bne,pn %%xcc, 1b\n"
9246 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9247 : "memory");
9248 }
9249
9250 -static void inline arch_write_lock(arch_rwlock_t *lock)
9251 +static inline void arch_write_lock(arch_rwlock_t *lock)
9252 {
9253 unsigned long mask, tmp1, tmp2;
9254
9255 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9256 : "memory");
9257 }
9258
9259 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9260 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9261 {
9262 __asm__ __volatile__(
9263 " stw %%g0, [%0]"
9264 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9265 : "memory");
9266 }
9267
9268 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9269 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9270 {
9271 unsigned long mask, tmp1, tmp2, result;
9272
9273 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9274 index dd38075..e7cac83 100644
9275 --- a/arch/sparc/include/asm/thread_info_32.h
9276 +++ b/arch/sparc/include/asm/thread_info_32.h
9277 @@ -49,6 +49,8 @@ struct thread_info {
9278 unsigned long w_saved;
9279
9280 struct restart_block restart_block;
9281 +
9282 + unsigned long lowest_stack;
9283 };
9284
9285 /*
9286 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9287 index d5e5042..9bfee76 100644
9288 --- a/arch/sparc/include/asm/thread_info_64.h
9289 +++ b/arch/sparc/include/asm/thread_info_64.h
9290 @@ -63,6 +63,8 @@ struct thread_info {
9291 struct pt_regs *kern_una_regs;
9292 unsigned int kern_una_insn;
9293
9294 + unsigned long lowest_stack;
9295 +
9296 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9297 };
9298
9299 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9300 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9301 /* flag bit 6 is available */
9302 #define TIF_32BIT 7 /* 32-bit binary */
9303 -/* flag bit 8 is available */
9304 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9305 #define TIF_SECCOMP 9 /* secure computing */
9306 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9307 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9308 +
9309 /* NOTE: Thread flags >= 12 should be ones we have no interest
9310 * in using in assembly, else we can't use the mask as
9311 * an immediate value in instructions such as andcc.
9312 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9313 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9314 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9315 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9316 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9317
9318 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9319 _TIF_DO_NOTIFY_RESUME_MASK | \
9320 _TIF_NEED_RESCHED)
9321 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9322
9323 +#define _TIF_WORK_SYSCALL \
9324 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9325 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9326 +
9327 +
9328 /*
9329 * Thread-synchronous status.
9330 *
9331 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9332 index 0167d26..767bb0c 100644
9333 --- a/arch/sparc/include/asm/uaccess.h
9334 +++ b/arch/sparc/include/asm/uaccess.h
9335 @@ -1,5 +1,6 @@
9336 #ifndef ___ASM_SPARC_UACCESS_H
9337 #define ___ASM_SPARC_UACCESS_H
9338 +
9339 #if defined(__sparc__) && defined(__arch64__)
9340 #include <asm/uaccess_64.h>
9341 #else
9342 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9343 index 53a28dd..50c38c3 100644
9344 --- a/arch/sparc/include/asm/uaccess_32.h
9345 +++ b/arch/sparc/include/asm/uaccess_32.h
9346 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9347
9348 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9349 {
9350 - if (n && __access_ok((unsigned long) to, n))
9351 + if ((long)n < 0)
9352 + return n;
9353 +
9354 + if (n && __access_ok((unsigned long) to, n)) {
9355 + if (!__builtin_constant_p(n))
9356 + check_object_size(from, n, true);
9357 return __copy_user(to, (__force void __user *) from, n);
9358 - else
9359 + } else
9360 return n;
9361 }
9362
9363 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9364 {
9365 + if ((long)n < 0)
9366 + return n;
9367 +
9368 + if (!__builtin_constant_p(n))
9369 + check_object_size(from, n, true);
9370 +
9371 return __copy_user(to, (__force void __user *) from, n);
9372 }
9373
9374 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9375 {
9376 - if (n && __access_ok((unsigned long) from, n))
9377 + if ((long)n < 0)
9378 + return n;
9379 +
9380 + if (n && __access_ok((unsigned long) from, n)) {
9381 + if (!__builtin_constant_p(n))
9382 + check_object_size(to, n, false);
9383 return __copy_user((__force void __user *) to, from, n);
9384 - else
9385 + } else
9386 return n;
9387 }
9388
9389 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9390 {
9391 + if ((long)n < 0)
9392 + return n;
9393 +
9394 return __copy_user((__force void __user *) to, from, n);
9395 }
9396
9397 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9398 index e562d3c..191f176 100644
9399 --- a/arch/sparc/include/asm/uaccess_64.h
9400 +++ b/arch/sparc/include/asm/uaccess_64.h
9401 @@ -10,6 +10,7 @@
9402 #include <linux/compiler.h>
9403 #include <linux/string.h>
9404 #include <linux/thread_info.h>
9405 +#include <linux/kernel.h>
9406 #include <asm/asi.h>
9407 #include <asm/spitfire.h>
9408 #include <asm-generic/uaccess-unaligned.h>
9409 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9410 static inline unsigned long __must_check
9411 copy_from_user(void *to, const void __user *from, unsigned long size)
9412 {
9413 - unsigned long ret = ___copy_from_user(to, from, size);
9414 + unsigned long ret;
9415
9416 + if ((long)size < 0 || size > INT_MAX)
9417 + return size;
9418 +
9419 + if (!__builtin_constant_p(size))
9420 + check_object_size(to, size, false);
9421 +
9422 + ret = ___copy_from_user(to, from, size);
9423 if (unlikely(ret))
9424 ret = copy_from_user_fixup(to, from, size);
9425
9426 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9427 static inline unsigned long __must_check
9428 copy_to_user(void __user *to, const void *from, unsigned long size)
9429 {
9430 - unsigned long ret = ___copy_to_user(to, from, size);
9431 + unsigned long ret;
9432
9433 + if ((long)size < 0 || size > INT_MAX)
9434 + return size;
9435 +
9436 + if (!__builtin_constant_p(size))
9437 + check_object_size(from, size, true);
9438 +
9439 + ret = ___copy_to_user(to, from, size);
9440 if (unlikely(ret))
9441 ret = copy_to_user_fixup(to, from, size);
9442 return ret;
9443 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9444 index d432fb2..6056af1 100644
9445 --- a/arch/sparc/kernel/Makefile
9446 +++ b/arch/sparc/kernel/Makefile
9447 @@ -3,7 +3,7 @@
9448 #
9449
9450 asflags-y := -ansi
9451 -ccflags-y := -Werror
9452 +#ccflags-y := -Werror
9453
9454 extra-y := head_$(BITS).o
9455
9456 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9457 index fdd819d..5af08c8 100644
9458 --- a/arch/sparc/kernel/process_32.c
9459 +++ b/arch/sparc/kernel/process_32.c
9460 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9461
9462 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9463 r->psr, r->pc, r->npc, r->y, print_tainted());
9464 - printk("PC: <%pS>\n", (void *) r->pc);
9465 + printk("PC: <%pA>\n", (void *) r->pc);
9466 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9467 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9468 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9469 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9470 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9471 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9472 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9473 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9474
9475 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9476 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9477 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9478 rw = (struct reg_window32 *) fp;
9479 pc = rw->ins[7];
9480 printk("[%08lx : ", pc);
9481 - printk("%pS ] ", (void *) pc);
9482 + printk("%pA ] ", (void *) pc);
9483 fp = rw->ins[6];
9484 } while (++count < 16);
9485 printk("\n");
9486 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9487 index baebab2..9cd13b1 100644
9488 --- a/arch/sparc/kernel/process_64.c
9489 +++ b/arch/sparc/kernel/process_64.c
9490 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9491 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9492 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9493 if (regs->tstate & TSTATE_PRIV)
9494 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9495 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9496 }
9497
9498 void show_regs(struct pt_regs *regs)
9499 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9500
9501 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9502 regs->tpc, regs->tnpc, regs->y, print_tainted());
9503 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9504 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9505 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9506 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9507 regs->u_regs[3]);
9508 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9509 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9510 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9511 regs->u_regs[15]);
9512 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9513 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9514 show_regwindow(regs);
9515 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9516 }
9517 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9518 ((tp && tp->task) ? tp->task->pid : -1));
9519
9520 if (gp->tstate & TSTATE_PRIV) {
9521 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9522 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9523 (void *) gp->tpc,
9524 (void *) gp->o7,
9525 (void *) gp->i7,
9526 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9527 index 79cc0d1..ec62734 100644
9528 --- a/arch/sparc/kernel/prom_common.c
9529 +++ b/arch/sparc/kernel/prom_common.c
9530 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9531
9532 unsigned int prom_early_allocated __initdata;
9533
9534 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9535 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9536 .nextprop = prom_common_nextprop,
9537 .getproplen = prom_getproplen,
9538 .getproperty = prom_getproperty,
9539 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9540 index 7ff45e4..a58f271 100644
9541 --- a/arch/sparc/kernel/ptrace_64.c
9542 +++ b/arch/sparc/kernel/ptrace_64.c
9543 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9544 return ret;
9545 }
9546
9547 +#ifdef CONFIG_GRKERNSEC_SETXID
9548 +extern void gr_delayed_cred_worker(void);
9549 +#endif
9550 +
9551 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9552 {
9553 int ret = 0;
9554 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9555 /* do the secure computing check first */
9556 secure_computing_strict(regs->u_regs[UREG_G1]);
9557
9558 +#ifdef CONFIG_GRKERNSEC_SETXID
9559 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9560 + gr_delayed_cred_worker();
9561 +#endif
9562 +
9563 if (test_thread_flag(TIF_SYSCALL_TRACE))
9564 ret = tracehook_report_syscall_entry(regs);
9565
9566 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9567
9568 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9569 {
9570 +#ifdef CONFIG_GRKERNSEC_SETXID
9571 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9572 + gr_delayed_cred_worker();
9573 +#endif
9574 +
9575 audit_syscall_exit(regs);
9576
9577 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9578 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9579 index e142545..fd29654 100644
9580 --- a/arch/sparc/kernel/smp_64.c
9581 +++ b/arch/sparc/kernel/smp_64.c
9582 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9583 extern unsigned long xcall_flush_dcache_page_spitfire;
9584
9585 #ifdef CONFIG_DEBUG_DCFLUSH
9586 -extern atomic_t dcpage_flushes;
9587 -extern atomic_t dcpage_flushes_xcall;
9588 +extern atomic_unchecked_t dcpage_flushes;
9589 +extern atomic_unchecked_t dcpage_flushes_xcall;
9590 #endif
9591
9592 static inline void __local_flush_dcache_page(struct page *page)
9593 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9594 return;
9595
9596 #ifdef CONFIG_DEBUG_DCFLUSH
9597 - atomic_inc(&dcpage_flushes);
9598 + atomic_inc_unchecked(&dcpage_flushes);
9599 #endif
9600
9601 this_cpu = get_cpu();
9602 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9603 xcall_deliver(data0, __pa(pg_addr),
9604 (u64) pg_addr, cpumask_of(cpu));
9605 #ifdef CONFIG_DEBUG_DCFLUSH
9606 - atomic_inc(&dcpage_flushes_xcall);
9607 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9608 #endif
9609 }
9610 }
9611 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9612 preempt_disable();
9613
9614 #ifdef CONFIG_DEBUG_DCFLUSH
9615 - atomic_inc(&dcpage_flushes);
9616 + atomic_inc_unchecked(&dcpage_flushes);
9617 #endif
9618 data0 = 0;
9619 pg_addr = page_address(page);
9620 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9621 xcall_deliver(data0, __pa(pg_addr),
9622 (u64) pg_addr, cpu_online_mask);
9623 #ifdef CONFIG_DEBUG_DCFLUSH
9624 - atomic_inc(&dcpage_flushes_xcall);
9625 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9626 #endif
9627 }
9628 __local_flush_dcache_page(page);
9629 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9630 index 3a8d184..49498a8 100644
9631 --- a/arch/sparc/kernel/sys_sparc_32.c
9632 +++ b/arch/sparc/kernel/sys_sparc_32.c
9633 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9634 if (len > TASK_SIZE - PAGE_SIZE)
9635 return -ENOMEM;
9636 if (!addr)
9637 - addr = TASK_UNMAPPED_BASE;
9638 + addr = current->mm->mmap_base;
9639
9640 info.flags = 0;
9641 info.length = len;
9642 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9643 index 51561b8..8256764 100644
9644 --- a/arch/sparc/kernel/sys_sparc_64.c
9645 +++ b/arch/sparc/kernel/sys_sparc_64.c
9646 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9647 struct vm_area_struct * vma;
9648 unsigned long task_size = TASK_SIZE;
9649 int do_color_align;
9650 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9651 struct vm_unmapped_area_info info;
9652
9653 if (flags & MAP_FIXED) {
9654 /* We do not accept a shared mapping if it would violate
9655 * cache aliasing constraints.
9656 */
9657 - if ((flags & MAP_SHARED) &&
9658 + if ((filp || (flags & MAP_SHARED)) &&
9659 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9660 return -EINVAL;
9661 return addr;
9662 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9663 if (filp || (flags & MAP_SHARED))
9664 do_color_align = 1;
9665
9666 +#ifdef CONFIG_PAX_RANDMMAP
9667 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9668 +#endif
9669 +
9670 if (addr) {
9671 if (do_color_align)
9672 addr = COLOR_ALIGN(addr, pgoff);
9673 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9674 addr = PAGE_ALIGN(addr);
9675
9676 vma = find_vma(mm, addr);
9677 - if (task_size - len >= addr &&
9678 - (!vma || addr + len <= vma->vm_start))
9679 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9680 return addr;
9681 }
9682
9683 info.flags = 0;
9684 info.length = len;
9685 - info.low_limit = TASK_UNMAPPED_BASE;
9686 + info.low_limit = mm->mmap_base;
9687 info.high_limit = min(task_size, VA_EXCLUDE_START);
9688 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9689 info.align_offset = pgoff << PAGE_SHIFT;
9690 + info.threadstack_offset = offset;
9691 addr = vm_unmapped_area(&info);
9692
9693 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9694 VM_BUG_ON(addr != -ENOMEM);
9695 info.low_limit = VA_EXCLUDE_END;
9696 +
9697 +#ifdef CONFIG_PAX_RANDMMAP
9698 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9699 + info.low_limit += mm->delta_mmap;
9700 +#endif
9701 +
9702 info.high_limit = task_size;
9703 addr = vm_unmapped_area(&info);
9704 }
9705 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9706 unsigned long task_size = STACK_TOP32;
9707 unsigned long addr = addr0;
9708 int do_color_align;
9709 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9710 struct vm_unmapped_area_info info;
9711
9712 /* This should only ever run for 32-bit processes. */
9713 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9714 /* We do not accept a shared mapping if it would violate
9715 * cache aliasing constraints.
9716 */
9717 - if ((flags & MAP_SHARED) &&
9718 + if ((filp || (flags & MAP_SHARED)) &&
9719 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9720 return -EINVAL;
9721 return addr;
9722 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9723 if (filp || (flags & MAP_SHARED))
9724 do_color_align = 1;
9725
9726 +#ifdef CONFIG_PAX_RANDMMAP
9727 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9728 +#endif
9729 +
9730 /* requesting a specific address */
9731 if (addr) {
9732 if (do_color_align)
9733 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9734 addr = PAGE_ALIGN(addr);
9735
9736 vma = find_vma(mm, addr);
9737 - if (task_size - len >= addr &&
9738 - (!vma || addr + len <= vma->vm_start))
9739 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9740 return addr;
9741 }
9742
9743 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9744 info.high_limit = mm->mmap_base;
9745 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9746 info.align_offset = pgoff << PAGE_SHIFT;
9747 + info.threadstack_offset = offset;
9748 addr = vm_unmapped_area(&info);
9749
9750 /*
9751 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9752 VM_BUG_ON(addr != -ENOMEM);
9753 info.flags = 0;
9754 info.low_limit = TASK_UNMAPPED_BASE;
9755 +
9756 +#ifdef CONFIG_PAX_RANDMMAP
9757 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9758 + info.low_limit += mm->delta_mmap;
9759 +#endif
9760 +
9761 info.high_limit = STACK_TOP32;
9762 addr = vm_unmapped_area(&info);
9763 }
9764 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9765 EXPORT_SYMBOL(get_fb_unmapped_area);
9766
9767 /* Essentially the same as PowerPC. */
9768 -static unsigned long mmap_rnd(void)
9769 +static unsigned long mmap_rnd(struct mm_struct *mm)
9770 {
9771 unsigned long rnd = 0UL;
9772
9773 +#ifdef CONFIG_PAX_RANDMMAP
9774 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9775 +#endif
9776 +
9777 if (current->flags & PF_RANDOMIZE) {
9778 unsigned long val = get_random_int();
9779 if (test_thread_flag(TIF_32BIT))
9780 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9781
9782 void arch_pick_mmap_layout(struct mm_struct *mm)
9783 {
9784 - unsigned long random_factor = mmap_rnd();
9785 + unsigned long random_factor = mmap_rnd(mm);
9786 unsigned long gap;
9787
9788 /*
9789 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9790 gap == RLIM_INFINITY ||
9791 sysctl_legacy_va_layout) {
9792 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9793 +
9794 +#ifdef CONFIG_PAX_RANDMMAP
9795 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9796 + mm->mmap_base += mm->delta_mmap;
9797 +#endif
9798 +
9799 mm->get_unmapped_area = arch_get_unmapped_area;
9800 } else {
9801 /* We know it's 32-bit */
9802 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9803 gap = (task_size / 6 * 5);
9804
9805 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9806 +
9807 +#ifdef CONFIG_PAX_RANDMMAP
9808 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9809 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9810 +#endif
9811 +
9812 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9813 }
9814 }
9815 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9816 index 73ec8a7..4611979 100644
9817 --- a/arch/sparc/kernel/syscalls.S
9818 +++ b/arch/sparc/kernel/syscalls.S
9819 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9820 #endif
9821 .align 32
9822 1: ldx [%g6 + TI_FLAGS], %l5
9823 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9824 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9825 be,pt %icc, rtrap
9826 nop
9827 call syscall_trace_leave
9828 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9829
9830 srl %i3, 0, %o3 ! IEU0
9831 srl %i2, 0, %o2 ! IEU0 Group
9832 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9833 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9834 bne,pn %icc, linux_syscall_trace32 ! CTI
9835 mov %i0, %l5 ! IEU1
9836 5: call %l7 ! CTI Group brk forced
9837 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9838
9839 mov %i3, %o3 ! IEU1
9840 mov %i4, %o4 ! IEU0 Group
9841 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9842 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9843 bne,pn %icc, linux_syscall_trace ! CTI Group
9844 mov %i0, %l5 ! IEU0
9845 2: call %l7 ! CTI Group brk forced
9846 @@ -223,7 +223,7 @@ ret_sys_call:
9847
9848 cmp %o0, -ERESTART_RESTARTBLOCK
9849 bgeu,pn %xcc, 1f
9850 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9851 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9852 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9853
9854 2:
9855 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9856 index 6629829..036032d 100644
9857 --- a/arch/sparc/kernel/traps_32.c
9858 +++ b/arch/sparc/kernel/traps_32.c
9859 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9860 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9861 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9862
9863 +extern void gr_handle_kernel_exploit(void);
9864 +
9865 void die_if_kernel(char *str, struct pt_regs *regs)
9866 {
9867 static int die_counter;
9868 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9869 count++ < 30 &&
9870 (((unsigned long) rw) >= PAGE_OFFSET) &&
9871 !(((unsigned long) rw) & 0x7)) {
9872 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9873 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9874 (void *) rw->ins[7]);
9875 rw = (struct reg_window32 *)rw->ins[6];
9876 }
9877 }
9878 printk("Instruction DUMP:");
9879 instruction_dump ((unsigned long *) regs->pc);
9880 - if(regs->psr & PSR_PS)
9881 + if(regs->psr & PSR_PS) {
9882 + gr_handle_kernel_exploit();
9883 do_exit(SIGKILL);
9884 + }
9885 do_exit(SIGSEGV);
9886 }
9887
9888 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9889 index b3f833a..f485f80 100644
9890 --- a/arch/sparc/kernel/traps_64.c
9891 +++ b/arch/sparc/kernel/traps_64.c
9892 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9893 i + 1,
9894 p->trapstack[i].tstate, p->trapstack[i].tpc,
9895 p->trapstack[i].tnpc, p->trapstack[i].tt);
9896 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9897 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9898 }
9899 }
9900
9901 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9902
9903 lvl -= 0x100;
9904 if (regs->tstate & TSTATE_PRIV) {
9905 +
9906 +#ifdef CONFIG_PAX_REFCOUNT
9907 + if (lvl == 6)
9908 + pax_report_refcount_overflow(regs);
9909 +#endif
9910 +
9911 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9912 die_if_kernel(buffer, regs);
9913 }
9914 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9915 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9916 {
9917 char buffer[32];
9918 -
9919 +
9920 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9921 0, lvl, SIGTRAP) == NOTIFY_STOP)
9922 return;
9923
9924 +#ifdef CONFIG_PAX_REFCOUNT
9925 + if (lvl == 6)
9926 + pax_report_refcount_overflow(regs);
9927 +#endif
9928 +
9929 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9930
9931 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9932 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9933 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9934 printk("%s" "ERROR(%d): ",
9935 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9936 - printk("TPC<%pS>\n", (void *) regs->tpc);
9937 + printk("TPC<%pA>\n", (void *) regs->tpc);
9938 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9939 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9940 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9941 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9942 smp_processor_id(),
9943 (type & 0x1) ? 'I' : 'D',
9944 regs->tpc);
9945 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9946 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9947 panic("Irrecoverable Cheetah+ parity error.");
9948 }
9949
9950 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9951 smp_processor_id(),
9952 (type & 0x1) ? 'I' : 'D',
9953 regs->tpc);
9954 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9955 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9956 }
9957
9958 struct sun4v_error_entry {
9959 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9960 /*0x38*/u64 reserved_5;
9961 };
9962
9963 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9964 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9965 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9966 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9967
9968 static const char *sun4v_err_type_to_str(u8 type)
9969 {
9970 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9971 }
9972
9973 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9974 - int cpu, const char *pfx, atomic_t *ocnt)
9975 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9976 {
9977 u64 *raw_ptr = (u64 *) ent;
9978 u32 attrs;
9979 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9980
9981 show_regs(regs);
9982
9983 - if ((cnt = atomic_read(ocnt)) != 0) {
9984 - atomic_set(ocnt, 0);
9985 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9986 + atomic_set_unchecked(ocnt, 0);
9987 wmb();
9988 printk("%s: Queue overflowed %d times.\n",
9989 pfx, cnt);
9990 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9991 */
9992 void sun4v_resum_overflow(struct pt_regs *regs)
9993 {
9994 - atomic_inc(&sun4v_resum_oflow_cnt);
9995 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
9996 }
9997
9998 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
9999 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10000 /* XXX Actually even this can make not that much sense. Perhaps
10001 * XXX we should just pull the plug and panic directly from here?
10002 */
10003 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10004 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10005 }
10006
10007 unsigned long sun4v_err_itlb_vaddr;
10008 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10009
10010 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10011 regs->tpc, tl);
10012 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10013 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10014 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10015 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10016 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10017 (void *) regs->u_regs[UREG_I7]);
10018 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10019 "pte[%lx] error[%lx]\n",
10020 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10021
10022 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10023 regs->tpc, tl);
10024 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10025 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10026 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10027 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10028 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10029 (void *) regs->u_regs[UREG_I7]);
10030 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10031 "pte[%lx] error[%lx]\n",
10032 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10033 fp = (unsigned long)sf->fp + STACK_BIAS;
10034 }
10035
10036 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10037 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10038 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10039 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10040 int index = tsk->curr_ret_stack;
10041 if (tsk->ret_stack && index >= graph) {
10042 pc = tsk->ret_stack[index - graph].ret;
10043 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10044 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10045 graph++;
10046 }
10047 }
10048 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10049 return (struct reg_window *) (fp + STACK_BIAS);
10050 }
10051
10052 +extern void gr_handle_kernel_exploit(void);
10053 +
10054 void die_if_kernel(char *str, struct pt_regs *regs)
10055 {
10056 static int die_counter;
10057 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10058 while (rw &&
10059 count++ < 30 &&
10060 kstack_valid(tp, (unsigned long) rw)) {
10061 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10062 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10063 (void *) rw->ins[7]);
10064
10065 rw = kernel_stack_up(rw);
10066 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10067 }
10068 user_instruction_dump ((unsigned int __user *) regs->tpc);
10069 }
10070 - if (regs->tstate & TSTATE_PRIV)
10071 + if (regs->tstate & TSTATE_PRIV) {
10072 + gr_handle_kernel_exploit();
10073 do_exit(SIGKILL);
10074 + }
10075 do_exit(SIGSEGV);
10076 }
10077 EXPORT_SYMBOL(die_if_kernel);
10078 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10079 index 8201c25e..072a2a7 100644
10080 --- a/arch/sparc/kernel/unaligned_64.c
10081 +++ b/arch/sparc/kernel/unaligned_64.c
10082 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10083 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10084
10085 if (__ratelimit(&ratelimit)) {
10086 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10087 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10088 regs->tpc, (void *) regs->tpc);
10089 }
10090 }
10091 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10092 index dbe119b..089c7c1 100644
10093 --- a/arch/sparc/lib/Makefile
10094 +++ b/arch/sparc/lib/Makefile
10095 @@ -2,7 +2,7 @@
10096 #
10097
10098 asflags-y := -ansi -DST_DIV0=0x02
10099 -ccflags-y := -Werror
10100 +#ccflags-y := -Werror
10101
10102 lib-$(CONFIG_SPARC32) += ashrdi3.o
10103 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10104 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10105 index 85c233d..68500e0 100644
10106 --- a/arch/sparc/lib/atomic_64.S
10107 +++ b/arch/sparc/lib/atomic_64.S
10108 @@ -17,7 +17,12 @@
10109 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10110 BACKOFF_SETUP(%o2)
10111 1: lduw [%o1], %g1
10112 - add %g1, %o0, %g7
10113 + addcc %g1, %o0, %g7
10114 +
10115 +#ifdef CONFIG_PAX_REFCOUNT
10116 + tvs %icc, 6
10117 +#endif
10118 +
10119 cas [%o1], %g1, %g7
10120 cmp %g1, %g7
10121 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10122 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10123 2: BACKOFF_SPIN(%o2, %o3, 1b)
10124 ENDPROC(atomic_add)
10125
10126 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10127 + BACKOFF_SETUP(%o2)
10128 +1: lduw [%o1], %g1
10129 + add %g1, %o0, %g7
10130 + cas [%o1], %g1, %g7
10131 + cmp %g1, %g7
10132 + bne,pn %icc, 2f
10133 + nop
10134 + retl
10135 + nop
10136 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10137 +ENDPROC(atomic_add_unchecked)
10138 +
10139 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10140 BACKOFF_SETUP(%o2)
10141 1: lduw [%o1], %g1
10142 - sub %g1, %o0, %g7
10143 + subcc %g1, %o0, %g7
10144 +
10145 +#ifdef CONFIG_PAX_REFCOUNT
10146 + tvs %icc, 6
10147 +#endif
10148 +
10149 cas [%o1], %g1, %g7
10150 cmp %g1, %g7
10151 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10152 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10153 2: BACKOFF_SPIN(%o2, %o3, 1b)
10154 ENDPROC(atomic_sub)
10155
10156 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10157 + BACKOFF_SETUP(%o2)
10158 +1: lduw [%o1], %g1
10159 + sub %g1, %o0, %g7
10160 + cas [%o1], %g1, %g7
10161 + cmp %g1, %g7
10162 + bne,pn %icc, 2f
10163 + nop
10164 + retl
10165 + nop
10166 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10167 +ENDPROC(atomic_sub_unchecked)
10168 +
10169 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10170 BACKOFF_SETUP(%o2)
10171 1: lduw [%o1], %g1
10172 - add %g1, %o0, %g7
10173 + addcc %g1, %o0, %g7
10174 +
10175 +#ifdef CONFIG_PAX_REFCOUNT
10176 + tvs %icc, 6
10177 +#endif
10178 +
10179 cas [%o1], %g1, %g7
10180 cmp %g1, %g7
10181 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10182 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10183 2: BACKOFF_SPIN(%o2, %o3, 1b)
10184 ENDPROC(atomic_add_ret)
10185
10186 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10187 + BACKOFF_SETUP(%o2)
10188 +1: lduw [%o1], %g1
10189 + addcc %g1, %o0, %g7
10190 + cas [%o1], %g1, %g7
10191 + cmp %g1, %g7
10192 + bne,pn %icc, 2f
10193 + add %g7, %o0, %g7
10194 + sra %g7, 0, %o0
10195 + retl
10196 + nop
10197 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10198 +ENDPROC(atomic_add_ret_unchecked)
10199 +
10200 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10201 BACKOFF_SETUP(%o2)
10202 1: lduw [%o1], %g1
10203 - sub %g1, %o0, %g7
10204 + subcc %g1, %o0, %g7
10205 +
10206 +#ifdef CONFIG_PAX_REFCOUNT
10207 + tvs %icc, 6
10208 +#endif
10209 +
10210 cas [%o1], %g1, %g7
10211 cmp %g1, %g7
10212 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10213 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10214 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10215 BACKOFF_SETUP(%o2)
10216 1: ldx [%o1], %g1
10217 - add %g1, %o0, %g7
10218 + addcc %g1, %o0, %g7
10219 +
10220 +#ifdef CONFIG_PAX_REFCOUNT
10221 + tvs %xcc, 6
10222 +#endif
10223 +
10224 casx [%o1], %g1, %g7
10225 cmp %g1, %g7
10226 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10227 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10228 2: BACKOFF_SPIN(%o2, %o3, 1b)
10229 ENDPROC(atomic64_add)
10230
10231 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10232 + BACKOFF_SETUP(%o2)
10233 +1: ldx [%o1], %g1
10234 + addcc %g1, %o0, %g7
10235 + casx [%o1], %g1, %g7
10236 + cmp %g1, %g7
10237 + bne,pn %xcc, 2f
10238 + nop
10239 + retl
10240 + nop
10241 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10242 +ENDPROC(atomic64_add_unchecked)
10243 +
10244 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10245 BACKOFF_SETUP(%o2)
10246 1: ldx [%o1], %g1
10247 - sub %g1, %o0, %g7
10248 + subcc %g1, %o0, %g7
10249 +
10250 +#ifdef CONFIG_PAX_REFCOUNT
10251 + tvs %xcc, 6
10252 +#endif
10253 +
10254 casx [%o1], %g1, %g7
10255 cmp %g1, %g7
10256 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10257 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10258 2: BACKOFF_SPIN(%o2, %o3, 1b)
10259 ENDPROC(atomic64_sub)
10260
10261 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10262 + BACKOFF_SETUP(%o2)
10263 +1: ldx [%o1], %g1
10264 + subcc %g1, %o0, %g7
10265 + casx [%o1], %g1, %g7
10266 + cmp %g1, %g7
10267 + bne,pn %xcc, 2f
10268 + nop
10269 + retl
10270 + nop
10271 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10272 +ENDPROC(atomic64_sub_unchecked)
10273 +
10274 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10275 BACKOFF_SETUP(%o2)
10276 1: ldx [%o1], %g1
10277 - add %g1, %o0, %g7
10278 + addcc %g1, %o0, %g7
10279 +
10280 +#ifdef CONFIG_PAX_REFCOUNT
10281 + tvs %xcc, 6
10282 +#endif
10283 +
10284 casx [%o1], %g1, %g7
10285 cmp %g1, %g7
10286 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10287 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10288 2: BACKOFF_SPIN(%o2, %o3, 1b)
10289 ENDPROC(atomic64_add_ret)
10290
10291 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10292 + BACKOFF_SETUP(%o2)
10293 +1: ldx [%o1], %g1
10294 + addcc %g1, %o0, %g7
10295 + casx [%o1], %g1, %g7
10296 + cmp %g1, %g7
10297 + bne,pn %xcc, 2f
10298 + add %g7, %o0, %g7
10299 + mov %g7, %o0
10300 + retl
10301 + nop
10302 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10303 +ENDPROC(atomic64_add_ret_unchecked)
10304 +
10305 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10306 BACKOFF_SETUP(%o2)
10307 1: ldx [%o1], %g1
10308 - sub %g1, %o0, %g7
10309 + subcc %g1, %o0, %g7
10310 +
10311 +#ifdef CONFIG_PAX_REFCOUNT
10312 + tvs %xcc, 6
10313 +#endif
10314 +
10315 casx [%o1], %g1, %g7
10316 cmp %g1, %g7
10317 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10318 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10319 index 323335b..ed85ea2 100644
10320 --- a/arch/sparc/lib/ksyms.c
10321 +++ b/arch/sparc/lib/ksyms.c
10322 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10323
10324 /* Atomic counter implementation. */
10325 EXPORT_SYMBOL(atomic_add);
10326 +EXPORT_SYMBOL(atomic_add_unchecked);
10327 EXPORT_SYMBOL(atomic_add_ret);
10328 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10329 EXPORT_SYMBOL(atomic_sub);
10330 +EXPORT_SYMBOL(atomic_sub_unchecked);
10331 EXPORT_SYMBOL(atomic_sub_ret);
10332 EXPORT_SYMBOL(atomic64_add);
10333 +EXPORT_SYMBOL(atomic64_add_unchecked);
10334 EXPORT_SYMBOL(atomic64_add_ret);
10335 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10336 EXPORT_SYMBOL(atomic64_sub);
10337 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10338 EXPORT_SYMBOL(atomic64_sub_ret);
10339 EXPORT_SYMBOL(atomic64_dec_if_positive);
10340
10341 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10342 index 30c3ecc..736f015 100644
10343 --- a/arch/sparc/mm/Makefile
10344 +++ b/arch/sparc/mm/Makefile
10345 @@ -2,7 +2,7 @@
10346 #
10347
10348 asflags-y := -ansi
10349 -ccflags-y := -Werror
10350 +#ccflags-y := -Werror
10351
10352 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10353 obj-y += fault_$(BITS).o
10354 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10355 index e98bfda..ea8d221 100644
10356 --- a/arch/sparc/mm/fault_32.c
10357 +++ b/arch/sparc/mm/fault_32.c
10358 @@ -21,6 +21,9 @@
10359 #include <linux/perf_event.h>
10360 #include <linux/interrupt.h>
10361 #include <linux/kdebug.h>
10362 +#include <linux/slab.h>
10363 +#include <linux/pagemap.h>
10364 +#include <linux/compiler.h>
10365
10366 #include <asm/page.h>
10367 #include <asm/pgtable.h>
10368 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10369 return safe_compute_effective_address(regs, insn);
10370 }
10371
10372 +#ifdef CONFIG_PAX_PAGEEXEC
10373 +#ifdef CONFIG_PAX_DLRESOLVE
10374 +static void pax_emuplt_close(struct vm_area_struct *vma)
10375 +{
10376 + vma->vm_mm->call_dl_resolve = 0UL;
10377 +}
10378 +
10379 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10380 +{
10381 + unsigned int *kaddr;
10382 +
10383 + vmf->page = alloc_page(GFP_HIGHUSER);
10384 + if (!vmf->page)
10385 + return VM_FAULT_OOM;
10386 +
10387 + kaddr = kmap(vmf->page);
10388 + memset(kaddr, 0, PAGE_SIZE);
10389 + kaddr[0] = 0x9DE3BFA8U; /* save */
10390 + flush_dcache_page(vmf->page);
10391 + kunmap(vmf->page);
10392 + return VM_FAULT_MAJOR;
10393 +}
10394 +
10395 +static const struct vm_operations_struct pax_vm_ops = {
10396 + .close = pax_emuplt_close,
10397 + .fault = pax_emuplt_fault
10398 +};
10399 +
10400 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10401 +{
10402 + int ret;
10403 +
10404 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10405 + vma->vm_mm = current->mm;
10406 + vma->vm_start = addr;
10407 + vma->vm_end = addr + PAGE_SIZE;
10408 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10409 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10410 + vma->vm_ops = &pax_vm_ops;
10411 +
10412 + ret = insert_vm_struct(current->mm, vma);
10413 + if (ret)
10414 + return ret;
10415 +
10416 + ++current->mm->total_vm;
10417 + return 0;
10418 +}
10419 +#endif
10420 +
10421 +/*
10422 + * PaX: decide what to do with offenders (regs->pc = fault address)
10423 + *
10424 + * returns 1 when task should be killed
10425 + * 2 when patched PLT trampoline was detected
10426 + * 3 when unpatched PLT trampoline was detected
10427 + */
10428 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10429 +{
10430 +
10431 +#ifdef CONFIG_PAX_EMUPLT
10432 + int err;
10433 +
10434 + do { /* PaX: patched PLT emulation #1 */
10435 + unsigned int sethi1, sethi2, jmpl;
10436 +
10437 + err = get_user(sethi1, (unsigned int *)regs->pc);
10438 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10439 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10440 +
10441 + if (err)
10442 + break;
10443 +
10444 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10445 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10446 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10447 + {
10448 + unsigned int addr;
10449 +
10450 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10451 + addr = regs->u_regs[UREG_G1];
10452 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10453 + regs->pc = addr;
10454 + regs->npc = addr+4;
10455 + return 2;
10456 + }
10457 + } while (0);
10458 +
10459 + do { /* PaX: patched PLT emulation #2 */
10460 + unsigned int ba;
10461 +
10462 + err = get_user(ba, (unsigned int *)regs->pc);
10463 +
10464 + if (err)
10465 + break;
10466 +
10467 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10468 + unsigned int addr;
10469 +
10470 + if ((ba & 0xFFC00000U) == 0x30800000U)
10471 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10472 + else
10473 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10474 + regs->pc = addr;
10475 + regs->npc = addr+4;
10476 + return 2;
10477 + }
10478 + } while (0);
10479 +
10480 + do { /* PaX: patched PLT emulation #3 */
10481 + unsigned int sethi, bajmpl, nop;
10482 +
10483 + err = get_user(sethi, (unsigned int *)regs->pc);
10484 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10485 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10486 +
10487 + if (err)
10488 + break;
10489 +
10490 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10491 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10492 + nop == 0x01000000U)
10493 + {
10494 + unsigned int addr;
10495 +
10496 + addr = (sethi & 0x003FFFFFU) << 10;
10497 + regs->u_regs[UREG_G1] = addr;
10498 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10499 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10500 + else
10501 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10502 + regs->pc = addr;
10503 + regs->npc = addr+4;
10504 + return 2;
10505 + }
10506 + } while (0);
10507 +
10508 + do { /* PaX: unpatched PLT emulation step 1 */
10509 + unsigned int sethi, ba, nop;
10510 +
10511 + err = get_user(sethi, (unsigned int *)regs->pc);
10512 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10513 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10514 +
10515 + if (err)
10516 + break;
10517 +
10518 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10519 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10520 + nop == 0x01000000U)
10521 + {
10522 + unsigned int addr, save, call;
10523 +
10524 + if ((ba & 0xFFC00000U) == 0x30800000U)
10525 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10526 + else
10527 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10528 +
10529 + err = get_user(save, (unsigned int *)addr);
10530 + err |= get_user(call, (unsigned int *)(addr+4));
10531 + err |= get_user(nop, (unsigned int *)(addr+8));
10532 + if (err)
10533 + break;
10534 +
10535 +#ifdef CONFIG_PAX_DLRESOLVE
10536 + if (save == 0x9DE3BFA8U &&
10537 + (call & 0xC0000000U) == 0x40000000U &&
10538 + nop == 0x01000000U)
10539 + {
10540 + struct vm_area_struct *vma;
10541 + unsigned long call_dl_resolve;
10542 +
10543 + down_read(&current->mm->mmap_sem);
10544 + call_dl_resolve = current->mm->call_dl_resolve;
10545 + up_read(&current->mm->mmap_sem);
10546 + if (likely(call_dl_resolve))
10547 + goto emulate;
10548 +
10549 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10550 +
10551 + down_write(&current->mm->mmap_sem);
10552 + if (current->mm->call_dl_resolve) {
10553 + call_dl_resolve = current->mm->call_dl_resolve;
10554 + up_write(&current->mm->mmap_sem);
10555 + if (vma)
10556 + kmem_cache_free(vm_area_cachep, vma);
10557 + goto emulate;
10558 + }
10559 +
10560 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10561 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10562 + up_write(&current->mm->mmap_sem);
10563 + if (vma)
10564 + kmem_cache_free(vm_area_cachep, vma);
10565 + return 1;
10566 + }
10567 +
10568 + if (pax_insert_vma(vma, call_dl_resolve)) {
10569 + up_write(&current->mm->mmap_sem);
10570 + kmem_cache_free(vm_area_cachep, vma);
10571 + return 1;
10572 + }
10573 +
10574 + current->mm->call_dl_resolve = call_dl_resolve;
10575 + up_write(&current->mm->mmap_sem);
10576 +
10577 +emulate:
10578 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10579 + regs->pc = call_dl_resolve;
10580 + regs->npc = addr+4;
10581 + return 3;
10582 + }
10583 +#endif
10584 +
10585 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10586 + if ((save & 0xFFC00000U) == 0x05000000U &&
10587 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10588 + nop == 0x01000000U)
10589 + {
10590 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10591 + regs->u_regs[UREG_G2] = addr + 4;
10592 + addr = (save & 0x003FFFFFU) << 10;
10593 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10594 + regs->pc = addr;
10595 + regs->npc = addr+4;
10596 + return 3;
10597 + }
10598 + }
10599 + } while (0);
10600 +
10601 + do { /* PaX: unpatched PLT emulation step 2 */
10602 + unsigned int save, call, nop;
10603 +
10604 + err = get_user(save, (unsigned int *)(regs->pc-4));
10605 + err |= get_user(call, (unsigned int *)regs->pc);
10606 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10607 + if (err)
10608 + break;
10609 +
10610 + if (save == 0x9DE3BFA8U &&
10611 + (call & 0xC0000000U) == 0x40000000U &&
10612 + nop == 0x01000000U)
10613 + {
10614 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10615 +
10616 + regs->u_regs[UREG_RETPC] = regs->pc;
10617 + regs->pc = dl_resolve;
10618 + regs->npc = dl_resolve+4;
10619 + return 3;
10620 + }
10621 + } while (0);
10622 +#endif
10623 +
10624 + return 1;
10625 +}
10626 +
10627 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10628 +{
10629 + unsigned long i;
10630 +
10631 + printk(KERN_ERR "PAX: bytes at PC: ");
10632 + for (i = 0; i < 8; i++) {
10633 + unsigned int c;
10634 + if (get_user(c, (unsigned int *)pc+i))
10635 + printk(KERN_CONT "???????? ");
10636 + else
10637 + printk(KERN_CONT "%08x ", c);
10638 + }
10639 + printk("\n");
10640 +}
10641 +#endif
10642 +
10643 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10644 int text_fault)
10645 {
10646 @@ -230,6 +504,24 @@ good_area:
10647 if (!(vma->vm_flags & VM_WRITE))
10648 goto bad_area;
10649 } else {
10650 +
10651 +#ifdef CONFIG_PAX_PAGEEXEC
10652 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10653 + up_read(&mm->mmap_sem);
10654 + switch (pax_handle_fetch_fault(regs)) {
10655 +
10656 +#ifdef CONFIG_PAX_EMUPLT
10657 + case 2:
10658 + case 3:
10659 + return;
10660 +#endif
10661 +
10662 + }
10663 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10664 + do_group_exit(SIGKILL);
10665 + }
10666 +#endif
10667 +
10668 /* Allow reads even for write-only mappings */
10669 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10670 goto bad_area;
10671 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10672 index 5062ff3..e0b75f3 100644
10673 --- a/arch/sparc/mm/fault_64.c
10674 +++ b/arch/sparc/mm/fault_64.c
10675 @@ -21,6 +21,9 @@
10676 #include <linux/kprobes.h>
10677 #include <linux/kdebug.h>
10678 #include <linux/percpu.h>
10679 +#include <linux/slab.h>
10680 +#include <linux/pagemap.h>
10681 +#include <linux/compiler.h>
10682
10683 #include <asm/page.h>
10684 #include <asm/pgtable.h>
10685 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10686 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10687 regs->tpc);
10688 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10689 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10690 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10691 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10692 dump_stack();
10693 unhandled_fault(regs->tpc, current, regs);
10694 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10695 show_regs(regs);
10696 }
10697
10698 +#ifdef CONFIG_PAX_PAGEEXEC
10699 +#ifdef CONFIG_PAX_DLRESOLVE
10700 +static void pax_emuplt_close(struct vm_area_struct *vma)
10701 +{
10702 + vma->vm_mm->call_dl_resolve = 0UL;
10703 +}
10704 +
10705 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10706 +{
10707 + unsigned int *kaddr;
10708 +
10709 + vmf->page = alloc_page(GFP_HIGHUSER);
10710 + if (!vmf->page)
10711 + return VM_FAULT_OOM;
10712 +
10713 + kaddr = kmap(vmf->page);
10714 + memset(kaddr, 0, PAGE_SIZE);
10715 + kaddr[0] = 0x9DE3BFA8U; /* save */
10716 + flush_dcache_page(vmf->page);
10717 + kunmap(vmf->page);
10718 + return VM_FAULT_MAJOR;
10719 +}
10720 +
10721 +static const struct vm_operations_struct pax_vm_ops = {
10722 + .close = pax_emuplt_close,
10723 + .fault = pax_emuplt_fault
10724 +};
10725 +
10726 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10727 +{
10728 + int ret;
10729 +
10730 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10731 + vma->vm_mm = current->mm;
10732 + vma->vm_start = addr;
10733 + vma->vm_end = addr + PAGE_SIZE;
10734 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10735 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10736 + vma->vm_ops = &pax_vm_ops;
10737 +
10738 + ret = insert_vm_struct(current->mm, vma);
10739 + if (ret)
10740 + return ret;
10741 +
10742 + ++current->mm->total_vm;
10743 + return 0;
10744 +}
10745 +#endif
10746 +
10747 +/*
10748 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10749 + *
10750 + * returns 1 when task should be killed
10751 + * 2 when patched PLT trampoline was detected
10752 + * 3 when unpatched PLT trampoline was detected
10753 + */
10754 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10755 +{
10756 +
10757 +#ifdef CONFIG_PAX_EMUPLT
10758 + int err;
10759 +
10760 + do { /* PaX: patched PLT emulation #1 */
10761 + unsigned int sethi1, sethi2, jmpl;
10762 +
10763 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10764 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10765 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10766 +
10767 + if (err)
10768 + break;
10769 +
10770 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10771 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10772 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10773 + {
10774 + unsigned long addr;
10775 +
10776 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10777 + addr = regs->u_regs[UREG_G1];
10778 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10779 +
10780 + if (test_thread_flag(TIF_32BIT))
10781 + addr &= 0xFFFFFFFFUL;
10782 +
10783 + regs->tpc = addr;
10784 + regs->tnpc = addr+4;
10785 + return 2;
10786 + }
10787 + } while (0);
10788 +
10789 + do { /* PaX: patched PLT emulation #2 */
10790 + unsigned int ba;
10791 +
10792 + err = get_user(ba, (unsigned int *)regs->tpc);
10793 +
10794 + if (err)
10795 + break;
10796 +
10797 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10798 + unsigned long addr;
10799 +
10800 + if ((ba & 0xFFC00000U) == 0x30800000U)
10801 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10802 + else
10803 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10804 +
10805 + if (test_thread_flag(TIF_32BIT))
10806 + addr &= 0xFFFFFFFFUL;
10807 +
10808 + regs->tpc = addr;
10809 + regs->tnpc = addr+4;
10810 + return 2;
10811 + }
10812 + } while (0);
10813 +
10814 + do { /* PaX: patched PLT emulation #3 */
10815 + unsigned int sethi, bajmpl, nop;
10816 +
10817 + err = get_user(sethi, (unsigned int *)regs->tpc);
10818 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10819 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10820 +
10821 + if (err)
10822 + break;
10823 +
10824 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10825 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10826 + nop == 0x01000000U)
10827 + {
10828 + unsigned long addr;
10829 +
10830 + addr = (sethi & 0x003FFFFFU) << 10;
10831 + regs->u_regs[UREG_G1] = addr;
10832 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10833 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10834 + else
10835 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10836 +
10837 + if (test_thread_flag(TIF_32BIT))
10838 + addr &= 0xFFFFFFFFUL;
10839 +
10840 + regs->tpc = addr;
10841 + regs->tnpc = addr+4;
10842 + return 2;
10843 + }
10844 + } while (0);
10845 +
10846 + do { /* PaX: patched PLT emulation #4 */
10847 + unsigned int sethi, mov1, call, mov2;
10848 +
10849 + err = get_user(sethi, (unsigned int *)regs->tpc);
10850 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10851 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10852 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10853 +
10854 + if (err)
10855 + break;
10856 +
10857 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10858 + mov1 == 0x8210000FU &&
10859 + (call & 0xC0000000U) == 0x40000000U &&
10860 + mov2 == 0x9E100001U)
10861 + {
10862 + unsigned long addr;
10863 +
10864 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10865 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10866 +
10867 + if (test_thread_flag(TIF_32BIT))
10868 + addr &= 0xFFFFFFFFUL;
10869 +
10870 + regs->tpc = addr;
10871 + regs->tnpc = addr+4;
10872 + return 2;
10873 + }
10874 + } while (0);
10875 +
10876 + do { /* PaX: patched PLT emulation #5 */
10877 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10878 +
10879 + err = get_user(sethi, (unsigned int *)regs->tpc);
10880 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10881 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10882 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10883 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10884 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10885 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10886 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10887 +
10888 + if (err)
10889 + break;
10890 +
10891 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10892 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10893 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10894 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10895 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10896 + sllx == 0x83287020U &&
10897 + jmpl == 0x81C04005U &&
10898 + nop == 0x01000000U)
10899 + {
10900 + unsigned long addr;
10901 +
10902 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10903 + regs->u_regs[UREG_G1] <<= 32;
10904 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10905 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10906 + regs->tpc = addr;
10907 + regs->tnpc = addr+4;
10908 + return 2;
10909 + }
10910 + } while (0);
10911 +
10912 + do { /* PaX: patched PLT emulation #6 */
10913 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10914 +
10915 + err = get_user(sethi, (unsigned int *)regs->tpc);
10916 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10917 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10918 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10919 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10920 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10921 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10922 +
10923 + if (err)
10924 + break;
10925 +
10926 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10927 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10928 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10929 + sllx == 0x83287020U &&
10930 + (or & 0xFFFFE000U) == 0x8A116000U &&
10931 + jmpl == 0x81C04005U &&
10932 + nop == 0x01000000U)
10933 + {
10934 + unsigned long addr;
10935 +
10936 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10937 + regs->u_regs[UREG_G1] <<= 32;
10938 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10939 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10940 + regs->tpc = addr;
10941 + regs->tnpc = addr+4;
10942 + return 2;
10943 + }
10944 + } while (0);
10945 +
10946 + do { /* PaX: unpatched PLT emulation step 1 */
10947 + unsigned int sethi, ba, nop;
10948 +
10949 + err = get_user(sethi, (unsigned int *)regs->tpc);
10950 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10951 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10952 +
10953 + if (err)
10954 + break;
10955 +
10956 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10957 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10958 + nop == 0x01000000U)
10959 + {
10960 + unsigned long addr;
10961 + unsigned int save, call;
10962 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10963 +
10964 + if ((ba & 0xFFC00000U) == 0x30800000U)
10965 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10966 + else
10967 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10968 +
10969 + if (test_thread_flag(TIF_32BIT))
10970 + addr &= 0xFFFFFFFFUL;
10971 +
10972 + err = get_user(save, (unsigned int *)addr);
10973 + err |= get_user(call, (unsigned int *)(addr+4));
10974 + err |= get_user(nop, (unsigned int *)(addr+8));
10975 + if (err)
10976 + break;
10977 +
10978 +#ifdef CONFIG_PAX_DLRESOLVE
10979 + if (save == 0x9DE3BFA8U &&
10980 + (call & 0xC0000000U) == 0x40000000U &&
10981 + nop == 0x01000000U)
10982 + {
10983 + struct vm_area_struct *vma;
10984 + unsigned long call_dl_resolve;
10985 +
10986 + down_read(&current->mm->mmap_sem);
10987 + call_dl_resolve = current->mm->call_dl_resolve;
10988 + up_read(&current->mm->mmap_sem);
10989 + if (likely(call_dl_resolve))
10990 + goto emulate;
10991 +
10992 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10993 +
10994 + down_write(&current->mm->mmap_sem);
10995 + if (current->mm->call_dl_resolve) {
10996 + call_dl_resolve = current->mm->call_dl_resolve;
10997 + up_write(&current->mm->mmap_sem);
10998 + if (vma)
10999 + kmem_cache_free(vm_area_cachep, vma);
11000 + goto emulate;
11001 + }
11002 +
11003 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11004 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11005 + up_write(&current->mm->mmap_sem);
11006 + if (vma)
11007 + kmem_cache_free(vm_area_cachep, vma);
11008 + return 1;
11009 + }
11010 +
11011 + if (pax_insert_vma(vma, call_dl_resolve)) {
11012 + up_write(&current->mm->mmap_sem);
11013 + kmem_cache_free(vm_area_cachep, vma);
11014 + return 1;
11015 + }
11016 +
11017 + current->mm->call_dl_resolve = call_dl_resolve;
11018 + up_write(&current->mm->mmap_sem);
11019 +
11020 +emulate:
11021 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11022 + regs->tpc = call_dl_resolve;
11023 + regs->tnpc = addr+4;
11024 + return 3;
11025 + }
11026 +#endif
11027 +
11028 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11029 + if ((save & 0xFFC00000U) == 0x05000000U &&
11030 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11031 + nop == 0x01000000U)
11032 + {
11033 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11034 + regs->u_regs[UREG_G2] = addr + 4;
11035 + addr = (save & 0x003FFFFFU) << 10;
11036 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11037 +
11038 + if (test_thread_flag(TIF_32BIT))
11039 + addr &= 0xFFFFFFFFUL;
11040 +
11041 + regs->tpc = addr;
11042 + regs->tnpc = addr+4;
11043 + return 3;
11044 + }
11045 +
11046 + /* PaX: 64-bit PLT stub */
11047 + err = get_user(sethi1, (unsigned int *)addr);
11048 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11049 + err |= get_user(or1, (unsigned int *)(addr+8));
11050 + err |= get_user(or2, (unsigned int *)(addr+12));
11051 + err |= get_user(sllx, (unsigned int *)(addr+16));
11052 + err |= get_user(add, (unsigned int *)(addr+20));
11053 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11054 + err |= get_user(nop, (unsigned int *)(addr+28));
11055 + if (err)
11056 + break;
11057 +
11058 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11059 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11060 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11061 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11062 + sllx == 0x89293020U &&
11063 + add == 0x8A010005U &&
11064 + jmpl == 0x89C14000U &&
11065 + nop == 0x01000000U)
11066 + {
11067 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11068 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11069 + regs->u_regs[UREG_G4] <<= 32;
11070 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11071 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11072 + regs->u_regs[UREG_G4] = addr + 24;
11073 + addr = regs->u_regs[UREG_G5];
11074 + regs->tpc = addr;
11075 + regs->tnpc = addr+4;
11076 + return 3;
11077 + }
11078 + }
11079 + } while (0);
11080 +
11081 +#ifdef CONFIG_PAX_DLRESOLVE
11082 + do { /* PaX: unpatched PLT emulation step 2 */
11083 + unsigned int save, call, nop;
11084 +
11085 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11086 + err |= get_user(call, (unsigned int *)regs->tpc);
11087 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11088 + if (err)
11089 + break;
11090 +
11091 + if (save == 0x9DE3BFA8U &&
11092 + (call & 0xC0000000U) == 0x40000000U &&
11093 + nop == 0x01000000U)
11094 + {
11095 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11096 +
11097 + if (test_thread_flag(TIF_32BIT))
11098 + dl_resolve &= 0xFFFFFFFFUL;
11099 +
11100 + regs->u_regs[UREG_RETPC] = regs->tpc;
11101 + regs->tpc = dl_resolve;
11102 + regs->tnpc = dl_resolve+4;
11103 + return 3;
11104 + }
11105 + } while (0);
11106 +#endif
11107 +
11108 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11109 + unsigned int sethi, ba, nop;
11110 +
11111 + err = get_user(sethi, (unsigned int *)regs->tpc);
11112 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11113 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11114 +
11115 + if (err)
11116 + break;
11117 +
11118 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11119 + (ba & 0xFFF00000U) == 0x30600000U &&
11120 + nop == 0x01000000U)
11121 + {
11122 + unsigned long addr;
11123 +
11124 + addr = (sethi & 0x003FFFFFU) << 10;
11125 + regs->u_regs[UREG_G1] = addr;
11126 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11127 +
11128 + if (test_thread_flag(TIF_32BIT))
11129 + addr &= 0xFFFFFFFFUL;
11130 +
11131 + regs->tpc = addr;
11132 + regs->tnpc = addr+4;
11133 + return 2;
11134 + }
11135 + } while (0);
11136 +
11137 +#endif
11138 +
11139 + return 1;
11140 +}
11141 +
11142 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11143 +{
11144 + unsigned long i;
11145 +
11146 + printk(KERN_ERR "PAX: bytes at PC: ");
11147 + for (i = 0; i < 8; i++) {
11148 + unsigned int c;
11149 + if (get_user(c, (unsigned int *)pc+i))
11150 + printk(KERN_CONT "???????? ");
11151 + else
11152 + printk(KERN_CONT "%08x ", c);
11153 + }
11154 + printk("\n");
11155 +}
11156 +#endif
11157 +
11158 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11159 {
11160 struct mm_struct *mm = current->mm;
11161 @@ -341,6 +804,29 @@ retry:
11162 if (!vma)
11163 goto bad_area;
11164
11165 +#ifdef CONFIG_PAX_PAGEEXEC
11166 + /* PaX: detect ITLB misses on non-exec pages */
11167 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11168 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11169 + {
11170 + if (address != regs->tpc)
11171 + goto good_area;
11172 +
11173 + up_read(&mm->mmap_sem);
11174 + switch (pax_handle_fetch_fault(regs)) {
11175 +
11176 +#ifdef CONFIG_PAX_EMUPLT
11177 + case 2:
11178 + case 3:
11179 + return;
11180 +#endif
11181 +
11182 + }
11183 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11184 + do_group_exit(SIGKILL);
11185 + }
11186 +#endif
11187 +
11188 /* Pure DTLB misses do not tell us whether the fault causing
11189 * load/store/atomic was a write or not, it only says that there
11190 * was no match. So in such a case we (carefully) read the
11191 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11192 index d2b5944..d878f3c 100644
11193 --- a/arch/sparc/mm/hugetlbpage.c
11194 +++ b/arch/sparc/mm/hugetlbpage.c
11195 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11196 unsigned long addr,
11197 unsigned long len,
11198 unsigned long pgoff,
11199 - unsigned long flags)
11200 + unsigned long flags,
11201 + unsigned long offset)
11202 {
11203 unsigned long task_size = TASK_SIZE;
11204 struct vm_unmapped_area_info info;
11205 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11206
11207 info.flags = 0;
11208 info.length = len;
11209 - info.low_limit = TASK_UNMAPPED_BASE;
11210 + info.low_limit = mm->mmap_base;
11211 info.high_limit = min(task_size, VA_EXCLUDE_START);
11212 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11213 info.align_offset = 0;
11214 + info.threadstack_offset = offset;
11215 addr = vm_unmapped_area(&info);
11216
11217 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11218 VM_BUG_ON(addr != -ENOMEM);
11219 info.low_limit = VA_EXCLUDE_END;
11220 +
11221 +#ifdef CONFIG_PAX_RANDMMAP
11222 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11223 + info.low_limit += mm->delta_mmap;
11224 +#endif
11225 +
11226 info.high_limit = task_size;
11227 addr = vm_unmapped_area(&info);
11228 }
11229 @@ -58,7 +66,8 @@ static unsigned long
11230 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11231 const unsigned long len,
11232 const unsigned long pgoff,
11233 - const unsigned long flags)
11234 + const unsigned long flags,
11235 + const unsigned long offset)
11236 {
11237 struct mm_struct *mm = current->mm;
11238 unsigned long addr = addr0;
11239 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11240 info.high_limit = mm->mmap_base;
11241 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11242 info.align_offset = 0;
11243 + info.threadstack_offset = offset;
11244 addr = vm_unmapped_area(&info);
11245
11246 /*
11247 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11248 VM_BUG_ON(addr != -ENOMEM);
11249 info.flags = 0;
11250 info.low_limit = TASK_UNMAPPED_BASE;
11251 +
11252 +#ifdef CONFIG_PAX_RANDMMAP
11253 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11254 + info.low_limit += mm->delta_mmap;
11255 +#endif
11256 +
11257 info.high_limit = STACK_TOP32;
11258 addr = vm_unmapped_area(&info);
11259 }
11260 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11261 struct mm_struct *mm = current->mm;
11262 struct vm_area_struct *vma;
11263 unsigned long task_size = TASK_SIZE;
11264 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11265
11266 if (test_thread_flag(TIF_32BIT))
11267 task_size = STACK_TOP32;
11268 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11269 return addr;
11270 }
11271
11272 +#ifdef CONFIG_PAX_RANDMMAP
11273 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11274 +#endif
11275 +
11276 if (addr) {
11277 addr = ALIGN(addr, HPAGE_SIZE);
11278 vma = find_vma(mm, addr);
11279 - if (task_size - len >= addr &&
11280 - (!vma || addr + len <= vma->vm_start))
11281 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11282 return addr;
11283 }
11284 if (mm->get_unmapped_area == arch_get_unmapped_area)
11285 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11286 - pgoff, flags);
11287 + pgoff, flags, offset);
11288 else
11289 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11290 - pgoff, flags);
11291 + pgoff, flags, offset);
11292 }
11293
11294 pte_t *huge_pte_alloc(struct mm_struct *mm,
11295 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11296 index ed82eda..0d80e77 100644
11297 --- a/arch/sparc/mm/init_64.c
11298 +++ b/arch/sparc/mm/init_64.c
11299 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11300 int num_kernel_image_mappings;
11301
11302 #ifdef CONFIG_DEBUG_DCFLUSH
11303 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11304 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11305 #ifdef CONFIG_SMP
11306 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11307 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11308 #endif
11309 #endif
11310
11311 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11312 {
11313 BUG_ON(tlb_type == hypervisor);
11314 #ifdef CONFIG_DEBUG_DCFLUSH
11315 - atomic_inc(&dcpage_flushes);
11316 + atomic_inc_unchecked(&dcpage_flushes);
11317 #endif
11318
11319 #ifdef DCACHE_ALIASING_POSSIBLE
11320 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11321
11322 #ifdef CONFIG_DEBUG_DCFLUSH
11323 seq_printf(m, "DCPageFlushes\t: %d\n",
11324 - atomic_read(&dcpage_flushes));
11325 + atomic_read_unchecked(&dcpage_flushes));
11326 #ifdef CONFIG_SMP
11327 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11328 - atomic_read(&dcpage_flushes_xcall));
11329 + atomic_read_unchecked(&dcpage_flushes_xcall));
11330 #endif /* CONFIG_SMP */
11331 #endif /* CONFIG_DEBUG_DCFLUSH */
11332 }
11333 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11334 index f4500c6..889656c 100644
11335 --- a/arch/tile/include/asm/atomic_64.h
11336 +++ b/arch/tile/include/asm/atomic_64.h
11337 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11338
11339 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11340
11341 +#define atomic64_read_unchecked(v) atomic64_read(v)
11342 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11343 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11344 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11345 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11346 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11347 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11348 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11349 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11350 +
11351 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11352 #define smp_mb__before_atomic_dec() smp_mb()
11353 #define smp_mb__after_atomic_dec() smp_mb()
11354 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11355 index a9a5299..0fce79e 100644
11356 --- a/arch/tile/include/asm/cache.h
11357 +++ b/arch/tile/include/asm/cache.h
11358 @@ -15,11 +15,12 @@
11359 #ifndef _ASM_TILE_CACHE_H
11360 #define _ASM_TILE_CACHE_H
11361
11362 +#include <linux/const.h>
11363 #include <arch/chip.h>
11364
11365 /* bytes per L1 data cache line */
11366 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11367 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11368 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11369
11370 /* bytes per L2 cache line */
11371 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11372 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11373 index e4d44bd..99927a3 100644
11374 --- a/arch/tile/include/asm/uaccess.h
11375 +++ b/arch/tile/include/asm/uaccess.h
11376 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11377 const void __user *from,
11378 unsigned long n)
11379 {
11380 - int sz = __compiletime_object_size(to);
11381 + size_t sz = __compiletime_object_size(to);
11382
11383 - if (likely(sz == -1 || sz >= n))
11384 + if (likely(sz == (size_t)-1 || sz >= n))
11385 n = _copy_from_user(to, from, n);
11386 else
11387 copy_from_user_overflow();
11388 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11389 index 650ccff..45fe2d6 100644
11390 --- a/arch/tile/mm/hugetlbpage.c
11391 +++ b/arch/tile/mm/hugetlbpage.c
11392 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11393 info.high_limit = TASK_SIZE;
11394 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11395 info.align_offset = 0;
11396 + info.threadstack_offset = 0;
11397 return vm_unmapped_area(&info);
11398 }
11399
11400 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11401 info.high_limit = current->mm->mmap_base;
11402 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11403 info.align_offset = 0;
11404 + info.threadstack_offset = 0;
11405 addr = vm_unmapped_area(&info);
11406
11407 /*
11408 diff --git a/arch/um/Makefile b/arch/um/Makefile
11409 index 133f7de..1d6f2f1 100644
11410 --- a/arch/um/Makefile
11411 +++ b/arch/um/Makefile
11412 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11413 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11414 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11415
11416 +ifdef CONSTIFY_PLUGIN
11417 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11418 +endif
11419 +
11420 #This will adjust *FLAGS accordingly to the platform.
11421 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11422
11423 diff --git a/arch/um/defconfig b/arch/um/defconfig
11424 index 08107a7..ab22afe 100644
11425 --- a/arch/um/defconfig
11426 +++ b/arch/um/defconfig
11427 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11428 CONFIG_X86_L1_CACHE_SHIFT=5
11429 CONFIG_X86_XADD=y
11430 CONFIG_X86_PPRO_FENCE=y
11431 -CONFIG_X86_WP_WORKS_OK=y
11432 CONFIG_X86_INVLPG=y
11433 CONFIG_X86_BSWAP=y
11434 CONFIG_X86_POPAD_OK=y
11435 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11436 index 19e1bdd..3665b77 100644
11437 --- a/arch/um/include/asm/cache.h
11438 +++ b/arch/um/include/asm/cache.h
11439 @@ -1,6 +1,7 @@
11440 #ifndef __UM_CACHE_H
11441 #define __UM_CACHE_H
11442
11443 +#include <linux/const.h>
11444
11445 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11446 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11447 @@ -12,6 +13,6 @@
11448 # define L1_CACHE_SHIFT 5
11449 #endif
11450
11451 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11452 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11453
11454 #endif
11455 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11456 index 2e0a6b1..a64d0f5 100644
11457 --- a/arch/um/include/asm/kmap_types.h
11458 +++ b/arch/um/include/asm/kmap_types.h
11459 @@ -8,6 +8,6 @@
11460
11461 /* No more #include "asm/arch/kmap_types.h" ! */
11462
11463 -#define KM_TYPE_NR 14
11464 +#define KM_TYPE_NR 15
11465
11466 #endif
11467 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11468 index 5ff53d9..5850cdf 100644
11469 --- a/arch/um/include/asm/page.h
11470 +++ b/arch/um/include/asm/page.h
11471 @@ -14,6 +14,9 @@
11472 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11473 #define PAGE_MASK (~(PAGE_SIZE-1))
11474
11475 +#define ktla_ktva(addr) (addr)
11476 +#define ktva_ktla(addr) (addr)
11477 +
11478 #ifndef __ASSEMBLY__
11479
11480 struct page;
11481 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11482 index 0032f92..cd151e0 100644
11483 --- a/arch/um/include/asm/pgtable-3level.h
11484 +++ b/arch/um/include/asm/pgtable-3level.h
11485 @@ -58,6 +58,7 @@
11486 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11487 #define pud_populate(mm, pud, pmd) \
11488 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11489 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11490
11491 #ifdef CONFIG_64BIT
11492 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11493 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11494 index bbcef52..6a2a483 100644
11495 --- a/arch/um/kernel/process.c
11496 +++ b/arch/um/kernel/process.c
11497 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11498 return 2;
11499 }
11500
11501 -/*
11502 - * Only x86 and x86_64 have an arch_align_stack().
11503 - * All other arches have "#define arch_align_stack(x) (x)"
11504 - * in their asm/system.h
11505 - * As this is included in UML from asm-um/system-generic.h,
11506 - * we can use it to behave as the subarch does.
11507 - */
11508 -#ifndef arch_align_stack
11509 -unsigned long arch_align_stack(unsigned long sp)
11510 -{
11511 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11512 - sp -= get_random_int() % 8192;
11513 - return sp & ~0xf;
11514 -}
11515 -#endif
11516 -
11517 unsigned long get_wchan(struct task_struct *p)
11518 {
11519 unsigned long stack_page, sp, ip;
11520 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11521 index ad8f795..2c7eec6 100644
11522 --- a/arch/unicore32/include/asm/cache.h
11523 +++ b/arch/unicore32/include/asm/cache.h
11524 @@ -12,8 +12,10 @@
11525 #ifndef __UNICORE_CACHE_H__
11526 #define __UNICORE_CACHE_H__
11527
11528 -#define L1_CACHE_SHIFT (5)
11529 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11530 +#include <linux/const.h>
11531 +
11532 +#define L1_CACHE_SHIFT 5
11533 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11534
11535 /*
11536 * Memory returned by kmalloc() may be used for DMA, so we must make
11537 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11538 index b32ebf9..5704f98 100644
11539 --- a/arch/x86/Kconfig
11540 +++ b/arch/x86/Kconfig
11541 @@ -248,7 +248,7 @@ config X86_HT
11542
11543 config X86_32_LAZY_GS
11544 def_bool y
11545 - depends on X86_32 && !CC_STACKPROTECTOR
11546 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11547
11548 config ARCH_HWEIGHT_CFLAGS
11549 string
11550 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11551
11552 config X86_MSR
11553 tristate "/dev/cpu/*/msr - Model-specific register support"
11554 + depends on !GRKERNSEC_KMEM
11555 ---help---
11556 This device gives privileged processes access to the x86
11557 Model-Specific Registers (MSRs). It is a character device with
11558 @@ -1111,7 +1112,7 @@ choice
11559
11560 config NOHIGHMEM
11561 bool "off"
11562 - depends on !X86_NUMAQ
11563 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11564 ---help---
11565 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11566 However, the address space of 32-bit x86 processors is only 4
11567 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11568
11569 config HIGHMEM4G
11570 bool "4GB"
11571 - depends on !X86_NUMAQ
11572 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11573 ---help---
11574 Select this if you have a 32-bit processor and between 1 and 4
11575 gigabytes of physical RAM.
11576 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11577 hex
11578 default 0xB0000000 if VMSPLIT_3G_OPT
11579 default 0x80000000 if VMSPLIT_2G
11580 - default 0x78000000 if VMSPLIT_2G_OPT
11581 + default 0x70000000 if VMSPLIT_2G_OPT
11582 default 0x40000000 if VMSPLIT_1G
11583 default 0xC0000000
11584 depends on X86_32
11585 @@ -1599,6 +1600,7 @@ config SECCOMP
11586
11587 config CC_STACKPROTECTOR
11588 bool "Enable -fstack-protector buffer overflow detection"
11589 + depends on X86_64 || !PAX_MEMORY_UDEREF
11590 ---help---
11591 This option turns on the -fstack-protector GCC feature. This
11592 feature puts, at the beginning of functions, a canary value on
11593 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11594 config PHYSICAL_ALIGN
11595 hex "Alignment value to which kernel should be aligned" if X86_32
11596 default "0x1000000"
11597 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11598 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11599 range 0x2000 0x1000000
11600 ---help---
11601 This value puts the alignment restrictions on physical address
11602 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11603 If unsure, say N.
11604
11605 config COMPAT_VDSO
11606 - def_bool y
11607 + def_bool n
11608 prompt "Compat VDSO support"
11609 depends on X86_32 || IA32_EMULATION
11610 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11611 ---help---
11612 Map the 32-bit VDSO to the predictable old-style address too.
11613
11614 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11615 index c026cca..14657ae 100644
11616 --- a/arch/x86/Kconfig.cpu
11617 +++ b/arch/x86/Kconfig.cpu
11618 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11619
11620 config X86_F00F_BUG
11621 def_bool y
11622 - depends on M586MMX || M586TSC || M586 || M486
11623 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11624
11625 config X86_INVD_BUG
11626 def_bool y
11627 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11628
11629 config X86_ALIGNMENT_16
11630 def_bool y
11631 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11632 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11633
11634 config X86_INTEL_USERCOPY
11635 def_bool y
11636 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11637 # generates cmov.
11638 config X86_CMOV
11639 def_bool y
11640 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11641 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11642
11643 config X86_MINIMUM_CPU_FAMILY
11644 int
11645 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11646 index 78d91af..8ceb94b 100644
11647 --- a/arch/x86/Kconfig.debug
11648 +++ b/arch/x86/Kconfig.debug
11649 @@ -74,7 +74,7 @@ config X86_PTDUMP
11650 config DEBUG_RODATA
11651 bool "Write protect kernel read-only data structures"
11652 default y
11653 - depends on DEBUG_KERNEL
11654 + depends on DEBUG_KERNEL && BROKEN
11655 ---help---
11656 Mark the kernel read-only data as write-protected in the pagetables,
11657 in order to catch accidental (and incorrect) writes to such const
11658 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11659
11660 config DEBUG_SET_MODULE_RONX
11661 bool "Set loadable kernel module data as NX and text as RO"
11662 - depends on MODULES
11663 + depends on MODULES && BROKEN
11664 ---help---
11665 This option helps catch unintended modifications to loadable
11666 kernel module's text and read-only data. It also prevents execution
11667 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11668 index 07639c6..6f2c901 100644
11669 --- a/arch/x86/Makefile
11670 +++ b/arch/x86/Makefile
11671 @@ -54,6 +54,7 @@ else
11672 UTS_MACHINE := x86_64
11673 CHECKFLAGS += -D__x86_64__ -m64
11674
11675 + biarch := $(call cc-option,-m64)
11676 KBUILD_AFLAGS += -m64
11677 KBUILD_CFLAGS += -m64
11678
11679 @@ -241,3 +242,12 @@ define archhelp
11680 echo ' FDINITRD=file initrd for the booted kernel'
11681 echo ' kvmconfig - Enable additional options for guest kernel support'
11682 endef
11683 +
11684 +define OLD_LD
11685 +
11686 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11687 +*** Please upgrade your binutils to 2.18 or newer
11688 +endef
11689 +
11690 +archprepare:
11691 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11692 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11693 index 379814b..add62ce 100644
11694 --- a/arch/x86/boot/Makefile
11695 +++ b/arch/x86/boot/Makefile
11696 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11697 $(call cc-option, -fno-stack-protector) \
11698 $(call cc-option, -mpreferred-stack-boundary=2)
11699 KBUILD_CFLAGS += $(call cc-option, -m32)
11700 +ifdef CONSTIFY_PLUGIN
11701 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11702 +endif
11703 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11704 GCOV_PROFILE := n
11705
11706 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11707 index 878e4b9..20537ab 100644
11708 --- a/arch/x86/boot/bitops.h
11709 +++ b/arch/x86/boot/bitops.h
11710 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11711 u8 v;
11712 const u32 *p = (const u32 *)addr;
11713
11714 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11715 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11716 return v;
11717 }
11718
11719 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11720
11721 static inline void set_bit(int nr, void *addr)
11722 {
11723 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11724 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11725 }
11726
11727 #endif /* BOOT_BITOPS_H */
11728 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11729 index 5b75319..331a4ca 100644
11730 --- a/arch/x86/boot/boot.h
11731 +++ b/arch/x86/boot/boot.h
11732 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11733 static inline u16 ds(void)
11734 {
11735 u16 seg;
11736 - asm("movw %%ds,%0" : "=rm" (seg));
11737 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11738 return seg;
11739 }
11740
11741 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11742 static inline int memcmp(const void *s1, const void *s2, size_t len)
11743 {
11744 u8 diff;
11745 - asm("repe; cmpsb; setnz %0"
11746 + asm volatile("repe; cmpsb; setnz %0"
11747 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11748 return diff;
11749 }
11750 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11751 index dcd90df..c830d7d 100644
11752 --- a/arch/x86/boot/compressed/Makefile
11753 +++ b/arch/x86/boot/compressed/Makefile
11754 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11755 KBUILD_CFLAGS += $(cflags-y)
11756 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11757 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11758 +ifdef CONSTIFY_PLUGIN
11759 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11760 +endif
11761
11762 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11763 GCOV_PROFILE := n
11764 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11765 index b7388a4..03844ec 100644
11766 --- a/arch/x86/boot/compressed/eboot.c
11767 +++ b/arch/x86/boot/compressed/eboot.c
11768 @@ -150,7 +150,6 @@ again:
11769 *addr = max_addr;
11770 }
11771
11772 -free_pool:
11773 efi_call_phys1(sys_table->boottime->free_pool, map);
11774
11775 fail:
11776 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11777 if (i == map_size / desc_size)
11778 status = EFI_NOT_FOUND;
11779
11780 -free_pool:
11781 efi_call_phys1(sys_table->boottime->free_pool, map);
11782 fail:
11783 return status;
11784 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11785 index a53440e..c3dbf1e 100644
11786 --- a/arch/x86/boot/compressed/efi_stub_32.S
11787 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11788 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11789 * parameter 2, ..., param n. To make things easy, we save the return
11790 * address of efi_call_phys in a global variable.
11791 */
11792 - popl %ecx
11793 - movl %ecx, saved_return_addr(%edx)
11794 - /* get the function pointer into ECX*/
11795 - popl %ecx
11796 - movl %ecx, efi_rt_function_ptr(%edx)
11797 + popl saved_return_addr(%edx)
11798 + popl efi_rt_function_ptr(%edx)
11799
11800 /*
11801 * 3. Call the physical function.
11802 */
11803 - call *%ecx
11804 + call *efi_rt_function_ptr(%edx)
11805
11806 /*
11807 * 4. Balance the stack. And because EAX contain the return value,
11808 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11809 1: popl %edx
11810 subl $1b, %edx
11811
11812 - movl efi_rt_function_ptr(%edx), %ecx
11813 - pushl %ecx
11814 + pushl efi_rt_function_ptr(%edx)
11815
11816 /*
11817 * 10. Push the saved return address onto the stack and return.
11818 */
11819 - movl saved_return_addr(%edx), %ecx
11820 - pushl %ecx
11821 - ret
11822 + jmpl *saved_return_addr(%edx)
11823 ENDPROC(efi_call_phys)
11824 .previous
11825
11826 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11827 index 1e3184f..0d11e2e 100644
11828 --- a/arch/x86/boot/compressed/head_32.S
11829 +++ b/arch/x86/boot/compressed/head_32.S
11830 @@ -118,7 +118,7 @@ preferred_addr:
11831 notl %eax
11832 andl %eax, %ebx
11833 #else
11834 - movl $LOAD_PHYSICAL_ADDR, %ebx
11835 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11836 #endif
11837
11838 /* Target address to relocate to for decompression */
11839 @@ -204,7 +204,7 @@ relocated:
11840 * and where it was actually loaded.
11841 */
11842 movl %ebp, %ebx
11843 - subl $LOAD_PHYSICAL_ADDR, %ebx
11844 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11845 jz 2f /* Nothing to be done if loaded at compiled addr. */
11846 /*
11847 * Process relocations.
11848 @@ -212,8 +212,7 @@ relocated:
11849
11850 1: subl $4, %edi
11851 movl (%edi), %ecx
11852 - testl %ecx, %ecx
11853 - jz 2f
11854 + jecxz 2f
11855 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11856 jmp 1b
11857 2:
11858 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11859 index 06e71c2..88a98264 100644
11860 --- a/arch/x86/boot/compressed/head_64.S
11861 +++ b/arch/x86/boot/compressed/head_64.S
11862 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11863 notl %eax
11864 andl %eax, %ebx
11865 #else
11866 - movl $LOAD_PHYSICAL_ADDR, %ebx
11867 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11868 #endif
11869
11870 /* Target address to relocate to for decompression */
11871 @@ -270,7 +270,7 @@ preferred_addr:
11872 notq %rax
11873 andq %rax, %rbp
11874 #else
11875 - movq $LOAD_PHYSICAL_ADDR, %rbp
11876 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11877 #endif
11878
11879 /* Target address to relocate to for decompression */
11880 @@ -361,8 +361,8 @@ gdt:
11881 .long gdt
11882 .word 0
11883 .quad 0x0000000000000000 /* NULL descriptor */
11884 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11885 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11886 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11887 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11888 .quad 0x0080890000000000 /* TS descriptor */
11889 .quad 0x0000000000000000 /* TS continued */
11890 gdt_end:
11891 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11892 index 0319c88..7c1931f 100644
11893 --- a/arch/x86/boot/compressed/misc.c
11894 +++ b/arch/x86/boot/compressed/misc.c
11895 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11896 case PT_LOAD:
11897 #ifdef CONFIG_RELOCATABLE
11898 dest = output;
11899 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11900 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11901 #else
11902 dest = (void *)(phdr->p_paddr);
11903 #endif
11904 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11905 error("Destination address too large");
11906 #endif
11907 #ifndef CONFIG_RELOCATABLE
11908 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11909 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11910 error("Wrong destination address");
11911 #endif
11912
11913 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11914 index 4d3ff03..e4972ff 100644
11915 --- a/arch/x86/boot/cpucheck.c
11916 +++ b/arch/x86/boot/cpucheck.c
11917 @@ -74,7 +74,7 @@ static int has_fpu(void)
11918 u16 fcw = -1, fsw = -1;
11919 u32 cr0;
11920
11921 - asm("movl %%cr0,%0" : "=r" (cr0));
11922 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11923 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11924 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11925 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11926 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11927 {
11928 u32 f0, f1;
11929
11930 - asm("pushfl ; "
11931 + asm volatile("pushfl ; "
11932 "pushfl ; "
11933 "popl %0 ; "
11934 "movl %0,%1 ; "
11935 @@ -115,7 +115,7 @@ static void get_flags(void)
11936 set_bit(X86_FEATURE_FPU, cpu.flags);
11937
11938 if (has_eflag(X86_EFLAGS_ID)) {
11939 - asm("cpuid"
11940 + asm volatile("cpuid"
11941 : "=a" (max_intel_level),
11942 "=b" (cpu_vendor[0]),
11943 "=d" (cpu_vendor[1]),
11944 @@ -124,7 +124,7 @@ static void get_flags(void)
11945
11946 if (max_intel_level >= 0x00000001 &&
11947 max_intel_level <= 0x0000ffff) {
11948 - asm("cpuid"
11949 + asm volatile("cpuid"
11950 : "=a" (tfms),
11951 "=c" (cpu.flags[4]),
11952 "=d" (cpu.flags[0])
11953 @@ -136,7 +136,7 @@ static void get_flags(void)
11954 cpu.model += ((tfms >> 16) & 0xf) << 4;
11955 }
11956
11957 - asm("cpuid"
11958 + asm volatile("cpuid"
11959 : "=a" (max_amd_level)
11960 : "a" (0x80000000)
11961 : "ebx", "ecx", "edx");
11962 @@ -144,7 +144,7 @@ static void get_flags(void)
11963 if (max_amd_level >= 0x80000001 &&
11964 max_amd_level <= 0x8000ffff) {
11965 u32 eax = 0x80000001;
11966 - asm("cpuid"
11967 + asm volatile("cpuid"
11968 : "+a" (eax),
11969 "=c" (cpu.flags[6]),
11970 "=d" (cpu.flags[1])
11971 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11972 u32 ecx = MSR_K7_HWCR;
11973 u32 eax, edx;
11974
11975 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11976 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11977 eax &= ~(1 << 15);
11978 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11979 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11980
11981 get_flags(); /* Make sure it really did something */
11982 err = check_flags();
11983 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11984 u32 ecx = MSR_VIA_FCR;
11985 u32 eax, edx;
11986
11987 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11988 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11989 eax |= (1<<1)|(1<<7);
11990 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11991 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11992
11993 set_bit(X86_FEATURE_CX8, cpu.flags);
11994 err = check_flags();
11995 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11996 u32 eax, edx;
11997 u32 level = 1;
11998
11999 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12000 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12001 - asm("cpuid"
12002 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12003 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12004 + asm volatile("cpuid"
12005 : "+a" (level), "=d" (cpu.flags[0])
12006 : : "ecx", "ebx");
12007 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12008 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12009
12010 err = check_flags();
12011 }
12012 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12013 index 9ec06a1..2c25e79 100644
12014 --- a/arch/x86/boot/header.S
12015 +++ b/arch/x86/boot/header.S
12016 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12017 # single linked list of
12018 # struct setup_data
12019
12020 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12021 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12022
12023 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12024 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12025 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12026 +#else
12027 #define VO_INIT_SIZE (VO__end - VO__text)
12028 +#endif
12029 #if ZO_INIT_SIZE > VO_INIT_SIZE
12030 #define INIT_SIZE ZO_INIT_SIZE
12031 #else
12032 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12033 index db75d07..8e6d0af 100644
12034 --- a/arch/x86/boot/memory.c
12035 +++ b/arch/x86/boot/memory.c
12036 @@ -19,7 +19,7 @@
12037
12038 static int detect_memory_e820(void)
12039 {
12040 - int count = 0;
12041 + unsigned int count = 0;
12042 struct biosregs ireg, oreg;
12043 struct e820entry *desc = boot_params.e820_map;
12044 static struct e820entry buf; /* static so it is zeroed */
12045 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12046 index 11e8c6e..fdbb1ed 100644
12047 --- a/arch/x86/boot/video-vesa.c
12048 +++ b/arch/x86/boot/video-vesa.c
12049 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12050
12051 boot_params.screen_info.vesapm_seg = oreg.es;
12052 boot_params.screen_info.vesapm_off = oreg.di;
12053 + boot_params.screen_info.vesapm_size = oreg.cx;
12054 }
12055
12056 /*
12057 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12058 index 43eda28..5ab5fdb 100644
12059 --- a/arch/x86/boot/video.c
12060 +++ b/arch/x86/boot/video.c
12061 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12062 static unsigned int get_entry(void)
12063 {
12064 char entry_buf[4];
12065 - int i, len = 0;
12066 + unsigned int i, len = 0;
12067 int key;
12068 unsigned int v;
12069
12070 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12071 index 9105655..5e37f27 100644
12072 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12073 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12074 @@ -8,6 +8,8 @@
12075 * including this sentence is retained in full.
12076 */
12077
12078 +#include <asm/alternative-asm.h>
12079 +
12080 .extern crypto_ft_tab
12081 .extern crypto_it_tab
12082 .extern crypto_fl_tab
12083 @@ -70,6 +72,8 @@
12084 je B192; \
12085 leaq 32(r9),r9;
12086
12087 +#define ret pax_force_retaddr 0, 1; ret
12088 +
12089 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12090 movq r1,r2; \
12091 movq r3,r4; \
12092 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12093 index 477e9d7..3ab339f 100644
12094 --- a/arch/x86/crypto/aesni-intel_asm.S
12095 +++ b/arch/x86/crypto/aesni-intel_asm.S
12096 @@ -31,6 +31,7 @@
12097
12098 #include <linux/linkage.h>
12099 #include <asm/inst.h>
12100 +#include <asm/alternative-asm.h>
12101
12102 #ifdef __x86_64__
12103 .data
12104 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12105 pop %r14
12106 pop %r13
12107 pop %r12
12108 + pax_force_retaddr 0, 1
12109 ret
12110 ENDPROC(aesni_gcm_dec)
12111
12112 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12113 pop %r14
12114 pop %r13
12115 pop %r12
12116 + pax_force_retaddr 0, 1
12117 ret
12118 ENDPROC(aesni_gcm_enc)
12119
12120 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12121 pxor %xmm1, %xmm0
12122 movaps %xmm0, (TKEYP)
12123 add $0x10, TKEYP
12124 + pax_force_retaddr_bts
12125 ret
12126 ENDPROC(_key_expansion_128)
12127 ENDPROC(_key_expansion_256a)
12128 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12129 shufps $0b01001110, %xmm2, %xmm1
12130 movaps %xmm1, 0x10(TKEYP)
12131 add $0x20, TKEYP
12132 + pax_force_retaddr_bts
12133 ret
12134 ENDPROC(_key_expansion_192a)
12135
12136 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12137
12138 movaps %xmm0, (TKEYP)
12139 add $0x10, TKEYP
12140 + pax_force_retaddr_bts
12141 ret
12142 ENDPROC(_key_expansion_192b)
12143
12144 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12145 pxor %xmm1, %xmm2
12146 movaps %xmm2, (TKEYP)
12147 add $0x10, TKEYP
12148 + pax_force_retaddr_bts
12149 ret
12150 ENDPROC(_key_expansion_256b)
12151
12152 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12153 #ifndef __x86_64__
12154 popl KEYP
12155 #endif
12156 + pax_force_retaddr 0, 1
12157 ret
12158 ENDPROC(aesni_set_key)
12159
12160 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12161 popl KLEN
12162 popl KEYP
12163 #endif
12164 + pax_force_retaddr 0, 1
12165 ret
12166 ENDPROC(aesni_enc)
12167
12168 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12169 AESENC KEY STATE
12170 movaps 0x70(TKEYP), KEY
12171 AESENCLAST KEY STATE
12172 + pax_force_retaddr_bts
12173 ret
12174 ENDPROC(_aesni_enc1)
12175
12176 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12177 AESENCLAST KEY STATE2
12178 AESENCLAST KEY STATE3
12179 AESENCLAST KEY STATE4
12180 + pax_force_retaddr_bts
12181 ret
12182 ENDPROC(_aesni_enc4)
12183
12184 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12185 popl KLEN
12186 popl KEYP
12187 #endif
12188 + pax_force_retaddr 0, 1
12189 ret
12190 ENDPROC(aesni_dec)
12191
12192 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12193 AESDEC KEY STATE
12194 movaps 0x70(TKEYP), KEY
12195 AESDECLAST KEY STATE
12196 + pax_force_retaddr_bts
12197 ret
12198 ENDPROC(_aesni_dec1)
12199
12200 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12201 AESDECLAST KEY STATE2
12202 AESDECLAST KEY STATE3
12203 AESDECLAST KEY STATE4
12204 + pax_force_retaddr_bts
12205 ret
12206 ENDPROC(_aesni_dec4)
12207
12208 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12209 popl KEYP
12210 popl LEN
12211 #endif
12212 + pax_force_retaddr 0, 1
12213 ret
12214 ENDPROC(aesni_ecb_enc)
12215
12216 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12217 popl KEYP
12218 popl LEN
12219 #endif
12220 + pax_force_retaddr 0, 1
12221 ret
12222 ENDPROC(aesni_ecb_dec)
12223
12224 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12225 popl LEN
12226 popl IVP
12227 #endif
12228 + pax_force_retaddr 0, 1
12229 ret
12230 ENDPROC(aesni_cbc_enc)
12231
12232 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12233 popl LEN
12234 popl IVP
12235 #endif
12236 + pax_force_retaddr 0, 1
12237 ret
12238 ENDPROC(aesni_cbc_dec)
12239
12240 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12241 mov $1, TCTR_LOW
12242 MOVQ_R64_XMM TCTR_LOW INC
12243 MOVQ_R64_XMM CTR TCTR_LOW
12244 + pax_force_retaddr_bts
12245 ret
12246 ENDPROC(_aesni_inc_init)
12247
12248 @@ -2579,6 +2598,7 @@ _aesni_inc:
12249 .Linc_low:
12250 movaps CTR, IV
12251 PSHUFB_XMM BSWAP_MASK IV
12252 + pax_force_retaddr_bts
12253 ret
12254 ENDPROC(_aesni_inc)
12255
12256 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12257 .Lctr_enc_ret:
12258 movups IV, (IVP)
12259 .Lctr_enc_just_ret:
12260 + pax_force_retaddr 0, 1
12261 ret
12262 ENDPROC(aesni_ctr_enc)
12263
12264 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12265 pxor INC, STATE4
12266 movdqu STATE4, 0x70(OUTP)
12267
12268 + pax_force_retaddr 0, 1
12269 ret
12270 ENDPROC(aesni_xts_crypt8)
12271
12272 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12273 index 246c670..4d1ed00 100644
12274 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12275 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12276 @@ -21,6 +21,7 @@
12277 */
12278
12279 #include <linux/linkage.h>
12280 +#include <asm/alternative-asm.h>
12281
12282 .file "blowfish-x86_64-asm.S"
12283 .text
12284 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12285 jnz .L__enc_xor;
12286
12287 write_block();
12288 + pax_force_retaddr 0, 1
12289 ret;
12290 .L__enc_xor:
12291 xor_block();
12292 + pax_force_retaddr 0, 1
12293 ret;
12294 ENDPROC(__blowfish_enc_blk)
12295
12296 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12297
12298 movq %r11, %rbp;
12299
12300 + pax_force_retaddr 0, 1
12301 ret;
12302 ENDPROC(blowfish_dec_blk)
12303
12304 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12305
12306 popq %rbx;
12307 popq %rbp;
12308 + pax_force_retaddr 0, 1
12309 ret;
12310
12311 .L__enc_xor4:
12312 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12313
12314 popq %rbx;
12315 popq %rbp;
12316 + pax_force_retaddr 0, 1
12317 ret;
12318 ENDPROC(__blowfish_enc_blk_4way)
12319
12320 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12321 popq %rbx;
12322 popq %rbp;
12323
12324 + pax_force_retaddr 0, 1
12325 ret;
12326 ENDPROC(blowfish_dec_blk_4way)
12327 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12328 index ce71f92..2dd5b1e 100644
12329 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12330 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12331 @@ -16,6 +16,7 @@
12332 */
12333
12334 #include <linux/linkage.h>
12335 +#include <asm/alternative-asm.h>
12336
12337 #define CAMELLIA_TABLE_BYTE_LEN 272
12338
12339 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12340 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12341 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12342 %rcx, (%r9));
12343 + pax_force_retaddr_bts
12344 ret;
12345 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12346
12347 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12348 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12349 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12350 %rax, (%r9));
12351 + pax_force_retaddr_bts
12352 ret;
12353 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12354
12355 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12356 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12357 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12358
12359 + pax_force_retaddr_bts
12360 ret;
12361
12362 .align 8
12363 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12364 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12365 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12366
12367 + pax_force_retaddr_bts
12368 ret;
12369
12370 .align 8
12371 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12372 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12373 %xmm8, %rsi);
12374
12375 + pax_force_retaddr 0, 1
12376 ret;
12377 ENDPROC(camellia_ecb_enc_16way)
12378
12379 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12380 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12381 %xmm8, %rsi);
12382
12383 + pax_force_retaddr 0, 1
12384 ret;
12385 ENDPROC(camellia_ecb_dec_16way)
12386
12387 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12388 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12389 %xmm8, %rsi);
12390
12391 + pax_force_retaddr 0, 1
12392 ret;
12393 ENDPROC(camellia_cbc_dec_16way)
12394
12395 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12396 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12397 %xmm8, %rsi);
12398
12399 + pax_force_retaddr 0, 1
12400 ret;
12401 ENDPROC(camellia_ctr_16way)
12402
12403 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12404 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12405 %xmm8, %rsi);
12406
12407 + pax_force_retaddr 0, 1
12408 ret;
12409 ENDPROC(camellia_xts_crypt_16way)
12410
12411 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12412 index 0e0b886..8fc756a 100644
12413 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12414 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12415 @@ -11,6 +11,7 @@
12416 */
12417
12418 #include <linux/linkage.h>
12419 +#include <asm/alternative-asm.h>
12420
12421 #define CAMELLIA_TABLE_BYTE_LEN 272
12422
12423 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12424 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12425 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12426 %rcx, (%r9));
12427 + pax_force_retaddr_bts
12428 ret;
12429 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12430
12431 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12432 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12433 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12434 %rax, (%r9));
12435 + pax_force_retaddr_bts
12436 ret;
12437 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12438
12439 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12440 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12441 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12442
12443 + pax_force_retaddr_bts
12444 ret;
12445
12446 .align 8
12447 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12448 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12449 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12450
12451 + pax_force_retaddr_bts
12452 ret;
12453
12454 .align 8
12455 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12456
12457 vzeroupper;
12458
12459 + pax_force_retaddr 0, 1
12460 ret;
12461 ENDPROC(camellia_ecb_enc_32way)
12462
12463 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12464
12465 vzeroupper;
12466
12467 + pax_force_retaddr 0, 1
12468 ret;
12469 ENDPROC(camellia_ecb_dec_32way)
12470
12471 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12472
12473 vzeroupper;
12474
12475 + pax_force_retaddr 0, 1
12476 ret;
12477 ENDPROC(camellia_cbc_dec_32way)
12478
12479 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12480
12481 vzeroupper;
12482
12483 + pax_force_retaddr 0, 1
12484 ret;
12485 ENDPROC(camellia_ctr_32way)
12486
12487 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12488
12489 vzeroupper;
12490
12491 + pax_force_retaddr 0, 1
12492 ret;
12493 ENDPROC(camellia_xts_crypt_32way)
12494
12495 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12496 index 310319c..ce174a4 100644
12497 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12498 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12499 @@ -21,6 +21,7 @@
12500 */
12501
12502 #include <linux/linkage.h>
12503 +#include <asm/alternative-asm.h>
12504
12505 .file "camellia-x86_64-asm_64.S"
12506 .text
12507 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12508 enc_outunpack(mov, RT1);
12509
12510 movq RRBP, %rbp;
12511 + pax_force_retaddr 0, 1
12512 ret;
12513
12514 .L__enc_xor:
12515 enc_outunpack(xor, RT1);
12516
12517 movq RRBP, %rbp;
12518 + pax_force_retaddr 0, 1
12519 ret;
12520 ENDPROC(__camellia_enc_blk)
12521
12522 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12523 dec_outunpack();
12524
12525 movq RRBP, %rbp;
12526 + pax_force_retaddr 0, 1
12527 ret;
12528 ENDPROC(camellia_dec_blk)
12529
12530 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12531
12532 movq RRBP, %rbp;
12533 popq %rbx;
12534 + pax_force_retaddr 0, 1
12535 ret;
12536
12537 .L__enc2_xor:
12538 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12539
12540 movq RRBP, %rbp;
12541 popq %rbx;
12542 + pax_force_retaddr 0, 1
12543 ret;
12544 ENDPROC(__camellia_enc_blk_2way)
12545
12546 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12547
12548 movq RRBP, %rbp;
12549 movq RXOR, %rbx;
12550 + pax_force_retaddr 0, 1
12551 ret;
12552 ENDPROC(camellia_dec_blk_2way)
12553 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12554 index c35fd5d..c1ee236 100644
12555 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12556 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12557 @@ -24,6 +24,7 @@
12558 */
12559
12560 #include <linux/linkage.h>
12561 +#include <asm/alternative-asm.h>
12562
12563 .file "cast5-avx-x86_64-asm_64.S"
12564
12565 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12566 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12567 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12568
12569 + pax_force_retaddr 0, 1
12570 ret;
12571 ENDPROC(__cast5_enc_blk16)
12572
12573 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12574 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12575 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12576
12577 + pax_force_retaddr 0, 1
12578 ret;
12579
12580 .L__skip_dec:
12581 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12582 vmovdqu RR4, (6*4*4)(%r11);
12583 vmovdqu RL4, (7*4*4)(%r11);
12584
12585 + pax_force_retaddr
12586 ret;
12587 ENDPROC(cast5_ecb_enc_16way)
12588
12589 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12590 vmovdqu RR4, (6*4*4)(%r11);
12591 vmovdqu RL4, (7*4*4)(%r11);
12592
12593 + pax_force_retaddr
12594 ret;
12595 ENDPROC(cast5_ecb_dec_16way)
12596
12597 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12598
12599 popq %r12;
12600
12601 + pax_force_retaddr
12602 ret;
12603 ENDPROC(cast5_cbc_dec_16way)
12604
12605 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12606
12607 popq %r12;
12608
12609 + pax_force_retaddr
12610 ret;
12611 ENDPROC(cast5_ctr_16way)
12612 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12613 index e3531f8..18ded3a 100644
12614 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12615 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12616 @@ -24,6 +24,7 @@
12617 */
12618
12619 #include <linux/linkage.h>
12620 +#include <asm/alternative-asm.h>
12621 #include "glue_helper-asm-avx.S"
12622
12623 .file "cast6-avx-x86_64-asm_64.S"
12624 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12625 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12626 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12627
12628 + pax_force_retaddr 0, 1
12629 ret;
12630 ENDPROC(__cast6_enc_blk8)
12631
12632 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12633 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12634 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12635
12636 + pax_force_retaddr 0, 1
12637 ret;
12638 ENDPROC(__cast6_dec_blk8)
12639
12640 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12641
12642 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12643
12644 + pax_force_retaddr
12645 ret;
12646 ENDPROC(cast6_ecb_enc_8way)
12647
12648 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12649
12650 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12651
12652 + pax_force_retaddr
12653 ret;
12654 ENDPROC(cast6_ecb_dec_8way)
12655
12656 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12657
12658 popq %r12;
12659
12660 + pax_force_retaddr
12661 ret;
12662 ENDPROC(cast6_cbc_dec_8way)
12663
12664 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12665
12666 popq %r12;
12667
12668 + pax_force_retaddr
12669 ret;
12670 ENDPROC(cast6_ctr_8way)
12671
12672 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12673 /* dst <= regs xor IVs(in dst) */
12674 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12675
12676 + pax_force_retaddr
12677 ret;
12678 ENDPROC(cast6_xts_enc_8way)
12679
12680 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12681 /* dst <= regs xor IVs(in dst) */
12682 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12683
12684 + pax_force_retaddr
12685 ret;
12686 ENDPROC(cast6_xts_dec_8way)
12687 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12688 index dbc4339..3d868c5 100644
12689 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12690 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12691 @@ -45,6 +45,7 @@
12692
12693 #include <asm/inst.h>
12694 #include <linux/linkage.h>
12695 +#include <asm/alternative-asm.h>
12696
12697 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12698
12699 @@ -312,6 +313,7 @@ do_return:
12700 popq %rsi
12701 popq %rdi
12702 popq %rbx
12703 + pax_force_retaddr 0, 1
12704 ret
12705
12706 ################################################################
12707 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12708 index 586f41a..d02851e 100644
12709 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12710 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12711 @@ -18,6 +18,7 @@
12712
12713 #include <linux/linkage.h>
12714 #include <asm/inst.h>
12715 +#include <asm/alternative-asm.h>
12716
12717 .data
12718
12719 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12720 psrlq $1, T2
12721 pxor T2, T1
12722 pxor T1, DATA
12723 + pax_force_retaddr
12724 ret
12725 ENDPROC(__clmul_gf128mul_ble)
12726
12727 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12728 call __clmul_gf128mul_ble
12729 PSHUFB_XMM BSWAP DATA
12730 movups DATA, (%rdi)
12731 + pax_force_retaddr
12732 ret
12733 ENDPROC(clmul_ghash_mul)
12734
12735 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12736 PSHUFB_XMM BSWAP DATA
12737 movups DATA, (%rdi)
12738 .Lupdate_just_ret:
12739 + pax_force_retaddr
12740 ret
12741 ENDPROC(clmul_ghash_update)
12742
12743 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12744 pand .Lpoly, %xmm1
12745 pxor %xmm1, %xmm0
12746 movups %xmm0, (%rdi)
12747 + pax_force_retaddr
12748 ret
12749 ENDPROC(clmul_ghash_setkey)
12750 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12751 index 9279e0b..9270820 100644
12752 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12753 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12754 @@ -1,4 +1,5 @@
12755 #include <linux/linkage.h>
12756 +#include <asm/alternative-asm.h>
12757
12758 # enter salsa20_encrypt_bytes
12759 ENTRY(salsa20_encrypt_bytes)
12760 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12761 add %r11,%rsp
12762 mov %rdi,%rax
12763 mov %rsi,%rdx
12764 + pax_force_retaddr 0, 1
12765 ret
12766 # bytesatleast65:
12767 ._bytesatleast65:
12768 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12769 add %r11,%rsp
12770 mov %rdi,%rax
12771 mov %rsi,%rdx
12772 + pax_force_retaddr
12773 ret
12774 ENDPROC(salsa20_keysetup)
12775
12776 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12777 add %r11,%rsp
12778 mov %rdi,%rax
12779 mov %rsi,%rdx
12780 + pax_force_retaddr
12781 ret
12782 ENDPROC(salsa20_ivsetup)
12783 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12784 index 2f202f4..d9164d6 100644
12785 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12786 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12787 @@ -24,6 +24,7 @@
12788 */
12789
12790 #include <linux/linkage.h>
12791 +#include <asm/alternative-asm.h>
12792 #include "glue_helper-asm-avx.S"
12793
12794 .file "serpent-avx-x86_64-asm_64.S"
12795 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12796 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12797 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12798
12799 + pax_force_retaddr
12800 ret;
12801 ENDPROC(__serpent_enc_blk8_avx)
12802
12803 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12804 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12805 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12806
12807 + pax_force_retaddr
12808 ret;
12809 ENDPROC(__serpent_dec_blk8_avx)
12810
12811 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12812
12813 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12814
12815 + pax_force_retaddr
12816 ret;
12817 ENDPROC(serpent_ecb_enc_8way_avx)
12818
12819 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12820
12821 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12822
12823 + pax_force_retaddr
12824 ret;
12825 ENDPROC(serpent_ecb_dec_8way_avx)
12826
12827 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12828
12829 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12830
12831 + pax_force_retaddr
12832 ret;
12833 ENDPROC(serpent_cbc_dec_8way_avx)
12834
12835 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12836
12837 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12838
12839 + pax_force_retaddr
12840 ret;
12841 ENDPROC(serpent_ctr_8way_avx)
12842
12843 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12844 /* dst <= regs xor IVs(in dst) */
12845 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12846
12847 + pax_force_retaddr
12848 ret;
12849 ENDPROC(serpent_xts_enc_8way_avx)
12850
12851 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12852 /* dst <= regs xor IVs(in dst) */
12853 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12854
12855 + pax_force_retaddr
12856 ret;
12857 ENDPROC(serpent_xts_dec_8way_avx)
12858 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12859 index b222085..abd483c 100644
12860 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12861 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12862 @@ -15,6 +15,7 @@
12863 */
12864
12865 #include <linux/linkage.h>
12866 +#include <asm/alternative-asm.h>
12867 #include "glue_helper-asm-avx2.S"
12868
12869 .file "serpent-avx2-asm_64.S"
12870 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12871 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12872 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12873
12874 + pax_force_retaddr
12875 ret;
12876 ENDPROC(__serpent_enc_blk16)
12877
12878 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12879 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12880 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12881
12882 + pax_force_retaddr
12883 ret;
12884 ENDPROC(__serpent_dec_blk16)
12885
12886 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12887
12888 vzeroupper;
12889
12890 + pax_force_retaddr
12891 ret;
12892 ENDPROC(serpent_ecb_enc_16way)
12893
12894 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12895
12896 vzeroupper;
12897
12898 + pax_force_retaddr
12899 ret;
12900 ENDPROC(serpent_ecb_dec_16way)
12901
12902 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12903
12904 vzeroupper;
12905
12906 + pax_force_retaddr
12907 ret;
12908 ENDPROC(serpent_cbc_dec_16way)
12909
12910 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12911
12912 vzeroupper;
12913
12914 + pax_force_retaddr
12915 ret;
12916 ENDPROC(serpent_ctr_16way)
12917
12918 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12919
12920 vzeroupper;
12921
12922 + pax_force_retaddr
12923 ret;
12924 ENDPROC(serpent_xts_enc_16way)
12925
12926 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12927
12928 vzeroupper;
12929
12930 + pax_force_retaddr
12931 ret;
12932 ENDPROC(serpent_xts_dec_16way)
12933 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12934 index acc066c..1559cc4 100644
12935 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12936 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12937 @@ -25,6 +25,7 @@
12938 */
12939
12940 #include <linux/linkage.h>
12941 +#include <asm/alternative-asm.h>
12942
12943 .file "serpent-sse2-x86_64-asm_64.S"
12944 .text
12945 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12946 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12947 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12948
12949 + pax_force_retaddr
12950 ret;
12951
12952 .L__enc_xor8:
12953 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12954 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12955
12956 + pax_force_retaddr
12957 ret;
12958 ENDPROC(__serpent_enc_blk_8way)
12959
12960 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12961 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12962 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12963
12964 + pax_force_retaddr
12965 ret;
12966 ENDPROC(serpent_dec_blk_8way)
12967 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12968 index a410950..3356d42 100644
12969 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12970 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12971 @@ -29,6 +29,7 @@
12972 */
12973
12974 #include <linux/linkage.h>
12975 +#include <asm/alternative-asm.h>
12976
12977 #define CTX %rdi // arg1
12978 #define BUF %rsi // arg2
12979 @@ -104,6 +105,7 @@
12980 pop %r12
12981 pop %rbp
12982 pop %rbx
12983 + pax_force_retaddr 0, 1
12984 ret
12985
12986 ENDPROC(\name)
12987 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12988 index 642f156..4ab07b9 100644
12989 --- a/arch/x86/crypto/sha256-avx-asm.S
12990 +++ b/arch/x86/crypto/sha256-avx-asm.S
12991 @@ -49,6 +49,7 @@
12992
12993 #ifdef CONFIG_AS_AVX
12994 #include <linux/linkage.h>
12995 +#include <asm/alternative-asm.h>
12996
12997 ## assume buffers not aligned
12998 #define VMOVDQ vmovdqu
12999 @@ -460,6 +461,7 @@ done_hash:
13000 popq %r13
13001 popq %rbp
13002 popq %rbx
13003 + pax_force_retaddr 0, 1
13004 ret
13005 ENDPROC(sha256_transform_avx)
13006
13007 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13008 index 9e86944..2e7f95a 100644
13009 --- a/arch/x86/crypto/sha256-avx2-asm.S
13010 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13011 @@ -50,6 +50,7 @@
13012
13013 #ifdef CONFIG_AS_AVX2
13014 #include <linux/linkage.h>
13015 +#include <asm/alternative-asm.h>
13016
13017 ## assume buffers not aligned
13018 #define VMOVDQ vmovdqu
13019 @@ -720,6 +721,7 @@ done_hash:
13020 popq %r12
13021 popq %rbp
13022 popq %rbx
13023 + pax_force_retaddr 0, 1
13024 ret
13025 ENDPROC(sha256_transform_rorx)
13026
13027 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13028 index f833b74..c36ed14 100644
13029 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13030 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13031 @@ -47,6 +47,7 @@
13032 ########################################################################
13033
13034 #include <linux/linkage.h>
13035 +#include <asm/alternative-asm.h>
13036
13037 ## assume buffers not aligned
13038 #define MOVDQ movdqu
13039 @@ -471,6 +472,7 @@ done_hash:
13040 popq %rbp
13041 popq %rbx
13042
13043 + pax_force_retaddr 0, 1
13044 ret
13045 ENDPROC(sha256_transform_ssse3)
13046
13047 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13048 index 974dde9..4533d34 100644
13049 --- a/arch/x86/crypto/sha512-avx-asm.S
13050 +++ b/arch/x86/crypto/sha512-avx-asm.S
13051 @@ -49,6 +49,7 @@
13052
13053 #ifdef CONFIG_AS_AVX
13054 #include <linux/linkage.h>
13055 +#include <asm/alternative-asm.h>
13056
13057 .text
13058
13059 @@ -364,6 +365,7 @@ updateblock:
13060 mov frame_RSPSAVE(%rsp), %rsp
13061
13062 nowork:
13063 + pax_force_retaddr 0, 1
13064 ret
13065 ENDPROC(sha512_transform_avx)
13066
13067 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13068 index 568b961..061ef1d 100644
13069 --- a/arch/x86/crypto/sha512-avx2-asm.S
13070 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13071 @@ -51,6 +51,7 @@
13072
13073 #ifdef CONFIG_AS_AVX2
13074 #include <linux/linkage.h>
13075 +#include <asm/alternative-asm.h>
13076
13077 .text
13078
13079 @@ -678,6 +679,7 @@ done_hash:
13080
13081 # Restore Stack Pointer
13082 mov frame_RSPSAVE(%rsp), %rsp
13083 + pax_force_retaddr 0, 1
13084 ret
13085 ENDPROC(sha512_transform_rorx)
13086
13087 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13088 index fb56855..e23914f 100644
13089 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13090 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13091 @@ -48,6 +48,7 @@
13092 ########################################################################
13093
13094 #include <linux/linkage.h>
13095 +#include <asm/alternative-asm.h>
13096
13097 .text
13098
13099 @@ -363,6 +364,7 @@ updateblock:
13100 mov frame_RSPSAVE(%rsp), %rsp
13101
13102 nowork:
13103 + pax_force_retaddr 0, 1
13104 ret
13105 ENDPROC(sha512_transform_ssse3)
13106
13107 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13108 index 0505813..63b1d00 100644
13109 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13110 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13111 @@ -24,6 +24,7 @@
13112 */
13113
13114 #include <linux/linkage.h>
13115 +#include <asm/alternative-asm.h>
13116 #include "glue_helper-asm-avx.S"
13117
13118 .file "twofish-avx-x86_64-asm_64.S"
13119 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13120 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13121 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13122
13123 + pax_force_retaddr 0, 1
13124 ret;
13125 ENDPROC(__twofish_enc_blk8)
13126
13127 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13128 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13129 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13130
13131 + pax_force_retaddr 0, 1
13132 ret;
13133 ENDPROC(__twofish_dec_blk8)
13134
13135 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13136
13137 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13138
13139 + pax_force_retaddr 0, 1
13140 ret;
13141 ENDPROC(twofish_ecb_enc_8way)
13142
13143 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13144
13145 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13146
13147 + pax_force_retaddr 0, 1
13148 ret;
13149 ENDPROC(twofish_ecb_dec_8way)
13150
13151 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13152
13153 popq %r12;
13154
13155 + pax_force_retaddr 0, 1
13156 ret;
13157 ENDPROC(twofish_cbc_dec_8way)
13158
13159 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13160
13161 popq %r12;
13162
13163 + pax_force_retaddr 0, 1
13164 ret;
13165 ENDPROC(twofish_ctr_8way)
13166
13167 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13168 /* dst <= regs xor IVs(in dst) */
13169 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13170
13171 + pax_force_retaddr 0, 1
13172 ret;
13173 ENDPROC(twofish_xts_enc_8way)
13174
13175 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13176 /* dst <= regs xor IVs(in dst) */
13177 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13178
13179 + pax_force_retaddr 0, 1
13180 ret;
13181 ENDPROC(twofish_xts_dec_8way)
13182 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13183 index 1c3b7ce..b365c5e 100644
13184 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13185 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13186 @@ -21,6 +21,7 @@
13187 */
13188
13189 #include <linux/linkage.h>
13190 +#include <asm/alternative-asm.h>
13191
13192 .file "twofish-x86_64-asm-3way.S"
13193 .text
13194 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13195 popq %r13;
13196 popq %r14;
13197 popq %r15;
13198 + pax_force_retaddr 0, 1
13199 ret;
13200
13201 .L__enc_xor3:
13202 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13203 popq %r13;
13204 popq %r14;
13205 popq %r15;
13206 + pax_force_retaddr 0, 1
13207 ret;
13208 ENDPROC(__twofish_enc_blk_3way)
13209
13210 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13211 popq %r13;
13212 popq %r14;
13213 popq %r15;
13214 + pax_force_retaddr 0, 1
13215 ret;
13216 ENDPROC(twofish_dec_blk_3way)
13217 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13218 index a039d21..29e7615 100644
13219 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13220 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13221 @@ -22,6 +22,7 @@
13222
13223 #include <linux/linkage.h>
13224 #include <asm/asm-offsets.h>
13225 +#include <asm/alternative-asm.h>
13226
13227 #define a_offset 0
13228 #define b_offset 4
13229 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13230
13231 popq R1
13232 movq $1,%rax
13233 + pax_force_retaddr 0, 1
13234 ret
13235 ENDPROC(twofish_enc_blk)
13236
13237 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13238
13239 popq R1
13240 movq $1,%rax
13241 + pax_force_retaddr 0, 1
13242 ret
13243 ENDPROC(twofish_dec_blk)
13244 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13245 index bae3aba..c1788c1 100644
13246 --- a/arch/x86/ia32/ia32_aout.c
13247 +++ b/arch/x86/ia32/ia32_aout.c
13248 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13249 unsigned long dump_start, dump_size;
13250 struct user32 dump;
13251
13252 + memset(&dump, 0, sizeof(dump));
13253 +
13254 fs = get_fs();
13255 set_fs(KERNEL_DS);
13256 has_dumped = 1;
13257 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13258 index 665a730..8e7a67a 100644
13259 --- a/arch/x86/ia32/ia32_signal.c
13260 +++ b/arch/x86/ia32/ia32_signal.c
13261 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13262 sp -= frame_size;
13263 /* Align the stack pointer according to the i386 ABI,
13264 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13265 - sp = ((sp + 4) & -16ul) - 4;
13266 + sp = ((sp - 12) & -16ul) - 4;
13267 return (void __user *) sp;
13268 }
13269
13270 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13271 * These are actually not used anymore, but left because some
13272 * gdb versions depend on them as a marker.
13273 */
13274 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13275 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13276 } put_user_catch(err);
13277
13278 if (err)
13279 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13280 0xb8,
13281 __NR_ia32_rt_sigreturn,
13282 0x80cd,
13283 - 0,
13284 + 0
13285 };
13286
13287 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13288 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13289
13290 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13291 restorer = ksig->ka.sa.sa_restorer;
13292 + else if (current->mm->context.vdso)
13293 + /* Return stub is in 32bit vsyscall page */
13294 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13295 else
13296 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13297 - rt_sigreturn);
13298 + restorer = &frame->retcode;
13299 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13300
13301 /*
13302 * Not actually used anymore, but left because some gdb
13303 * versions need it.
13304 */
13305 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13306 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13307 } put_user_catch(err);
13308
13309 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13310 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13311 index 474dc1b..9297c58 100644
13312 --- a/arch/x86/ia32/ia32entry.S
13313 +++ b/arch/x86/ia32/ia32entry.S
13314 @@ -15,8 +15,10 @@
13315 #include <asm/irqflags.h>
13316 #include <asm/asm.h>
13317 #include <asm/smap.h>
13318 +#include <asm/pgtable.h>
13319 #include <linux/linkage.h>
13320 #include <linux/err.h>
13321 +#include <asm/alternative-asm.h>
13322
13323 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13324 #include <linux/elf-em.h>
13325 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13326 ENDPROC(native_irq_enable_sysexit)
13327 #endif
13328
13329 + .macro pax_enter_kernel_user
13330 + pax_set_fptr_mask
13331 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13332 + call pax_enter_kernel_user
13333 +#endif
13334 + .endm
13335 +
13336 + .macro pax_exit_kernel_user
13337 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13338 + call pax_exit_kernel_user
13339 +#endif
13340 +#ifdef CONFIG_PAX_RANDKSTACK
13341 + pushq %rax
13342 + pushq %r11
13343 + call pax_randomize_kstack
13344 + popq %r11
13345 + popq %rax
13346 +#endif
13347 + .endm
13348 +
13349 + .macro pax_erase_kstack
13350 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13351 + call pax_erase_kstack
13352 +#endif
13353 + .endm
13354 +
13355 /*
13356 * 32bit SYSENTER instruction entry.
13357 *
13358 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13359 CFI_REGISTER rsp,rbp
13360 SWAPGS_UNSAFE_STACK
13361 movq PER_CPU_VAR(kernel_stack), %rsp
13362 - addq $(KERNEL_STACK_OFFSET),%rsp
13363 - /*
13364 - * No need to follow this irqs on/off section: the syscall
13365 - * disabled irqs, here we enable it straight after entry:
13366 - */
13367 - ENABLE_INTERRUPTS(CLBR_NONE)
13368 movl %ebp,%ebp /* zero extension */
13369 pushq_cfi $__USER32_DS
13370 /*CFI_REL_OFFSET ss,0*/
13371 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13372 CFI_REL_OFFSET rsp,0
13373 pushfq_cfi
13374 /*CFI_REL_OFFSET rflags,0*/
13375 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13376 - CFI_REGISTER rip,r10
13377 + orl $X86_EFLAGS_IF,(%rsp)
13378 + GET_THREAD_INFO(%r11)
13379 + movl TI_sysenter_return(%r11), %r11d
13380 + CFI_REGISTER rip,r11
13381 pushq_cfi $__USER32_CS
13382 /*CFI_REL_OFFSET cs,0*/
13383 movl %eax, %eax
13384 - pushq_cfi %r10
13385 + pushq_cfi %r11
13386 CFI_REL_OFFSET rip,0
13387 pushq_cfi %rax
13388 cld
13389 SAVE_ARGS 0,1,0
13390 + pax_enter_kernel_user
13391 +
13392 +#ifdef CONFIG_PAX_RANDKSTACK
13393 + pax_erase_kstack
13394 +#endif
13395 +
13396 + /*
13397 + * No need to follow this irqs on/off section: the syscall
13398 + * disabled irqs, here we enable it straight after entry:
13399 + */
13400 + ENABLE_INTERRUPTS(CLBR_NONE)
13401 /* no need to do an access_ok check here because rbp has been
13402 32bit zero extended */
13403 +
13404 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13405 + addq pax_user_shadow_base,%rbp
13406 + ASM_PAX_OPEN_USERLAND
13407 +#endif
13408 +
13409 ASM_STAC
13410 1: movl (%rbp),%ebp
13411 _ASM_EXTABLE(1b,ia32_badarg)
13412 ASM_CLAC
13413 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13414 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13415 +
13416 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13417 + ASM_PAX_CLOSE_USERLAND
13418 +#endif
13419 +
13420 + GET_THREAD_INFO(%r11)
13421 + orl $TS_COMPAT,TI_status(%r11)
13422 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13423 CFI_REMEMBER_STATE
13424 jnz sysenter_tracesys
13425 cmpq $(IA32_NR_syscalls-1),%rax
13426 @@ -162,12 +209,15 @@ sysenter_do_call:
13427 sysenter_dispatch:
13428 call *ia32_sys_call_table(,%rax,8)
13429 movq %rax,RAX-ARGOFFSET(%rsp)
13430 + GET_THREAD_INFO(%r11)
13431 DISABLE_INTERRUPTS(CLBR_NONE)
13432 TRACE_IRQS_OFF
13433 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13434 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13435 jnz sysexit_audit
13436 sysexit_from_sys_call:
13437 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13438 + pax_exit_kernel_user
13439 + pax_erase_kstack
13440 + andl $~TS_COMPAT,TI_status(%r11)
13441 /* clear IF, that popfq doesn't enable interrupts early */
13442 andl $~0x200,EFLAGS-R11(%rsp)
13443 movl RIP-R11(%rsp),%edx /* User %eip */
13444 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13445 movl %eax,%esi /* 2nd arg: syscall number */
13446 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13447 call __audit_syscall_entry
13448 +
13449 + pax_erase_kstack
13450 +
13451 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13452 cmpq $(IA32_NR_syscalls-1),%rax
13453 ja ia32_badsys
13454 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13455 .endm
13456
13457 .macro auditsys_exit exit
13458 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13459 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13460 jnz ia32_ret_from_sys_call
13461 TRACE_IRQS_ON
13462 ENABLE_INTERRUPTS(CLBR_NONE)
13463 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13464 1: setbe %al /* 1 if error, 0 if not */
13465 movzbl %al,%edi /* zero-extend that into %edi */
13466 call __audit_syscall_exit
13467 + GET_THREAD_INFO(%r11)
13468 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13469 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13470 DISABLE_INTERRUPTS(CLBR_NONE)
13471 TRACE_IRQS_OFF
13472 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13473 + testl %edi,TI_flags(%r11)
13474 jz \exit
13475 CLEAR_RREGS -ARGOFFSET
13476 jmp int_with_check
13477 @@ -237,7 +291,7 @@ sysexit_audit:
13478
13479 sysenter_tracesys:
13480 #ifdef CONFIG_AUDITSYSCALL
13481 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13482 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13483 jz sysenter_auditsys
13484 #endif
13485 SAVE_REST
13486 @@ -249,6 +303,9 @@ sysenter_tracesys:
13487 RESTORE_REST
13488 cmpq $(IA32_NR_syscalls-1),%rax
13489 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13490 +
13491 + pax_erase_kstack
13492 +
13493 jmp sysenter_do_call
13494 CFI_ENDPROC
13495 ENDPROC(ia32_sysenter_target)
13496 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13497 ENTRY(ia32_cstar_target)
13498 CFI_STARTPROC32 simple
13499 CFI_SIGNAL_FRAME
13500 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13501 + CFI_DEF_CFA rsp,0
13502 CFI_REGISTER rip,rcx
13503 /*CFI_REGISTER rflags,r11*/
13504 SWAPGS_UNSAFE_STACK
13505 movl %esp,%r8d
13506 CFI_REGISTER rsp,r8
13507 movq PER_CPU_VAR(kernel_stack),%rsp
13508 + SAVE_ARGS 8*6,0,0
13509 + pax_enter_kernel_user
13510 +
13511 +#ifdef CONFIG_PAX_RANDKSTACK
13512 + pax_erase_kstack
13513 +#endif
13514 +
13515 /*
13516 * No need to follow this irqs on/off section: the syscall
13517 * disabled irqs and here we enable it straight after entry:
13518 */
13519 ENABLE_INTERRUPTS(CLBR_NONE)
13520 - SAVE_ARGS 8,0,0
13521 movl %eax,%eax /* zero extension */
13522 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13523 movq %rcx,RIP-ARGOFFSET(%rsp)
13524 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13525 /* no need to do an access_ok check here because r8 has been
13526 32bit zero extended */
13527 /* hardware stack frame is complete now */
13528 +
13529 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13530 + ASM_PAX_OPEN_USERLAND
13531 + movq pax_user_shadow_base,%r8
13532 + addq RSP-ARGOFFSET(%rsp),%r8
13533 +#endif
13534 +
13535 ASM_STAC
13536 1: movl (%r8),%r9d
13537 _ASM_EXTABLE(1b,ia32_badarg)
13538 ASM_CLAC
13539 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13540 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13541 +
13542 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13543 + ASM_PAX_CLOSE_USERLAND
13544 +#endif
13545 +
13546 + GET_THREAD_INFO(%r11)
13547 + orl $TS_COMPAT,TI_status(%r11)
13548 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13549 CFI_REMEMBER_STATE
13550 jnz cstar_tracesys
13551 cmpq $IA32_NR_syscalls-1,%rax
13552 @@ -319,12 +395,15 @@ cstar_do_call:
13553 cstar_dispatch:
13554 call *ia32_sys_call_table(,%rax,8)
13555 movq %rax,RAX-ARGOFFSET(%rsp)
13556 + GET_THREAD_INFO(%r11)
13557 DISABLE_INTERRUPTS(CLBR_NONE)
13558 TRACE_IRQS_OFF
13559 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13560 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13561 jnz sysretl_audit
13562 sysretl_from_sys_call:
13563 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13564 + pax_exit_kernel_user
13565 + pax_erase_kstack
13566 + andl $~TS_COMPAT,TI_status(%r11)
13567 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13568 movl RIP-ARGOFFSET(%rsp),%ecx
13569 CFI_REGISTER rip,rcx
13570 @@ -352,7 +431,7 @@ sysretl_audit:
13571
13572 cstar_tracesys:
13573 #ifdef CONFIG_AUDITSYSCALL
13574 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13575 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13576 jz cstar_auditsys
13577 #endif
13578 xchgl %r9d,%ebp
13579 @@ -366,11 +445,19 @@ cstar_tracesys:
13580 xchgl %ebp,%r9d
13581 cmpq $(IA32_NR_syscalls-1),%rax
13582 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13583 +
13584 + pax_erase_kstack
13585 +
13586 jmp cstar_do_call
13587 END(ia32_cstar_target)
13588
13589 ia32_badarg:
13590 ASM_CLAC
13591 +
13592 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13593 + ASM_PAX_CLOSE_USERLAND
13594 +#endif
13595 +
13596 movq $-EFAULT,%rax
13597 jmp ia32_sysret
13598 CFI_ENDPROC
13599 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13600 CFI_REL_OFFSET rip,RIP-RIP
13601 PARAVIRT_ADJUST_EXCEPTION_FRAME
13602 SWAPGS
13603 - /*
13604 - * No need to follow this irqs on/off section: the syscall
13605 - * disabled irqs and here we enable it straight after entry:
13606 - */
13607 - ENABLE_INTERRUPTS(CLBR_NONE)
13608 movl %eax,%eax
13609 pushq_cfi %rax
13610 cld
13611 /* note the registers are not zero extended to the sf.
13612 this could be a problem. */
13613 SAVE_ARGS 0,1,0
13614 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13615 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13616 + pax_enter_kernel_user
13617 +
13618 +#ifdef CONFIG_PAX_RANDKSTACK
13619 + pax_erase_kstack
13620 +#endif
13621 +
13622 + /*
13623 + * No need to follow this irqs on/off section: the syscall
13624 + * disabled irqs and here we enable it straight after entry:
13625 + */
13626 + ENABLE_INTERRUPTS(CLBR_NONE)
13627 + GET_THREAD_INFO(%r11)
13628 + orl $TS_COMPAT,TI_status(%r11)
13629 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13630 jnz ia32_tracesys
13631 cmpq $(IA32_NR_syscalls-1),%rax
13632 ja ia32_badsys
13633 @@ -442,6 +536,9 @@ ia32_tracesys:
13634 RESTORE_REST
13635 cmpq $(IA32_NR_syscalls-1),%rax
13636 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13637 +
13638 + pax_erase_kstack
13639 +
13640 jmp ia32_do_call
13641 END(ia32_syscall)
13642
13643 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13644 index 8e0ceec..af13504 100644
13645 --- a/arch/x86/ia32/sys_ia32.c
13646 +++ b/arch/x86/ia32/sys_ia32.c
13647 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13648 */
13649 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13650 {
13651 - typeof(ubuf->st_uid) uid = 0;
13652 - typeof(ubuf->st_gid) gid = 0;
13653 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13654 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13655 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13656 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13657 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13658 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13659 index 372231c..a5aa1a1 100644
13660 --- a/arch/x86/include/asm/alternative-asm.h
13661 +++ b/arch/x86/include/asm/alternative-asm.h
13662 @@ -18,6 +18,45 @@
13663 .endm
13664 #endif
13665
13666 +#ifdef KERNEXEC_PLUGIN
13667 + .macro pax_force_retaddr_bts rip=0
13668 + btsq $63,\rip(%rsp)
13669 + .endm
13670 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13671 + .macro pax_force_retaddr rip=0, reload=0
13672 + btsq $63,\rip(%rsp)
13673 + .endm
13674 + .macro pax_force_fptr ptr
13675 + btsq $63,\ptr
13676 + .endm
13677 + .macro pax_set_fptr_mask
13678 + .endm
13679 +#endif
13680 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13681 + .macro pax_force_retaddr rip=0, reload=0
13682 + .if \reload
13683 + pax_set_fptr_mask
13684 + .endif
13685 + orq %r10,\rip(%rsp)
13686 + .endm
13687 + .macro pax_force_fptr ptr
13688 + orq %r10,\ptr
13689 + .endm
13690 + .macro pax_set_fptr_mask
13691 + movabs $0x8000000000000000,%r10
13692 + .endm
13693 +#endif
13694 +#else
13695 + .macro pax_force_retaddr rip=0, reload=0
13696 + .endm
13697 + .macro pax_force_fptr ptr
13698 + .endm
13699 + .macro pax_force_retaddr_bts rip=0
13700 + .endm
13701 + .macro pax_set_fptr_mask
13702 + .endm
13703 +#endif
13704 +
13705 .macro altinstruction_entry orig alt feature orig_len alt_len
13706 .long \orig - .
13707 .long \alt - .
13708 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13709 index 58ed6d9..f1cbe58 100644
13710 --- a/arch/x86/include/asm/alternative.h
13711 +++ b/arch/x86/include/asm/alternative.h
13712 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13713 ".pushsection .discard,\"aw\",@progbits\n" \
13714 DISCARD_ENTRY(1) \
13715 ".popsection\n" \
13716 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13717 + ".pushsection .altinstr_replacement, \"a\"\n" \
13718 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13719 ".popsection"
13720
13721 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13722 DISCARD_ENTRY(1) \
13723 DISCARD_ENTRY(2) \
13724 ".popsection\n" \
13725 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13726 + ".pushsection .altinstr_replacement, \"a\"\n" \
13727 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13728 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13729 ".popsection"
13730 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13731 index f8119b5..7209d5b 100644
13732 --- a/arch/x86/include/asm/apic.h
13733 +++ b/arch/x86/include/asm/apic.h
13734 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13735
13736 #ifdef CONFIG_X86_LOCAL_APIC
13737
13738 -extern unsigned int apic_verbosity;
13739 +extern int apic_verbosity;
13740 extern int local_apic_timer_c2_ok;
13741
13742 extern int disable_apic;
13743 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13744 index 20370c6..a2eb9b0 100644
13745 --- a/arch/x86/include/asm/apm.h
13746 +++ b/arch/x86/include/asm/apm.h
13747 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13748 __asm__ __volatile__(APM_DO_ZERO_SEGS
13749 "pushl %%edi\n\t"
13750 "pushl %%ebp\n\t"
13751 - "lcall *%%cs:apm_bios_entry\n\t"
13752 + "lcall *%%ss:apm_bios_entry\n\t"
13753 "setc %%al\n\t"
13754 "popl %%ebp\n\t"
13755 "popl %%edi\n\t"
13756 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13757 __asm__ __volatile__(APM_DO_ZERO_SEGS
13758 "pushl %%edi\n\t"
13759 "pushl %%ebp\n\t"
13760 - "lcall *%%cs:apm_bios_entry\n\t"
13761 + "lcall *%%ss:apm_bios_entry\n\t"
13762 "setc %%bl\n\t"
13763 "popl %%ebp\n\t"
13764 "popl %%edi\n\t"
13765 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13766 index 722aa3b..3a0bb27 100644
13767 --- a/arch/x86/include/asm/atomic.h
13768 +++ b/arch/x86/include/asm/atomic.h
13769 @@ -22,7 +22,18 @@
13770 */
13771 static inline int atomic_read(const atomic_t *v)
13772 {
13773 - return (*(volatile int *)&(v)->counter);
13774 + return (*(volatile const int *)&(v)->counter);
13775 +}
13776 +
13777 +/**
13778 + * atomic_read_unchecked - read atomic variable
13779 + * @v: pointer of type atomic_unchecked_t
13780 + *
13781 + * Atomically reads the value of @v.
13782 + */
13783 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13784 +{
13785 + return (*(volatile const int *)&(v)->counter);
13786 }
13787
13788 /**
13789 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13790 }
13791
13792 /**
13793 + * atomic_set_unchecked - set atomic variable
13794 + * @v: pointer of type atomic_unchecked_t
13795 + * @i: required value
13796 + *
13797 + * Atomically sets the value of @v to @i.
13798 + */
13799 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13800 +{
13801 + v->counter = i;
13802 +}
13803 +
13804 +/**
13805 * atomic_add - add integer to atomic variable
13806 * @i: integer value to add
13807 * @v: pointer of type atomic_t
13808 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13809 */
13810 static inline void atomic_add(int i, atomic_t *v)
13811 {
13812 - asm volatile(LOCK_PREFIX "addl %1,%0"
13813 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13814 +
13815 +#ifdef CONFIG_PAX_REFCOUNT
13816 + "jno 0f\n"
13817 + LOCK_PREFIX "subl %1,%0\n"
13818 + "int $4\n0:\n"
13819 + _ASM_EXTABLE(0b, 0b)
13820 +#endif
13821 +
13822 + : "+m" (v->counter)
13823 + : "ir" (i));
13824 +}
13825 +
13826 +/**
13827 + * atomic_add_unchecked - add integer to atomic variable
13828 + * @i: integer value to add
13829 + * @v: pointer of type atomic_unchecked_t
13830 + *
13831 + * Atomically adds @i to @v.
13832 + */
13833 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13834 +{
13835 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13836 : "+m" (v->counter)
13837 : "ir" (i));
13838 }
13839 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13840 */
13841 static inline void atomic_sub(int i, atomic_t *v)
13842 {
13843 - asm volatile(LOCK_PREFIX "subl %1,%0"
13844 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13845 +
13846 +#ifdef CONFIG_PAX_REFCOUNT
13847 + "jno 0f\n"
13848 + LOCK_PREFIX "addl %1,%0\n"
13849 + "int $4\n0:\n"
13850 + _ASM_EXTABLE(0b, 0b)
13851 +#endif
13852 +
13853 + : "+m" (v->counter)
13854 + : "ir" (i));
13855 +}
13856 +
13857 +/**
13858 + * atomic_sub_unchecked - subtract integer from atomic variable
13859 + * @i: integer value to subtract
13860 + * @v: pointer of type atomic_unchecked_t
13861 + *
13862 + * Atomically subtracts @i from @v.
13863 + */
13864 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13865 +{
13866 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13867 : "+m" (v->counter)
13868 : "ir" (i));
13869 }
13870 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13871 {
13872 unsigned char c;
13873
13874 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13875 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13876 +
13877 +#ifdef CONFIG_PAX_REFCOUNT
13878 + "jno 0f\n"
13879 + LOCK_PREFIX "addl %2,%0\n"
13880 + "int $4\n0:\n"
13881 + _ASM_EXTABLE(0b, 0b)
13882 +#endif
13883 +
13884 + "sete %1\n"
13885 : "+m" (v->counter), "=qm" (c)
13886 : "ir" (i) : "memory");
13887 return c;
13888 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13889 */
13890 static inline void atomic_inc(atomic_t *v)
13891 {
13892 - asm volatile(LOCK_PREFIX "incl %0"
13893 + asm volatile(LOCK_PREFIX "incl %0\n"
13894 +
13895 +#ifdef CONFIG_PAX_REFCOUNT
13896 + "jno 0f\n"
13897 + LOCK_PREFIX "decl %0\n"
13898 + "int $4\n0:\n"
13899 + _ASM_EXTABLE(0b, 0b)
13900 +#endif
13901 +
13902 + : "+m" (v->counter));
13903 +}
13904 +
13905 +/**
13906 + * atomic_inc_unchecked - increment atomic variable
13907 + * @v: pointer of type atomic_unchecked_t
13908 + *
13909 + * Atomically increments @v by 1.
13910 + */
13911 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13912 +{
13913 + asm volatile(LOCK_PREFIX "incl %0\n"
13914 : "+m" (v->counter));
13915 }
13916
13917 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13918 */
13919 static inline void atomic_dec(atomic_t *v)
13920 {
13921 - asm volatile(LOCK_PREFIX "decl %0"
13922 + asm volatile(LOCK_PREFIX "decl %0\n"
13923 +
13924 +#ifdef CONFIG_PAX_REFCOUNT
13925 + "jno 0f\n"
13926 + LOCK_PREFIX "incl %0\n"
13927 + "int $4\n0:\n"
13928 + _ASM_EXTABLE(0b, 0b)
13929 +#endif
13930 +
13931 + : "+m" (v->counter));
13932 +}
13933 +
13934 +/**
13935 + * atomic_dec_unchecked - decrement atomic variable
13936 + * @v: pointer of type atomic_unchecked_t
13937 + *
13938 + * Atomically decrements @v by 1.
13939 + */
13940 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13941 +{
13942 + asm volatile(LOCK_PREFIX "decl %0\n"
13943 : "+m" (v->counter));
13944 }
13945
13946 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13947 {
13948 unsigned char c;
13949
13950 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13951 + asm volatile(LOCK_PREFIX "decl %0\n"
13952 +
13953 +#ifdef CONFIG_PAX_REFCOUNT
13954 + "jno 0f\n"
13955 + LOCK_PREFIX "incl %0\n"
13956 + "int $4\n0:\n"
13957 + _ASM_EXTABLE(0b, 0b)
13958 +#endif
13959 +
13960 + "sete %1\n"
13961 : "+m" (v->counter), "=qm" (c)
13962 : : "memory");
13963 return c != 0;
13964 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13965 {
13966 unsigned char c;
13967
13968 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13969 + asm volatile(LOCK_PREFIX "incl %0\n"
13970 +
13971 +#ifdef CONFIG_PAX_REFCOUNT
13972 + "jno 0f\n"
13973 + LOCK_PREFIX "decl %0\n"
13974 + "int $4\n0:\n"
13975 + _ASM_EXTABLE(0b, 0b)
13976 +#endif
13977 +
13978 + "sete %1\n"
13979 + : "+m" (v->counter), "=qm" (c)
13980 + : : "memory");
13981 + return c != 0;
13982 +}
13983 +
13984 +/**
13985 + * atomic_inc_and_test_unchecked - increment and test
13986 + * @v: pointer of type atomic_unchecked_t
13987 + *
13988 + * Atomically increments @v by 1
13989 + * and returns true if the result is zero, or false for all
13990 + * other cases.
13991 + */
13992 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13993 +{
13994 + unsigned char c;
13995 +
13996 + asm volatile(LOCK_PREFIX "incl %0\n"
13997 + "sete %1\n"
13998 : "+m" (v->counter), "=qm" (c)
13999 : : "memory");
14000 return c != 0;
14001 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14002 {
14003 unsigned char c;
14004
14005 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14006 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14007 +
14008 +#ifdef CONFIG_PAX_REFCOUNT
14009 + "jno 0f\n"
14010 + LOCK_PREFIX "subl %2,%0\n"
14011 + "int $4\n0:\n"
14012 + _ASM_EXTABLE(0b, 0b)
14013 +#endif
14014 +
14015 + "sets %1\n"
14016 : "+m" (v->counter), "=qm" (c)
14017 : "ir" (i) : "memory");
14018 return c;
14019 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14020 */
14021 static inline int atomic_add_return(int i, atomic_t *v)
14022 {
14023 + return i + xadd_check_overflow(&v->counter, i);
14024 +}
14025 +
14026 +/**
14027 + * atomic_add_return_unchecked - add integer and return
14028 + * @i: integer value to add
14029 + * @v: pointer of type atomic_unchecked_t
14030 + *
14031 + * Atomically adds @i to @v and returns @i + @v
14032 + */
14033 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14034 +{
14035 return i + xadd(&v->counter, i);
14036 }
14037
14038 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14039 }
14040
14041 #define atomic_inc_return(v) (atomic_add_return(1, v))
14042 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14043 +{
14044 + return atomic_add_return_unchecked(1, v);
14045 +}
14046 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14047
14048 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14049 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14050 return cmpxchg(&v->counter, old, new);
14051 }
14052
14053 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14054 +{
14055 + return cmpxchg(&v->counter, old, new);
14056 +}
14057 +
14058 static inline int atomic_xchg(atomic_t *v, int new)
14059 {
14060 return xchg(&v->counter, new);
14061 }
14062
14063 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14064 +{
14065 + return xchg(&v->counter, new);
14066 +}
14067 +
14068 /**
14069 * __atomic_add_unless - add unless the number is already a given value
14070 * @v: pointer of type atomic_t
14071 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14072 */
14073 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14074 {
14075 - int c, old;
14076 + int c, old, new;
14077 c = atomic_read(v);
14078 for (;;) {
14079 - if (unlikely(c == (u)))
14080 + if (unlikely(c == u))
14081 break;
14082 - old = atomic_cmpxchg((v), c, c + (a));
14083 +
14084 + asm volatile("addl %2,%0\n"
14085 +
14086 +#ifdef CONFIG_PAX_REFCOUNT
14087 + "jno 0f\n"
14088 + "subl %2,%0\n"
14089 + "int $4\n0:\n"
14090 + _ASM_EXTABLE(0b, 0b)
14091 +#endif
14092 +
14093 + : "=r" (new)
14094 + : "0" (c), "ir" (a));
14095 +
14096 + old = atomic_cmpxchg(v, c, new);
14097 if (likely(old == c))
14098 break;
14099 c = old;
14100 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14101 }
14102
14103 /**
14104 + * atomic_inc_not_zero_hint - increment if not null
14105 + * @v: pointer of type atomic_t
14106 + * @hint: probable value of the atomic before the increment
14107 + *
14108 + * This version of atomic_inc_not_zero() gives a hint of probable
14109 + * value of the atomic. This helps processor to not read the memory
14110 + * before doing the atomic read/modify/write cycle, lowering
14111 + * number of bus transactions on some arches.
14112 + *
14113 + * Returns: 0 if increment was not done, 1 otherwise.
14114 + */
14115 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14116 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14117 +{
14118 + int val, c = hint, new;
14119 +
14120 + /* sanity test, should be removed by compiler if hint is a constant */
14121 + if (!hint)
14122 + return __atomic_add_unless(v, 1, 0);
14123 +
14124 + do {
14125 + asm volatile("incl %0\n"
14126 +
14127 +#ifdef CONFIG_PAX_REFCOUNT
14128 + "jno 0f\n"
14129 + "decl %0\n"
14130 + "int $4\n0:\n"
14131 + _ASM_EXTABLE(0b, 0b)
14132 +#endif
14133 +
14134 + : "=r" (new)
14135 + : "0" (c));
14136 +
14137 + val = atomic_cmpxchg(v, c, new);
14138 + if (val == c)
14139 + return 1;
14140 + c = val;
14141 + } while (c);
14142 +
14143 + return 0;
14144 +}
14145 +
14146 +/**
14147 * atomic_inc_short - increment of a short integer
14148 * @v: pointer to type int
14149 *
14150 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14151 #endif
14152
14153 /* These are x86-specific, used by some header files */
14154 -#define atomic_clear_mask(mask, addr) \
14155 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14156 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14157 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14158 +{
14159 + asm volatile(LOCK_PREFIX "andl %1,%0"
14160 + : "+m" (v->counter)
14161 + : "r" (~(mask))
14162 + : "memory");
14163 +}
14164
14165 -#define atomic_set_mask(mask, addr) \
14166 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14167 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14168 - : "memory")
14169 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14170 +{
14171 + asm volatile(LOCK_PREFIX "andl %1,%0"
14172 + : "+m" (v->counter)
14173 + : "r" (~(mask))
14174 + : "memory");
14175 +}
14176 +
14177 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14178 +{
14179 + asm volatile(LOCK_PREFIX "orl %1,%0"
14180 + : "+m" (v->counter)
14181 + : "r" (mask)
14182 + : "memory");
14183 +}
14184 +
14185 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14186 +{
14187 + asm volatile(LOCK_PREFIX "orl %1,%0"
14188 + : "+m" (v->counter)
14189 + : "r" (mask)
14190 + : "memory");
14191 +}
14192
14193 /* Atomic operations are already serializing on x86 */
14194 #define smp_mb__before_atomic_dec() barrier()
14195 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14196 index b154de7..aadebd8 100644
14197 --- a/arch/x86/include/asm/atomic64_32.h
14198 +++ b/arch/x86/include/asm/atomic64_32.h
14199 @@ -12,6 +12,14 @@ typedef struct {
14200 u64 __aligned(8) counter;
14201 } atomic64_t;
14202
14203 +#ifdef CONFIG_PAX_REFCOUNT
14204 +typedef struct {
14205 + u64 __aligned(8) counter;
14206 +} atomic64_unchecked_t;
14207 +#else
14208 +typedef atomic64_t atomic64_unchecked_t;
14209 +#endif
14210 +
14211 #define ATOMIC64_INIT(val) { (val) }
14212
14213 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14214 @@ -37,21 +45,31 @@ typedef struct {
14215 ATOMIC64_DECL_ONE(sym##_386)
14216
14217 ATOMIC64_DECL_ONE(add_386);
14218 +ATOMIC64_DECL_ONE(add_unchecked_386);
14219 ATOMIC64_DECL_ONE(sub_386);
14220 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14221 ATOMIC64_DECL_ONE(inc_386);
14222 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14223 ATOMIC64_DECL_ONE(dec_386);
14224 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14225 #endif
14226
14227 #define alternative_atomic64(f, out, in...) \
14228 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14229
14230 ATOMIC64_DECL(read);
14231 +ATOMIC64_DECL(read_unchecked);
14232 ATOMIC64_DECL(set);
14233 +ATOMIC64_DECL(set_unchecked);
14234 ATOMIC64_DECL(xchg);
14235 ATOMIC64_DECL(add_return);
14236 +ATOMIC64_DECL(add_return_unchecked);
14237 ATOMIC64_DECL(sub_return);
14238 +ATOMIC64_DECL(sub_return_unchecked);
14239 ATOMIC64_DECL(inc_return);
14240 +ATOMIC64_DECL(inc_return_unchecked);
14241 ATOMIC64_DECL(dec_return);
14242 +ATOMIC64_DECL(dec_return_unchecked);
14243 ATOMIC64_DECL(dec_if_positive);
14244 ATOMIC64_DECL(inc_not_zero);
14245 ATOMIC64_DECL(add_unless);
14246 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14247 }
14248
14249 /**
14250 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14251 + * @p: pointer to type atomic64_unchecked_t
14252 + * @o: expected value
14253 + * @n: new value
14254 + *
14255 + * Atomically sets @v to @n if it was equal to @o and returns
14256 + * the old value.
14257 + */
14258 +
14259 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14260 +{
14261 + return cmpxchg64(&v->counter, o, n);
14262 +}
14263 +
14264 +/**
14265 * atomic64_xchg - xchg atomic64 variable
14266 * @v: pointer to type atomic64_t
14267 * @n: value to assign
14268 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14269 }
14270
14271 /**
14272 + * atomic64_set_unchecked - set atomic64 variable
14273 + * @v: pointer to type atomic64_unchecked_t
14274 + * @n: value to assign
14275 + *
14276 + * Atomically sets the value of @v to @n.
14277 + */
14278 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14279 +{
14280 + unsigned high = (unsigned)(i >> 32);
14281 + unsigned low = (unsigned)i;
14282 + alternative_atomic64(set, /* no output */,
14283 + "S" (v), "b" (low), "c" (high)
14284 + : "eax", "edx", "memory");
14285 +}
14286 +
14287 +/**
14288 * atomic64_read - read atomic64 variable
14289 * @v: pointer to type atomic64_t
14290 *
14291 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14292 }
14293
14294 /**
14295 + * atomic64_read_unchecked - read atomic64 variable
14296 + * @v: pointer to type atomic64_unchecked_t
14297 + *
14298 + * Atomically reads the value of @v and returns it.
14299 + */
14300 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14301 +{
14302 + long long r;
14303 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14304 + return r;
14305 + }
14306 +
14307 +/**
14308 * atomic64_add_return - add and return
14309 * @i: integer value to add
14310 * @v: pointer to type atomic64_t
14311 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14312 return i;
14313 }
14314
14315 +/**
14316 + * atomic64_add_return_unchecked - add and return
14317 + * @i: integer value to add
14318 + * @v: pointer to type atomic64_unchecked_t
14319 + *
14320 + * Atomically adds @i to @v and returns @i + *@v
14321 + */
14322 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14323 +{
14324 + alternative_atomic64(add_return_unchecked,
14325 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14326 + ASM_NO_INPUT_CLOBBER("memory"));
14327 + return i;
14328 +}
14329 +
14330 /*
14331 * Other variants with different arithmetic operators:
14332 */
14333 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14334 return a;
14335 }
14336
14337 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14338 +{
14339 + long long a;
14340 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14341 + "S" (v) : "memory", "ecx");
14342 + return a;
14343 +}
14344 +
14345 static inline long long atomic64_dec_return(atomic64_t *v)
14346 {
14347 long long a;
14348 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14349 }
14350
14351 /**
14352 + * atomic64_add_unchecked - add integer to atomic64 variable
14353 + * @i: integer value to add
14354 + * @v: pointer to type atomic64_unchecked_t
14355 + *
14356 + * Atomically adds @i to @v.
14357 + */
14358 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14359 +{
14360 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14361 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14362 + ASM_NO_INPUT_CLOBBER("memory"));
14363 + return i;
14364 +}
14365 +
14366 +/**
14367 * atomic64_sub - subtract the atomic64 variable
14368 * @i: integer value to subtract
14369 * @v: pointer to type atomic64_t
14370 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14371 index 0e1cbfc..5623683 100644
14372 --- a/arch/x86/include/asm/atomic64_64.h
14373 +++ b/arch/x86/include/asm/atomic64_64.h
14374 @@ -18,7 +18,19 @@
14375 */
14376 static inline long atomic64_read(const atomic64_t *v)
14377 {
14378 - return (*(volatile long *)&(v)->counter);
14379 + return (*(volatile const long *)&(v)->counter);
14380 +}
14381 +
14382 +/**
14383 + * atomic64_read_unchecked - read atomic64 variable
14384 + * @v: pointer of type atomic64_unchecked_t
14385 + *
14386 + * Atomically reads the value of @v.
14387 + * Doesn't imply a read memory barrier.
14388 + */
14389 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14390 +{
14391 + return (*(volatile const long *)&(v)->counter);
14392 }
14393
14394 /**
14395 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14396 }
14397
14398 /**
14399 + * atomic64_set_unchecked - set atomic64 variable
14400 + * @v: pointer to type atomic64_unchecked_t
14401 + * @i: required value
14402 + *
14403 + * Atomically sets the value of @v to @i.
14404 + */
14405 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14406 +{
14407 + v->counter = i;
14408 +}
14409 +
14410 +/**
14411 * atomic64_add - add integer to atomic64 variable
14412 * @i: integer value to add
14413 * @v: pointer to type atomic64_t
14414 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14415 */
14416 static inline void atomic64_add(long i, atomic64_t *v)
14417 {
14418 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14419 +
14420 +#ifdef CONFIG_PAX_REFCOUNT
14421 + "jno 0f\n"
14422 + LOCK_PREFIX "subq %1,%0\n"
14423 + "int $4\n0:\n"
14424 + _ASM_EXTABLE(0b, 0b)
14425 +#endif
14426 +
14427 + : "=m" (v->counter)
14428 + : "er" (i), "m" (v->counter));
14429 +}
14430 +
14431 +/**
14432 + * atomic64_add_unchecked - add integer to atomic64 variable
14433 + * @i: integer value to add
14434 + * @v: pointer to type atomic64_unchecked_t
14435 + *
14436 + * Atomically adds @i to @v.
14437 + */
14438 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14439 +{
14440 asm volatile(LOCK_PREFIX "addq %1,%0"
14441 : "=m" (v->counter)
14442 : "er" (i), "m" (v->counter));
14443 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14444 */
14445 static inline void atomic64_sub(long i, atomic64_t *v)
14446 {
14447 - asm volatile(LOCK_PREFIX "subq %1,%0"
14448 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14449 +
14450 +#ifdef CONFIG_PAX_REFCOUNT
14451 + "jno 0f\n"
14452 + LOCK_PREFIX "addq %1,%0\n"
14453 + "int $4\n0:\n"
14454 + _ASM_EXTABLE(0b, 0b)
14455 +#endif
14456 +
14457 + : "=m" (v->counter)
14458 + : "er" (i), "m" (v->counter));
14459 +}
14460 +
14461 +/**
14462 + * atomic64_sub_unchecked - subtract the atomic64 variable
14463 + * @i: integer value to subtract
14464 + * @v: pointer to type atomic64_unchecked_t
14465 + *
14466 + * Atomically subtracts @i from @v.
14467 + */
14468 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14469 +{
14470 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14471 : "=m" (v->counter)
14472 : "er" (i), "m" (v->counter));
14473 }
14474 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14475 {
14476 unsigned char c;
14477
14478 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14479 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14480 +
14481 +#ifdef CONFIG_PAX_REFCOUNT
14482 + "jno 0f\n"
14483 + LOCK_PREFIX "addq %2,%0\n"
14484 + "int $4\n0:\n"
14485 + _ASM_EXTABLE(0b, 0b)
14486 +#endif
14487 +
14488 + "sete %1\n"
14489 : "=m" (v->counter), "=qm" (c)
14490 : "er" (i), "m" (v->counter) : "memory");
14491 return c;
14492 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14493 */
14494 static inline void atomic64_inc(atomic64_t *v)
14495 {
14496 + asm volatile(LOCK_PREFIX "incq %0\n"
14497 +
14498 +#ifdef CONFIG_PAX_REFCOUNT
14499 + "jno 0f\n"
14500 + LOCK_PREFIX "decq %0\n"
14501 + "int $4\n0:\n"
14502 + _ASM_EXTABLE(0b, 0b)
14503 +#endif
14504 +
14505 + : "=m" (v->counter)
14506 + : "m" (v->counter));
14507 +}
14508 +
14509 +/**
14510 + * atomic64_inc_unchecked - increment atomic64 variable
14511 + * @v: pointer to type atomic64_unchecked_t
14512 + *
14513 + * Atomically increments @v by 1.
14514 + */
14515 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14516 +{
14517 asm volatile(LOCK_PREFIX "incq %0"
14518 : "=m" (v->counter)
14519 : "m" (v->counter));
14520 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14521 */
14522 static inline void atomic64_dec(atomic64_t *v)
14523 {
14524 - asm volatile(LOCK_PREFIX "decq %0"
14525 + asm volatile(LOCK_PREFIX "decq %0\n"
14526 +
14527 +#ifdef CONFIG_PAX_REFCOUNT
14528 + "jno 0f\n"
14529 + LOCK_PREFIX "incq %0\n"
14530 + "int $4\n0:\n"
14531 + _ASM_EXTABLE(0b, 0b)
14532 +#endif
14533 +
14534 + : "=m" (v->counter)
14535 + : "m" (v->counter));
14536 +}
14537 +
14538 +/**
14539 + * atomic64_dec_unchecked - decrement atomic64 variable
14540 + * @v: pointer to type atomic64_t
14541 + *
14542 + * Atomically decrements @v by 1.
14543 + */
14544 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14545 +{
14546 + asm volatile(LOCK_PREFIX "decq %0\n"
14547 : "=m" (v->counter)
14548 : "m" (v->counter));
14549 }
14550 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14551 {
14552 unsigned char c;
14553
14554 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14555 + asm volatile(LOCK_PREFIX "decq %0\n"
14556 +
14557 +#ifdef CONFIG_PAX_REFCOUNT
14558 + "jno 0f\n"
14559 + LOCK_PREFIX "incq %0\n"
14560 + "int $4\n0:\n"
14561 + _ASM_EXTABLE(0b, 0b)
14562 +#endif
14563 +
14564 + "sete %1\n"
14565 : "=m" (v->counter), "=qm" (c)
14566 : "m" (v->counter) : "memory");
14567 return c != 0;
14568 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14569 {
14570 unsigned char c;
14571
14572 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14573 + asm volatile(LOCK_PREFIX "incq %0\n"
14574 +
14575 +#ifdef CONFIG_PAX_REFCOUNT
14576 + "jno 0f\n"
14577 + LOCK_PREFIX "decq %0\n"
14578 + "int $4\n0:\n"
14579 + _ASM_EXTABLE(0b, 0b)
14580 +#endif
14581 +
14582 + "sete %1\n"
14583 : "=m" (v->counter), "=qm" (c)
14584 : "m" (v->counter) : "memory");
14585 return c != 0;
14586 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14587 {
14588 unsigned char c;
14589
14590 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14591 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14592 +
14593 +#ifdef CONFIG_PAX_REFCOUNT
14594 + "jno 0f\n"
14595 + LOCK_PREFIX "subq %2,%0\n"
14596 + "int $4\n0:\n"
14597 + _ASM_EXTABLE(0b, 0b)
14598 +#endif
14599 +
14600 + "sets %1\n"
14601 : "=m" (v->counter), "=qm" (c)
14602 : "er" (i), "m" (v->counter) : "memory");
14603 return c;
14604 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14605 */
14606 static inline long atomic64_add_return(long i, atomic64_t *v)
14607 {
14608 + return i + xadd_check_overflow(&v->counter, i);
14609 +}
14610 +
14611 +/**
14612 + * atomic64_add_return_unchecked - add and return
14613 + * @i: integer value to add
14614 + * @v: pointer to type atomic64_unchecked_t
14615 + *
14616 + * Atomically adds @i to @v and returns @i + @v
14617 + */
14618 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14619 +{
14620 return i + xadd(&v->counter, i);
14621 }
14622
14623 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14624 }
14625
14626 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14627 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14628 +{
14629 + return atomic64_add_return_unchecked(1, v);
14630 +}
14631 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14632
14633 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14634 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14635 return cmpxchg(&v->counter, old, new);
14636 }
14637
14638 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14639 +{
14640 + return cmpxchg(&v->counter, old, new);
14641 +}
14642 +
14643 static inline long atomic64_xchg(atomic64_t *v, long new)
14644 {
14645 return xchg(&v->counter, new);
14646 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14647 */
14648 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14649 {
14650 - long c, old;
14651 + long c, old, new;
14652 c = atomic64_read(v);
14653 for (;;) {
14654 - if (unlikely(c == (u)))
14655 + if (unlikely(c == u))
14656 break;
14657 - old = atomic64_cmpxchg((v), c, c + (a));
14658 +
14659 + asm volatile("add %2,%0\n"
14660 +
14661 +#ifdef CONFIG_PAX_REFCOUNT
14662 + "jno 0f\n"
14663 + "sub %2,%0\n"
14664 + "int $4\n0:\n"
14665 + _ASM_EXTABLE(0b, 0b)
14666 +#endif
14667 +
14668 + : "=r" (new)
14669 + : "0" (c), "ir" (a));
14670 +
14671 + old = atomic64_cmpxchg(v, c, new);
14672 if (likely(old == c))
14673 break;
14674 c = old;
14675 }
14676 - return c != (u);
14677 + return c != u;
14678 }
14679
14680 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14681 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14682 index 6dfd019..28e188d 100644
14683 --- a/arch/x86/include/asm/bitops.h
14684 +++ b/arch/x86/include/asm/bitops.h
14685 @@ -40,7 +40,7 @@
14686 * a mask operation on a byte.
14687 */
14688 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14689 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14690 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14691 #define CONST_MASK(nr) (1 << ((nr) & 7))
14692
14693 /**
14694 @@ -486,7 +486,7 @@ static inline int fls(int x)
14695 * at position 64.
14696 */
14697 #ifdef CONFIG_X86_64
14698 -static __always_inline int fls64(__u64 x)
14699 +static __always_inline long fls64(__u64 x)
14700 {
14701 int bitpos = -1;
14702 /*
14703 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14704 index 4fa687a..60f2d39 100644
14705 --- a/arch/x86/include/asm/boot.h
14706 +++ b/arch/x86/include/asm/boot.h
14707 @@ -6,10 +6,15 @@
14708 #include <uapi/asm/boot.h>
14709
14710 /* Physical address where kernel should be loaded. */
14711 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14712 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14713 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14714 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14715
14716 +#ifndef __ASSEMBLY__
14717 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14718 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14719 +#endif
14720 +
14721 /* Minimum kernel alignment, as a power of two */
14722 #ifdef CONFIG_X86_64
14723 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14724 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14725 index 48f99f1..d78ebf9 100644
14726 --- a/arch/x86/include/asm/cache.h
14727 +++ b/arch/x86/include/asm/cache.h
14728 @@ -5,12 +5,13 @@
14729
14730 /* L1 cache line size */
14731 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14732 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14733 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14734
14735 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14736 +#define __read_only __attribute__((__section__(".data..read_only")))
14737
14738 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14739 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14740 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14741
14742 #ifdef CONFIG_X86_VSMP
14743 #ifdef CONFIG_SMP
14744 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14745 index 9863ee3..4a1f8e1 100644
14746 --- a/arch/x86/include/asm/cacheflush.h
14747 +++ b/arch/x86/include/asm/cacheflush.h
14748 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14749 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14750
14751 if (pg_flags == _PGMT_DEFAULT)
14752 - return -1;
14753 + return ~0UL;
14754 else if (pg_flags == _PGMT_WC)
14755 return _PAGE_CACHE_WC;
14756 else if (pg_flags == _PGMT_UC_MINUS)
14757 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14758 index f50de69..2b0a458 100644
14759 --- a/arch/x86/include/asm/checksum_32.h
14760 +++ b/arch/x86/include/asm/checksum_32.h
14761 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14762 int len, __wsum sum,
14763 int *src_err_ptr, int *dst_err_ptr);
14764
14765 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14766 + int len, __wsum sum,
14767 + int *src_err_ptr, int *dst_err_ptr);
14768 +
14769 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14770 + int len, __wsum sum,
14771 + int *src_err_ptr, int *dst_err_ptr);
14772 +
14773 /*
14774 * Note: when you get a NULL pointer exception here this means someone
14775 * passed in an incorrect kernel address to one of these functions.
14776 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14777
14778 might_sleep();
14779 stac();
14780 - ret = csum_partial_copy_generic((__force void *)src, dst,
14781 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14782 len, sum, err_ptr, NULL);
14783 clac();
14784
14785 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14786 might_sleep();
14787 if (access_ok(VERIFY_WRITE, dst, len)) {
14788 stac();
14789 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14790 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14791 len, sum, NULL, err_ptr);
14792 clac();
14793 return ret;
14794 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14795 index d47786a..ce1b05d 100644
14796 --- a/arch/x86/include/asm/cmpxchg.h
14797 +++ b/arch/x86/include/asm/cmpxchg.h
14798 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14799 __compiletime_error("Bad argument size for cmpxchg");
14800 extern void __xadd_wrong_size(void)
14801 __compiletime_error("Bad argument size for xadd");
14802 +extern void __xadd_check_overflow_wrong_size(void)
14803 + __compiletime_error("Bad argument size for xadd_check_overflow");
14804 extern void __add_wrong_size(void)
14805 __compiletime_error("Bad argument size for add");
14806 +extern void __add_check_overflow_wrong_size(void)
14807 + __compiletime_error("Bad argument size for add_check_overflow");
14808
14809 /*
14810 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14811 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14812 __ret; \
14813 })
14814
14815 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14816 + ({ \
14817 + __typeof__ (*(ptr)) __ret = (arg); \
14818 + switch (sizeof(*(ptr))) { \
14819 + case __X86_CASE_L: \
14820 + asm volatile (lock #op "l %0, %1\n" \
14821 + "jno 0f\n" \
14822 + "mov %0,%1\n" \
14823 + "int $4\n0:\n" \
14824 + _ASM_EXTABLE(0b, 0b) \
14825 + : "+r" (__ret), "+m" (*(ptr)) \
14826 + : : "memory", "cc"); \
14827 + break; \
14828 + case __X86_CASE_Q: \
14829 + asm volatile (lock #op "q %q0, %1\n" \
14830 + "jno 0f\n" \
14831 + "mov %0,%1\n" \
14832 + "int $4\n0:\n" \
14833 + _ASM_EXTABLE(0b, 0b) \
14834 + : "+r" (__ret), "+m" (*(ptr)) \
14835 + : : "memory", "cc"); \
14836 + break; \
14837 + default: \
14838 + __ ## op ## _check_overflow_wrong_size(); \
14839 + } \
14840 + __ret; \
14841 + })
14842 +
14843 /*
14844 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14845 * Since this is generally used to protect other memory information, we
14846 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14847 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14848 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14849
14850 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14851 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14852 +
14853 #define __add(ptr, inc, lock) \
14854 ({ \
14855 __typeof__ (*(ptr)) __ret = (inc); \
14856 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14857 index 59c6c40..5e0b22c 100644
14858 --- a/arch/x86/include/asm/compat.h
14859 +++ b/arch/x86/include/asm/compat.h
14860 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14861 typedef u32 compat_uint_t;
14862 typedef u32 compat_ulong_t;
14863 typedef u64 __attribute__((aligned(4))) compat_u64;
14864 -typedef u32 compat_uptr_t;
14865 +typedef u32 __user compat_uptr_t;
14866
14867 struct compat_timespec {
14868 compat_time_t tv_sec;
14869 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14870 index 7290585..717e89e 100644
14871 --- a/arch/x86/include/asm/cpufeature.h
14872 +++ b/arch/x86/include/asm/cpufeature.h
14873 @@ -203,7 +203,7 @@
14874 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14875 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14876 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14877 -
14878 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14879
14880 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14881 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14882 @@ -211,7 +211,7 @@
14883 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14884 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14885 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14886 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14887 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14888 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14889 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14890 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14891 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14892 #undef cpu_has_centaur_mcr
14893 #define cpu_has_centaur_mcr 0
14894
14895 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14896 #endif /* CONFIG_X86_64 */
14897
14898 #if __GNUC__ >= 4
14899 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14900
14901 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14902 t_warn:
14903 - warn_pre_alternatives();
14904 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14905 + warn_pre_alternatives();
14906 return false;
14907 #endif
14908 #else /* GCC_VERSION >= 40500 */
14909 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14910 ".section .discard,\"aw\",@progbits\n"
14911 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14912 ".previous\n"
14913 - ".section .altinstr_replacement,\"ax\"\n"
14914 + ".section .altinstr_replacement,\"a\"\n"
14915 "3: movb $1,%0\n"
14916 "4:\n"
14917 ".previous\n"
14918 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14919 " .byte 2b - 1b\n" /* src len */
14920 " .byte 4f - 3f\n" /* repl len */
14921 ".previous\n"
14922 - ".section .altinstr_replacement,\"ax\"\n"
14923 + ".section .altinstr_replacement,\"a\"\n"
14924 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14925 "4:\n"
14926 ".previous\n"
14927 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14928 ".section .discard,\"aw\",@progbits\n"
14929 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14930 ".previous\n"
14931 - ".section .altinstr_replacement,\"ax\"\n"
14932 + ".section .altinstr_replacement,\"a\"\n"
14933 "3: movb $0,%0\n"
14934 "4:\n"
14935 ".previous\n"
14936 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14937 ".section .discard,\"aw\",@progbits\n"
14938 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14939 ".previous\n"
14940 - ".section .altinstr_replacement,\"ax\"\n"
14941 + ".section .altinstr_replacement,\"a\"\n"
14942 "5: movb $1,%0\n"
14943 "6:\n"
14944 ".previous\n"
14945 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14946 index b90e5df..b462c91 100644
14947 --- a/arch/x86/include/asm/desc.h
14948 +++ b/arch/x86/include/asm/desc.h
14949 @@ -4,6 +4,7 @@
14950 #include <asm/desc_defs.h>
14951 #include <asm/ldt.h>
14952 #include <asm/mmu.h>
14953 +#include <asm/pgtable.h>
14954
14955 #include <linux/smp.h>
14956 #include <linux/percpu.h>
14957 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14958
14959 desc->type = (info->read_exec_only ^ 1) << 1;
14960 desc->type |= info->contents << 2;
14961 + desc->type |= info->seg_not_present ^ 1;
14962
14963 desc->s = 1;
14964 desc->dpl = 0x3;
14965 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14966 }
14967
14968 extern struct desc_ptr idt_descr;
14969 -extern gate_desc idt_table[];
14970 -extern struct desc_ptr debug_idt_descr;
14971 -extern gate_desc debug_idt_table[];
14972 -
14973 -struct gdt_page {
14974 - struct desc_struct gdt[GDT_ENTRIES];
14975 -} __attribute__((aligned(PAGE_SIZE)));
14976 -
14977 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14978 +extern gate_desc idt_table[IDT_ENTRIES];
14979 +extern const struct desc_ptr debug_idt_descr;
14980 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14981
14982 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14983 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14984 {
14985 - return per_cpu(gdt_page, cpu).gdt;
14986 + return cpu_gdt_table[cpu];
14987 }
14988
14989 #ifdef CONFIG_X86_64
14990 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14991 unsigned long base, unsigned dpl, unsigned flags,
14992 unsigned short seg)
14993 {
14994 - gate->a = (seg << 16) | (base & 0xffff);
14995 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14996 + gate->gate.offset_low = base;
14997 + gate->gate.seg = seg;
14998 + gate->gate.reserved = 0;
14999 + gate->gate.type = type;
15000 + gate->gate.s = 0;
15001 + gate->gate.dpl = dpl;
15002 + gate->gate.p = 1;
15003 + gate->gate.offset_high = base >> 16;
15004 }
15005
15006 #endif
15007 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15008
15009 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15010 {
15011 + pax_open_kernel();
15012 memcpy(&idt[entry], gate, sizeof(*gate));
15013 + pax_close_kernel();
15014 }
15015
15016 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15017 {
15018 + pax_open_kernel();
15019 memcpy(&ldt[entry], desc, 8);
15020 + pax_close_kernel();
15021 }
15022
15023 static inline void
15024 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15025 default: size = sizeof(*gdt); break;
15026 }
15027
15028 + pax_open_kernel();
15029 memcpy(&gdt[entry], desc, size);
15030 + pax_close_kernel();
15031 }
15032
15033 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15034 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15035
15036 static inline void native_load_tr_desc(void)
15037 {
15038 + pax_open_kernel();
15039 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15040 + pax_close_kernel();
15041 }
15042
15043 static inline void native_load_gdt(const struct desc_ptr *dtr)
15044 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15045 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15046 unsigned int i;
15047
15048 + pax_open_kernel();
15049 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15050 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15051 + pax_close_kernel();
15052 }
15053
15054 #define _LDT_empty(info) \
15055 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15056 preempt_enable();
15057 }
15058
15059 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15060 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15061 {
15062 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15063 }
15064 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15065 }
15066
15067 #ifdef CONFIG_X86_64
15068 -static inline void set_nmi_gate(int gate, void *addr)
15069 +static inline void set_nmi_gate(int gate, const void *addr)
15070 {
15071 gate_desc s;
15072
15073 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15074 #endif
15075
15076 #ifdef CONFIG_TRACING
15077 -extern struct desc_ptr trace_idt_descr;
15078 -extern gate_desc trace_idt_table[];
15079 +extern const struct desc_ptr trace_idt_descr;
15080 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15081 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15082 {
15083 write_idt_entry(trace_idt_table, entry, gate);
15084 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15085 }
15086 #endif
15087
15088 -static inline void _set_gate(int gate, unsigned type, void *addr,
15089 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15090 unsigned dpl, unsigned ist, unsigned seg)
15091 {
15092 gate_desc s;
15093 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15094 * Pentium F0 0F bugfix can have resulted in the mapped
15095 * IDT being write-protected.
15096 */
15097 -static inline void set_intr_gate(unsigned int n, void *addr)
15098 +static inline void set_intr_gate(unsigned int n, const void *addr)
15099 {
15100 BUG_ON((unsigned)n > 0xFF);
15101 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15102 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15103 /*
15104 * This routine sets up an interrupt gate at directory privilege level 3.
15105 */
15106 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15107 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15108 {
15109 BUG_ON((unsigned)n > 0xFF);
15110 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15111 }
15112
15113 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15114 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15115 {
15116 BUG_ON((unsigned)n > 0xFF);
15117 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15118 }
15119
15120 -static inline void set_trap_gate(unsigned int n, void *addr)
15121 +static inline void set_trap_gate(unsigned int n, const void *addr)
15122 {
15123 BUG_ON((unsigned)n > 0xFF);
15124 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15125 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15126 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15127 {
15128 BUG_ON((unsigned)n > 0xFF);
15129 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15130 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15131 }
15132
15133 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15134 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15135 {
15136 BUG_ON((unsigned)n > 0xFF);
15137 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15138 }
15139
15140 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15141 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15142 {
15143 BUG_ON((unsigned)n > 0xFF);
15144 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15145 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15146 else
15147 load_idt((const struct desc_ptr *)&idt_descr);
15148 }
15149 +
15150 +#ifdef CONFIG_X86_32
15151 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15152 +{
15153 + struct desc_struct d;
15154 +
15155 + if (likely(limit))
15156 + limit = (limit - 1UL) >> PAGE_SHIFT;
15157 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15158 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15159 +}
15160 +#endif
15161 +
15162 #endif /* _ASM_X86_DESC_H */
15163 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15164 index 278441f..b95a174 100644
15165 --- a/arch/x86/include/asm/desc_defs.h
15166 +++ b/arch/x86/include/asm/desc_defs.h
15167 @@ -31,6 +31,12 @@ struct desc_struct {
15168 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15169 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15170 };
15171 + struct {
15172 + u16 offset_low;
15173 + u16 seg;
15174 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15175 + unsigned offset_high: 16;
15176 + } gate;
15177 };
15178 } __attribute__((packed));
15179
15180 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15181 index ced283a..ffe04cc 100644
15182 --- a/arch/x86/include/asm/div64.h
15183 +++ b/arch/x86/include/asm/div64.h
15184 @@ -39,7 +39,7 @@
15185 __mod; \
15186 })
15187
15188 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15189 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15190 {
15191 union {
15192 u64 v64;
15193 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15194 index 9c999c1..3860cb8 100644
15195 --- a/arch/x86/include/asm/elf.h
15196 +++ b/arch/x86/include/asm/elf.h
15197 @@ -243,7 +243,25 @@ extern int force_personality32;
15198 the loader. We need to make sure that it is out of the way of the program
15199 that it will "exec", and that there is sufficient room for the brk. */
15200
15201 +#ifdef CONFIG_PAX_SEGMEXEC
15202 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15203 +#else
15204 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15205 +#endif
15206 +
15207 +#ifdef CONFIG_PAX_ASLR
15208 +#ifdef CONFIG_X86_32
15209 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15210 +
15211 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15212 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15213 +#else
15214 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15215 +
15216 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15217 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15218 +#endif
15219 +#endif
15220
15221 /* This yields a mask that user programs can use to figure out what
15222 instruction set this CPU supports. This could be done in user space,
15223 @@ -296,16 +314,12 @@ do { \
15224
15225 #define ARCH_DLINFO \
15226 do { \
15227 - if (vdso_enabled) \
15228 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15229 - (unsigned long)current->mm->context.vdso); \
15230 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15231 } while (0)
15232
15233 #define ARCH_DLINFO_X32 \
15234 do { \
15235 - if (vdso_enabled) \
15236 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15237 - (unsigned long)current->mm->context.vdso); \
15238 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15239 } while (0)
15240
15241 #define AT_SYSINFO 32
15242 @@ -320,7 +334,7 @@ else \
15243
15244 #endif /* !CONFIG_X86_32 */
15245
15246 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15247 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15248
15249 #define VDSO_ENTRY \
15250 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15251 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15252 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15253 #define compat_arch_setup_additional_pages syscall32_setup_pages
15254
15255 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15256 -#define arch_randomize_brk arch_randomize_brk
15257 -
15258 /*
15259 * True on X86_32 or when emulating IA32 on X86_64
15260 */
15261 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15262 index 77a99ac..39ff7f5 100644
15263 --- a/arch/x86/include/asm/emergency-restart.h
15264 +++ b/arch/x86/include/asm/emergency-restart.h
15265 @@ -1,6 +1,6 @@
15266 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15267 #define _ASM_X86_EMERGENCY_RESTART_H
15268
15269 -extern void machine_emergency_restart(void);
15270 +extern void machine_emergency_restart(void) __noreturn;
15271
15272 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15273 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15274 index 4d0bda7..221da4d 100644
15275 --- a/arch/x86/include/asm/fpu-internal.h
15276 +++ b/arch/x86/include/asm/fpu-internal.h
15277 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15278 #define user_insn(insn, output, input...) \
15279 ({ \
15280 int err; \
15281 + pax_open_userland(); \
15282 asm volatile(ASM_STAC "\n" \
15283 - "1:" #insn "\n\t" \
15284 + "1:" \
15285 + __copyuser_seg \
15286 + #insn "\n\t" \
15287 "2: " ASM_CLAC "\n" \
15288 ".section .fixup,\"ax\"\n" \
15289 "3: movl $-1,%[err]\n" \
15290 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15291 _ASM_EXTABLE(1b, 3b) \
15292 : [err] "=r" (err), output \
15293 : "0"(0), input); \
15294 + pax_close_userland(); \
15295 err; \
15296 })
15297
15298 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15299 "emms\n\t" /* clear stack tags */
15300 "fildl %P[addr]", /* set F?P to defined value */
15301 X86_FEATURE_FXSAVE_LEAK,
15302 - [addr] "m" (tsk->thread.fpu.has_fpu));
15303 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15304
15305 return fpu_restore_checking(&tsk->thread.fpu);
15306 }
15307 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15308 index be27ba1..04a8801 100644
15309 --- a/arch/x86/include/asm/futex.h
15310 +++ b/arch/x86/include/asm/futex.h
15311 @@ -12,6 +12,7 @@
15312 #include <asm/smap.h>
15313
15314 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15315 + typecheck(u32 __user *, uaddr); \
15316 asm volatile("\t" ASM_STAC "\n" \
15317 "1:\t" insn "\n" \
15318 "2:\t" ASM_CLAC "\n" \
15319 @@ -20,15 +21,16 @@
15320 "\tjmp\t2b\n" \
15321 "\t.previous\n" \
15322 _ASM_EXTABLE(1b, 3b) \
15323 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15324 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15325 : "i" (-EFAULT), "0" (oparg), "1" (0))
15326
15327 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15328 + typecheck(u32 __user *, uaddr); \
15329 asm volatile("\t" ASM_STAC "\n" \
15330 "1:\tmovl %2, %0\n" \
15331 "\tmovl\t%0, %3\n" \
15332 "\t" insn "\n" \
15333 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15334 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15335 "\tjnz\t1b\n" \
15336 "3:\t" ASM_CLAC "\n" \
15337 "\t.section .fixup,\"ax\"\n" \
15338 @@ -38,7 +40,7 @@
15339 _ASM_EXTABLE(1b, 4b) \
15340 _ASM_EXTABLE(2b, 4b) \
15341 : "=&a" (oldval), "=&r" (ret), \
15342 - "+m" (*uaddr), "=&r" (tem) \
15343 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15344 : "r" (oparg), "i" (-EFAULT), "1" (0))
15345
15346 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15347 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15348
15349 pagefault_disable();
15350
15351 + pax_open_userland();
15352 switch (op) {
15353 case FUTEX_OP_SET:
15354 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15355 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15356 break;
15357 case FUTEX_OP_ADD:
15358 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15359 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15360 uaddr, oparg);
15361 break;
15362 case FUTEX_OP_OR:
15363 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15364 default:
15365 ret = -ENOSYS;
15366 }
15367 + pax_close_userland();
15368
15369 pagefault_enable();
15370
15371 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15372 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15373 return -EFAULT;
15374
15375 + pax_open_userland();
15376 asm volatile("\t" ASM_STAC "\n"
15377 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15378 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15379 "2:\t" ASM_CLAC "\n"
15380 "\t.section .fixup, \"ax\"\n"
15381 "3:\tmov %3, %0\n"
15382 "\tjmp 2b\n"
15383 "\t.previous\n"
15384 _ASM_EXTABLE(1b, 3b)
15385 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15386 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15387 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15388 : "memory"
15389 );
15390 + pax_close_userland();
15391
15392 *uval = oldval;
15393 return ret;
15394 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15395 index e4ac559..c1c0c87 100644
15396 --- a/arch/x86/include/asm/hw_irq.h
15397 +++ b/arch/x86/include/asm/hw_irq.h
15398 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15399 extern void enable_IO_APIC(void);
15400
15401 /* Statistics */
15402 -extern atomic_t irq_err_count;
15403 -extern atomic_t irq_mis_count;
15404 +extern atomic_unchecked_t irq_err_count;
15405 +extern atomic_unchecked_t irq_mis_count;
15406
15407 /* EISA */
15408 extern void eisa_set_level_irq(unsigned int irq);
15409 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15410 index a203659..9889f1c 100644
15411 --- a/arch/x86/include/asm/i8259.h
15412 +++ b/arch/x86/include/asm/i8259.h
15413 @@ -62,7 +62,7 @@ struct legacy_pic {
15414 void (*init)(int auto_eoi);
15415 int (*irq_pending)(unsigned int irq);
15416 void (*make_irq)(unsigned int irq);
15417 -};
15418 +} __do_const;
15419
15420 extern struct legacy_pic *legacy_pic;
15421 extern struct legacy_pic null_legacy_pic;
15422 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15423 index 34f69cb..6d95446 100644
15424 --- a/arch/x86/include/asm/io.h
15425 +++ b/arch/x86/include/asm/io.h
15426 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15427 "m" (*(volatile type __force *)addr) barrier); }
15428
15429 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15430 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15431 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15432 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15433 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15434
15435 build_mmio_read(__readb, "b", unsigned char, "=q", )
15436 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15437 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15438 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15439 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15440
15441 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15442 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15443 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15444 return ioremap_nocache(offset, size);
15445 }
15446
15447 -extern void iounmap(volatile void __iomem *addr);
15448 +extern void iounmap(const volatile void __iomem *addr);
15449
15450 extern void set_iounmap_nonlazy(void);
15451
15452 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15453
15454 #include <linux/vmalloc.h>
15455
15456 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15457 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15458 +{
15459 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15460 +}
15461 +
15462 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15463 +{
15464 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15465 +}
15466 +
15467 /*
15468 * Convert a virtual cached pointer to an uncached pointer
15469 */
15470 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15471 index bba3cf8..06bc8da 100644
15472 --- a/arch/x86/include/asm/irqflags.h
15473 +++ b/arch/x86/include/asm/irqflags.h
15474 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15475 sti; \
15476 sysexit
15477
15478 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15479 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15480 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15481 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15482 +
15483 #else
15484 #define INTERRUPT_RETURN iret
15485 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15486 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15487 index 5a6d287..f815789 100644
15488 --- a/arch/x86/include/asm/kprobes.h
15489 +++ b/arch/x86/include/asm/kprobes.h
15490 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15491 #define RELATIVEJUMP_SIZE 5
15492 #define RELATIVECALL_OPCODE 0xe8
15493 #define RELATIVE_ADDR_SIZE 4
15494 -#define MAX_STACK_SIZE 64
15495 -#define MIN_STACK_SIZE(ADDR) \
15496 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15497 - THREAD_SIZE - (unsigned long)(ADDR))) \
15498 - ? (MAX_STACK_SIZE) \
15499 - : (((unsigned long)current_thread_info()) + \
15500 - THREAD_SIZE - (unsigned long)(ADDR)))
15501 +#define MAX_STACK_SIZE 64UL
15502 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15503
15504 #define flush_insn_slot(p) do { } while (0)
15505
15506 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15507 index 2d89e39..baee879 100644
15508 --- a/arch/x86/include/asm/local.h
15509 +++ b/arch/x86/include/asm/local.h
15510 @@ -10,33 +10,97 @@ typedef struct {
15511 atomic_long_t a;
15512 } local_t;
15513
15514 +typedef struct {
15515 + atomic_long_unchecked_t a;
15516 +} local_unchecked_t;
15517 +
15518 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15519
15520 #define local_read(l) atomic_long_read(&(l)->a)
15521 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15522 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15523 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15524
15525 static inline void local_inc(local_t *l)
15526 {
15527 - asm volatile(_ASM_INC "%0"
15528 + asm volatile(_ASM_INC "%0\n"
15529 +
15530 +#ifdef CONFIG_PAX_REFCOUNT
15531 + "jno 0f\n"
15532 + _ASM_DEC "%0\n"
15533 + "int $4\n0:\n"
15534 + _ASM_EXTABLE(0b, 0b)
15535 +#endif
15536 +
15537 + : "+m" (l->a.counter));
15538 +}
15539 +
15540 +static inline void local_inc_unchecked(local_unchecked_t *l)
15541 +{
15542 + asm volatile(_ASM_INC "%0\n"
15543 : "+m" (l->a.counter));
15544 }
15545
15546 static inline void local_dec(local_t *l)
15547 {
15548 - asm volatile(_ASM_DEC "%0"
15549 + asm volatile(_ASM_DEC "%0\n"
15550 +
15551 +#ifdef CONFIG_PAX_REFCOUNT
15552 + "jno 0f\n"
15553 + _ASM_INC "%0\n"
15554 + "int $4\n0:\n"
15555 + _ASM_EXTABLE(0b, 0b)
15556 +#endif
15557 +
15558 + : "+m" (l->a.counter));
15559 +}
15560 +
15561 +static inline void local_dec_unchecked(local_unchecked_t *l)
15562 +{
15563 + asm volatile(_ASM_DEC "%0\n"
15564 : "+m" (l->a.counter));
15565 }
15566
15567 static inline void local_add(long i, local_t *l)
15568 {
15569 - asm volatile(_ASM_ADD "%1,%0"
15570 + asm volatile(_ASM_ADD "%1,%0\n"
15571 +
15572 +#ifdef CONFIG_PAX_REFCOUNT
15573 + "jno 0f\n"
15574 + _ASM_SUB "%1,%0\n"
15575 + "int $4\n0:\n"
15576 + _ASM_EXTABLE(0b, 0b)
15577 +#endif
15578 +
15579 + : "+m" (l->a.counter)
15580 + : "ir" (i));
15581 +}
15582 +
15583 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15584 +{
15585 + asm volatile(_ASM_ADD "%1,%0\n"
15586 : "+m" (l->a.counter)
15587 : "ir" (i));
15588 }
15589
15590 static inline void local_sub(long i, local_t *l)
15591 {
15592 - asm volatile(_ASM_SUB "%1,%0"
15593 + asm volatile(_ASM_SUB "%1,%0\n"
15594 +
15595 +#ifdef CONFIG_PAX_REFCOUNT
15596 + "jno 0f\n"
15597 + _ASM_ADD "%1,%0\n"
15598 + "int $4\n0:\n"
15599 + _ASM_EXTABLE(0b, 0b)
15600 +#endif
15601 +
15602 + : "+m" (l->a.counter)
15603 + : "ir" (i));
15604 +}
15605 +
15606 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15607 +{
15608 + asm volatile(_ASM_SUB "%1,%0\n"
15609 : "+m" (l->a.counter)
15610 : "ir" (i));
15611 }
15612 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15613 {
15614 unsigned char c;
15615
15616 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15617 + asm volatile(_ASM_SUB "%2,%0\n"
15618 +
15619 +#ifdef CONFIG_PAX_REFCOUNT
15620 + "jno 0f\n"
15621 + _ASM_ADD "%2,%0\n"
15622 + "int $4\n0:\n"
15623 + _ASM_EXTABLE(0b, 0b)
15624 +#endif
15625 +
15626 + "sete %1\n"
15627 : "+m" (l->a.counter), "=qm" (c)
15628 : "ir" (i) : "memory");
15629 return c;
15630 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15631 {
15632 unsigned char c;
15633
15634 - asm volatile(_ASM_DEC "%0; sete %1"
15635 + asm volatile(_ASM_DEC "%0\n"
15636 +
15637 +#ifdef CONFIG_PAX_REFCOUNT
15638 + "jno 0f\n"
15639 + _ASM_INC "%0\n"
15640 + "int $4\n0:\n"
15641 + _ASM_EXTABLE(0b, 0b)
15642 +#endif
15643 +
15644 + "sete %1\n"
15645 : "+m" (l->a.counter), "=qm" (c)
15646 : : "memory");
15647 return c != 0;
15648 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15649 {
15650 unsigned char c;
15651
15652 - asm volatile(_ASM_INC "%0; sete %1"
15653 + asm volatile(_ASM_INC "%0\n"
15654 +
15655 +#ifdef CONFIG_PAX_REFCOUNT
15656 + "jno 0f\n"
15657 + _ASM_DEC "%0\n"
15658 + "int $4\n0:\n"
15659 + _ASM_EXTABLE(0b, 0b)
15660 +#endif
15661 +
15662 + "sete %1\n"
15663 : "+m" (l->a.counter), "=qm" (c)
15664 : : "memory");
15665 return c != 0;
15666 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15667 {
15668 unsigned char c;
15669
15670 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15671 + asm volatile(_ASM_ADD "%2,%0\n"
15672 +
15673 +#ifdef CONFIG_PAX_REFCOUNT
15674 + "jno 0f\n"
15675 + _ASM_SUB "%2,%0\n"
15676 + "int $4\n0:\n"
15677 + _ASM_EXTABLE(0b, 0b)
15678 +#endif
15679 +
15680 + "sets %1\n"
15681 : "+m" (l->a.counter), "=qm" (c)
15682 : "ir" (i) : "memory");
15683 return c;
15684 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15685 static inline long local_add_return(long i, local_t *l)
15686 {
15687 long __i = i;
15688 + asm volatile(_ASM_XADD "%0, %1\n"
15689 +
15690 +#ifdef CONFIG_PAX_REFCOUNT
15691 + "jno 0f\n"
15692 + _ASM_MOV "%0,%1\n"
15693 + "int $4\n0:\n"
15694 + _ASM_EXTABLE(0b, 0b)
15695 +#endif
15696 +
15697 + : "+r" (i), "+m" (l->a.counter)
15698 + : : "memory");
15699 + return i + __i;
15700 +}
15701 +
15702 +/**
15703 + * local_add_return_unchecked - add and return
15704 + * @i: integer value to add
15705 + * @l: pointer to type local_unchecked_t
15706 + *
15707 + * Atomically adds @i to @l and returns @i + @l
15708 + */
15709 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15710 +{
15711 + long __i = i;
15712 asm volatile(_ASM_XADD "%0, %1;"
15713 : "+r" (i), "+m" (l->a.counter)
15714 : : "memory");
15715 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15716
15717 #define local_cmpxchg(l, o, n) \
15718 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15719 +#define local_cmpxchg_unchecked(l, o, n) \
15720 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15721 /* Always has a lock prefix */
15722 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15723
15724 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15725 new file mode 100644
15726 index 0000000..2bfd3ba
15727 --- /dev/null
15728 +++ b/arch/x86/include/asm/mman.h
15729 @@ -0,0 +1,15 @@
15730 +#ifndef _X86_MMAN_H
15731 +#define _X86_MMAN_H
15732 +
15733 +#include <uapi/asm/mman.h>
15734 +
15735 +#ifdef __KERNEL__
15736 +#ifndef __ASSEMBLY__
15737 +#ifdef CONFIG_X86_32
15738 +#define arch_mmap_check i386_mmap_check
15739 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15740 +#endif
15741 +#endif
15742 +#endif
15743 +
15744 +#endif /* X86_MMAN_H */
15745 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15746 index 5f55e69..e20bfb1 100644
15747 --- a/arch/x86/include/asm/mmu.h
15748 +++ b/arch/x86/include/asm/mmu.h
15749 @@ -9,7 +9,7 @@
15750 * we put the segment information here.
15751 */
15752 typedef struct {
15753 - void *ldt;
15754 + struct desc_struct *ldt;
15755 int size;
15756
15757 #ifdef CONFIG_X86_64
15758 @@ -18,7 +18,19 @@ typedef struct {
15759 #endif
15760
15761 struct mutex lock;
15762 - void *vdso;
15763 + unsigned long vdso;
15764 +
15765 +#ifdef CONFIG_X86_32
15766 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15767 + unsigned long user_cs_base;
15768 + unsigned long user_cs_limit;
15769 +
15770 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15771 + cpumask_t cpu_user_cs_mask;
15772 +#endif
15773 +
15774 +#endif
15775 +#endif
15776 } mm_context_t;
15777
15778 #ifdef CONFIG_SMP
15779 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15780 index be12c53..4d24039 100644
15781 --- a/arch/x86/include/asm/mmu_context.h
15782 +++ b/arch/x86/include/asm/mmu_context.h
15783 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15784
15785 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15786 {
15787 +
15788 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15789 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15790 + unsigned int i;
15791 + pgd_t *pgd;
15792 +
15793 + pax_open_kernel();
15794 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15795 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15796 + set_pgd_batched(pgd+i, native_make_pgd(0));
15797 + pax_close_kernel();
15798 + }
15799 +#endif
15800 +
15801 #ifdef CONFIG_SMP
15802 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15803 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15804 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15805 struct task_struct *tsk)
15806 {
15807 unsigned cpu = smp_processor_id();
15808 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15809 + int tlbstate = TLBSTATE_OK;
15810 +#endif
15811
15812 if (likely(prev != next)) {
15813 #ifdef CONFIG_SMP
15814 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15815 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15816 +#endif
15817 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15818 this_cpu_write(cpu_tlbstate.active_mm, next);
15819 #endif
15820 cpumask_set_cpu(cpu, mm_cpumask(next));
15821
15822 /* Re-load page tables */
15823 +#ifdef CONFIG_PAX_PER_CPU_PGD
15824 + pax_open_kernel();
15825 +
15826 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15827 + if (static_cpu_has(X86_FEATURE_PCID))
15828 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15829 + else
15830 +#endif
15831 +
15832 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15833 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15834 + pax_close_kernel();
15835 + 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));
15836 +
15837 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15838 + if (static_cpu_has(X86_FEATURE_PCID)) {
15839 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15840 + u64 descriptor[2];
15841 + descriptor[0] = PCID_USER;
15842 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15843 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15844 + descriptor[0] = PCID_KERNEL;
15845 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15846 + }
15847 + } else {
15848 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15849 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15850 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15851 + else
15852 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15853 + }
15854 + } else
15855 +#endif
15856 +
15857 + load_cr3(get_cpu_pgd(cpu, kernel));
15858 +#else
15859 load_cr3(next->pgd);
15860 +#endif
15861
15862 /* Stop flush ipis for the previous mm */
15863 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15864 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15865 /* Load the LDT, if the LDT is different: */
15866 if (unlikely(prev->context.ldt != next->context.ldt))
15867 load_LDT_nolock(&next->context);
15868 +
15869 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15870 + if (!(__supported_pte_mask & _PAGE_NX)) {
15871 + smp_mb__before_clear_bit();
15872 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15873 + smp_mb__after_clear_bit();
15874 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15875 + }
15876 +#endif
15877 +
15878 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15879 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15880 + prev->context.user_cs_limit != next->context.user_cs_limit))
15881 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15882 +#ifdef CONFIG_SMP
15883 + else if (unlikely(tlbstate != TLBSTATE_OK))
15884 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15885 +#endif
15886 +#endif
15887 +
15888 }
15889 + else {
15890 +
15891 +#ifdef CONFIG_PAX_PER_CPU_PGD
15892 + pax_open_kernel();
15893 +
15894 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15895 + if (static_cpu_has(X86_FEATURE_PCID))
15896 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15897 + else
15898 +#endif
15899 +
15900 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15901 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15902 + pax_close_kernel();
15903 + 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));
15904 +
15905 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15906 + if (static_cpu_has(X86_FEATURE_PCID)) {
15907 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15908 + u64 descriptor[2];
15909 + descriptor[0] = PCID_USER;
15910 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15911 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15912 + descriptor[0] = PCID_KERNEL;
15913 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15914 + }
15915 + } else {
15916 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15917 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15918 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15919 + else
15920 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15921 + }
15922 + } else
15923 +#endif
15924 +
15925 + load_cr3(get_cpu_pgd(cpu, kernel));
15926 +#endif
15927 +
15928 #ifdef CONFIG_SMP
15929 - else {
15930 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15931 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15932
15933 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15934 * tlb flush IPI delivery. We must reload CR3
15935 * to make sure to use no freed page tables.
15936 */
15937 +
15938 +#ifndef CONFIG_PAX_PER_CPU_PGD
15939 load_cr3(next->pgd);
15940 +#endif
15941 +
15942 load_LDT_nolock(&next->context);
15943 +
15944 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15945 + if (!(__supported_pte_mask & _PAGE_NX))
15946 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15947 +#endif
15948 +
15949 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15950 +#ifdef CONFIG_PAX_PAGEEXEC
15951 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15952 +#endif
15953 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15954 +#endif
15955 +
15956 }
15957 +#endif
15958 }
15959 -#endif
15960 }
15961
15962 #define activate_mm(prev, next) \
15963 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15964 index e3b7819..b257c64 100644
15965 --- a/arch/x86/include/asm/module.h
15966 +++ b/arch/x86/include/asm/module.h
15967 @@ -5,6 +5,7 @@
15968
15969 #ifdef CONFIG_X86_64
15970 /* X86_64 does not define MODULE_PROC_FAMILY */
15971 +#define MODULE_PROC_FAMILY ""
15972 #elif defined CONFIG_M486
15973 #define MODULE_PROC_FAMILY "486 "
15974 #elif defined CONFIG_M586
15975 @@ -57,8 +58,20 @@
15976 #error unknown processor family
15977 #endif
15978
15979 -#ifdef CONFIG_X86_32
15980 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15981 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15982 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15983 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15984 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15985 +#else
15986 +#define MODULE_PAX_KERNEXEC ""
15987 #endif
15988
15989 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15990 +#define MODULE_PAX_UDEREF "UDEREF "
15991 +#else
15992 +#define MODULE_PAX_UDEREF ""
15993 +#endif
15994 +
15995 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15996 +
15997 #endif /* _ASM_X86_MODULE_H */
15998 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15999 index 86f9301..b365cda 100644
16000 --- a/arch/x86/include/asm/nmi.h
16001 +++ b/arch/x86/include/asm/nmi.h
16002 @@ -40,11 +40,11 @@ struct nmiaction {
16003 nmi_handler_t handler;
16004 unsigned long flags;
16005 const char *name;
16006 -};
16007 +} __do_const;
16008
16009 #define register_nmi_handler(t, fn, fg, n, init...) \
16010 ({ \
16011 - static struct nmiaction init fn##_na = { \
16012 + static const struct nmiaction init fn##_na = { \
16013 .handler = (fn), \
16014 .name = (n), \
16015 .flags = (fg), \
16016 @@ -52,7 +52,7 @@ struct nmiaction {
16017 __register_nmi_handler((t), &fn##_na); \
16018 })
16019
16020 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16021 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16022
16023 void unregister_nmi_handler(unsigned int, const char *);
16024
16025 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16026 index c878924..21f4889 100644
16027 --- a/arch/x86/include/asm/page.h
16028 +++ b/arch/x86/include/asm/page.h
16029 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16030 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16031
16032 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16033 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16034
16035 #define __boot_va(x) __va(x)
16036 #define __boot_pa(x) __pa(x)
16037 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16038 index 0f1ddee..e2fc3d1 100644
16039 --- a/arch/x86/include/asm/page_64.h
16040 +++ b/arch/x86/include/asm/page_64.h
16041 @@ -7,9 +7,9 @@
16042
16043 /* duplicated to the one in bootmem.h */
16044 extern unsigned long max_pfn;
16045 -extern unsigned long phys_base;
16046 +extern const unsigned long phys_base;
16047
16048 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16049 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16050 {
16051 unsigned long y = x - __START_KERNEL_map;
16052
16053 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16054 index cfdc9ee..3f7b5d6 100644
16055 --- a/arch/x86/include/asm/paravirt.h
16056 +++ b/arch/x86/include/asm/paravirt.h
16057 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16058 return (pmd_t) { ret };
16059 }
16060
16061 -static inline pmdval_t pmd_val(pmd_t pmd)
16062 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16063 {
16064 pmdval_t ret;
16065
16066 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16067 val);
16068 }
16069
16070 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16071 +{
16072 + pgdval_t val = native_pgd_val(pgd);
16073 +
16074 + if (sizeof(pgdval_t) > sizeof(long))
16075 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16076 + val, (u64)val >> 32);
16077 + else
16078 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16079 + val);
16080 +}
16081 +
16082 static inline void pgd_clear(pgd_t *pgdp)
16083 {
16084 set_pgd(pgdp, __pgd(0));
16085 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16086 pv_mmu_ops.set_fixmap(idx, phys, flags);
16087 }
16088
16089 +#ifdef CONFIG_PAX_KERNEXEC
16090 +static inline unsigned long pax_open_kernel(void)
16091 +{
16092 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16093 +}
16094 +
16095 +static inline unsigned long pax_close_kernel(void)
16096 +{
16097 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16098 +}
16099 +#else
16100 +static inline unsigned long pax_open_kernel(void) { return 0; }
16101 +static inline unsigned long pax_close_kernel(void) { return 0; }
16102 +#endif
16103 +
16104 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16105
16106 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16107 @@ -926,7 +953,7 @@ extern void default_banner(void);
16108
16109 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16110 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16111 -#define PARA_INDIRECT(addr) *%cs:addr
16112 +#define PARA_INDIRECT(addr) *%ss:addr
16113 #endif
16114
16115 #define INTERRUPT_RETURN \
16116 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16117 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16118 CLBR_NONE, \
16119 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16120 +
16121 +#define GET_CR0_INTO_RDI \
16122 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16123 + mov %rax,%rdi
16124 +
16125 +#define SET_RDI_INTO_CR0 \
16126 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16127 +
16128 +#define GET_CR3_INTO_RDI \
16129 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16130 + mov %rax,%rdi
16131 +
16132 +#define SET_RDI_INTO_CR3 \
16133 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16134 +
16135 #endif /* CONFIG_X86_32 */
16136
16137 #endif /* __ASSEMBLY__ */
16138 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16139 index 0db1fca..52310cc 100644
16140 --- a/arch/x86/include/asm/paravirt_types.h
16141 +++ b/arch/x86/include/asm/paravirt_types.h
16142 @@ -84,7 +84,7 @@ struct pv_init_ops {
16143 */
16144 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16145 unsigned long addr, unsigned len);
16146 -};
16147 +} __no_const;
16148
16149
16150 struct pv_lazy_ops {
16151 @@ -98,7 +98,7 @@ struct pv_time_ops {
16152 unsigned long long (*sched_clock)(void);
16153 unsigned long long (*steal_clock)(int cpu);
16154 unsigned long (*get_tsc_khz)(void);
16155 -};
16156 +} __no_const;
16157
16158 struct pv_cpu_ops {
16159 /* hooks for various privileged instructions */
16160 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16161
16162 void (*start_context_switch)(struct task_struct *prev);
16163 void (*end_context_switch)(struct task_struct *next);
16164 -};
16165 +} __no_const;
16166
16167 struct pv_irq_ops {
16168 /*
16169 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16170 unsigned long start_eip,
16171 unsigned long start_esp);
16172 #endif
16173 -};
16174 +} __no_const;
16175
16176 struct pv_mmu_ops {
16177 unsigned long (*read_cr2)(void);
16178 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16179 struct paravirt_callee_save make_pud;
16180
16181 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16182 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16183 #endif /* PAGETABLE_LEVELS == 4 */
16184 #endif /* PAGETABLE_LEVELS >= 3 */
16185
16186 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16187 an mfn. We can tell which is which from the index. */
16188 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16189 phys_addr_t phys, pgprot_t flags);
16190 +
16191 +#ifdef CONFIG_PAX_KERNEXEC
16192 + unsigned long (*pax_open_kernel)(void);
16193 + unsigned long (*pax_close_kernel)(void);
16194 +#endif
16195 +
16196 };
16197
16198 struct arch_spinlock;
16199 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16200 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16201 int (*spin_trylock)(struct arch_spinlock *lock);
16202 void (*spin_unlock)(struct arch_spinlock *lock);
16203 -};
16204 +} __no_const;
16205
16206 /* This contains all the paravirt structures: we get a convenient
16207 * number for each function using the offset which we use to indicate
16208 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16209 index b4389a4..7024269 100644
16210 --- a/arch/x86/include/asm/pgalloc.h
16211 +++ b/arch/x86/include/asm/pgalloc.h
16212 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16213 pmd_t *pmd, pte_t *pte)
16214 {
16215 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16216 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16217 +}
16218 +
16219 +static inline void pmd_populate_user(struct mm_struct *mm,
16220 + pmd_t *pmd, pte_t *pte)
16221 +{
16222 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16223 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16224 }
16225
16226 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16227
16228 #ifdef CONFIG_X86_PAE
16229 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16230 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16231 +{
16232 + pud_populate(mm, pudp, pmd);
16233 +}
16234 #else /* !CONFIG_X86_PAE */
16235 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16236 {
16237 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16238 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16239 }
16240 +
16241 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16242 +{
16243 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16244 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16245 +}
16246 #endif /* CONFIG_X86_PAE */
16247
16248 #if PAGETABLE_LEVELS > 3
16249 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16250 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16251 }
16252
16253 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16254 +{
16255 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16256 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16257 +}
16258 +
16259 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16260 {
16261 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16262 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16263 index 3bf2dd0..23d2a9f 100644
16264 --- a/arch/x86/include/asm/pgtable-2level.h
16265 +++ b/arch/x86/include/asm/pgtable-2level.h
16266 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16267
16268 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16269 {
16270 + pax_open_kernel();
16271 *pmdp = pmd;
16272 + pax_close_kernel();
16273 }
16274
16275 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16276 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16277 index 81bb91b..9392125 100644
16278 --- a/arch/x86/include/asm/pgtable-3level.h
16279 +++ b/arch/x86/include/asm/pgtable-3level.h
16280 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16281
16282 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16283 {
16284 + pax_open_kernel();
16285 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16286 + pax_close_kernel();
16287 }
16288
16289 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16290 {
16291 + pax_open_kernel();
16292 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16293 + pax_close_kernel();
16294 }
16295
16296 /*
16297 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16298 index 1c00631..845f898 100644
16299 --- a/arch/x86/include/asm/pgtable.h
16300 +++ b/arch/x86/include/asm/pgtable.h
16301 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16302
16303 #ifndef __PAGETABLE_PUD_FOLDED
16304 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16305 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16306 #define pgd_clear(pgd) native_pgd_clear(pgd)
16307 #endif
16308
16309 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16310
16311 #define arch_end_context_switch(prev) do {} while(0)
16312
16313 +#define pax_open_kernel() native_pax_open_kernel()
16314 +#define pax_close_kernel() native_pax_close_kernel()
16315 #endif /* CONFIG_PARAVIRT */
16316
16317 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16318 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16319 +
16320 +#ifdef CONFIG_PAX_KERNEXEC
16321 +static inline unsigned long native_pax_open_kernel(void)
16322 +{
16323 + unsigned long cr0;
16324 +
16325 + preempt_disable();
16326 + barrier();
16327 + cr0 = read_cr0() ^ X86_CR0_WP;
16328 + BUG_ON(cr0 & X86_CR0_WP);
16329 + write_cr0(cr0);
16330 + return cr0 ^ X86_CR0_WP;
16331 +}
16332 +
16333 +static inline unsigned long native_pax_close_kernel(void)
16334 +{
16335 + unsigned long cr0;
16336 +
16337 + cr0 = read_cr0() ^ X86_CR0_WP;
16338 + BUG_ON(!(cr0 & X86_CR0_WP));
16339 + write_cr0(cr0);
16340 + barrier();
16341 + preempt_enable_no_resched();
16342 + return cr0 ^ X86_CR0_WP;
16343 +}
16344 +#else
16345 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16346 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16347 +#endif
16348 +
16349 /*
16350 * The following only work if pte_present() is true.
16351 * Undefined behaviour if not..
16352 */
16353 +static inline int pte_user(pte_t pte)
16354 +{
16355 + return pte_val(pte) & _PAGE_USER;
16356 +}
16357 +
16358 static inline int pte_dirty(pte_t pte)
16359 {
16360 return pte_flags(pte) & _PAGE_DIRTY;
16361 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16362 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16363 }
16364
16365 +static inline unsigned long pgd_pfn(pgd_t pgd)
16366 +{
16367 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16368 +}
16369 +
16370 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16371
16372 static inline int pmd_large(pmd_t pte)
16373 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16374 return pte_clear_flags(pte, _PAGE_RW);
16375 }
16376
16377 +static inline pte_t pte_mkread(pte_t pte)
16378 +{
16379 + return __pte(pte_val(pte) | _PAGE_USER);
16380 +}
16381 +
16382 static inline pte_t pte_mkexec(pte_t pte)
16383 {
16384 - return pte_clear_flags(pte, _PAGE_NX);
16385 +#ifdef CONFIG_X86_PAE
16386 + if (__supported_pte_mask & _PAGE_NX)
16387 + return pte_clear_flags(pte, _PAGE_NX);
16388 + else
16389 +#endif
16390 + return pte_set_flags(pte, _PAGE_USER);
16391 +}
16392 +
16393 +static inline pte_t pte_exprotect(pte_t pte)
16394 +{
16395 +#ifdef CONFIG_X86_PAE
16396 + if (__supported_pte_mask & _PAGE_NX)
16397 + return pte_set_flags(pte, _PAGE_NX);
16398 + else
16399 +#endif
16400 + return pte_clear_flags(pte, _PAGE_USER);
16401 }
16402
16403 static inline pte_t pte_mkdirty(pte_t pte)
16404 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16405 #endif
16406
16407 #ifndef __ASSEMBLY__
16408 +
16409 +#ifdef CONFIG_PAX_PER_CPU_PGD
16410 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16411 +enum cpu_pgd_type {kernel = 0, user = 1};
16412 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16413 +{
16414 + return cpu_pgd[cpu][type];
16415 +}
16416 +#endif
16417 +
16418 #include <linux/mm_types.h>
16419 #include <linux/log2.h>
16420
16421 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16422 * Currently stuck as a macro due to indirect forward reference to
16423 * linux/mmzone.h's __section_mem_map_addr() definition:
16424 */
16425 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16426 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16427
16428 /* Find an entry in the second-level page table.. */
16429 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16430 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16431 * Currently stuck as a macro due to indirect forward reference to
16432 * linux/mmzone.h's __section_mem_map_addr() definition:
16433 */
16434 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16435 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16436
16437 /* to find an entry in a page-table-directory. */
16438 static inline unsigned long pud_index(unsigned long address)
16439 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16440
16441 static inline int pgd_bad(pgd_t pgd)
16442 {
16443 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16444 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16445 }
16446
16447 static inline int pgd_none(pgd_t pgd)
16448 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16449 * pgd_offset() returns a (pgd_t *)
16450 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16451 */
16452 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16453 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16454 +
16455 +#ifdef CONFIG_PAX_PER_CPU_PGD
16456 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16457 +#endif
16458 +
16459 /*
16460 * a shortcut which implies the use of the kernel's pgd, instead
16461 * of a process's
16462 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16463 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16464 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16465
16466 +#ifdef CONFIG_X86_32
16467 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16468 +#else
16469 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16470 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16471 +
16472 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16473 +#ifdef __ASSEMBLY__
16474 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16475 +#else
16476 +extern unsigned long pax_user_shadow_base;
16477 +extern pgdval_t clone_pgd_mask;
16478 +#endif
16479 +#endif
16480 +
16481 +#endif
16482 +
16483 #ifndef __ASSEMBLY__
16484
16485 extern int direct_gbpages;
16486 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16487 * dst and src can be on the same page, but the range must not overlap,
16488 * and must not cross a page boundary.
16489 */
16490 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16491 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16492 {
16493 - memcpy(dst, src, count * sizeof(pgd_t));
16494 + pax_open_kernel();
16495 + while (count--)
16496 + *dst++ = *src++;
16497 + pax_close_kernel();
16498 }
16499
16500 +#ifdef CONFIG_PAX_PER_CPU_PGD
16501 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16502 +#endif
16503 +
16504 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16505 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16506 +#else
16507 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16508 +#endif
16509 +
16510 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16511 static inline int page_level_shift(enum pg_level level)
16512 {
16513 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16514 index 9ee3221..b979c6b 100644
16515 --- a/arch/x86/include/asm/pgtable_32.h
16516 +++ b/arch/x86/include/asm/pgtable_32.h
16517 @@ -25,9 +25,6 @@
16518 struct mm_struct;
16519 struct vm_area_struct;
16520
16521 -extern pgd_t swapper_pg_dir[1024];
16522 -extern pgd_t initial_page_table[1024];
16523 -
16524 static inline void pgtable_cache_init(void) { }
16525 static inline void check_pgt_cache(void) { }
16526 void paging_init(void);
16527 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16528 # include <asm/pgtable-2level.h>
16529 #endif
16530
16531 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16532 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16533 +#ifdef CONFIG_X86_PAE
16534 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16535 +#endif
16536 +
16537 #if defined(CONFIG_HIGHPTE)
16538 #define pte_offset_map(dir, address) \
16539 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16540 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16541 /* Clear a kernel PTE and flush it from the TLB */
16542 #define kpte_clear_flush(ptep, vaddr) \
16543 do { \
16544 + pax_open_kernel(); \
16545 pte_clear(&init_mm, (vaddr), (ptep)); \
16546 + pax_close_kernel(); \
16547 __flush_tlb_one((vaddr)); \
16548 } while (0)
16549
16550 #endif /* !__ASSEMBLY__ */
16551
16552 +#define HAVE_ARCH_UNMAPPED_AREA
16553 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16554 +
16555 /*
16556 * kern_addr_valid() is (1) for FLATMEM and (0) for
16557 * SPARSEMEM and DISCONTIGMEM
16558 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16559 index ed5903b..c7fe163 100644
16560 --- a/arch/x86/include/asm/pgtable_32_types.h
16561 +++ b/arch/x86/include/asm/pgtable_32_types.h
16562 @@ -8,7 +8,7 @@
16563 */
16564 #ifdef CONFIG_X86_PAE
16565 # include <asm/pgtable-3level_types.h>
16566 -# define PMD_SIZE (1UL << PMD_SHIFT)
16567 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16568 # define PMD_MASK (~(PMD_SIZE - 1))
16569 #else
16570 # include <asm/pgtable-2level_types.h>
16571 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16572 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16573 #endif
16574
16575 +#ifdef CONFIG_PAX_KERNEXEC
16576 +#ifndef __ASSEMBLY__
16577 +extern unsigned char MODULES_EXEC_VADDR[];
16578 +extern unsigned char MODULES_EXEC_END[];
16579 +#endif
16580 +#include <asm/boot.h>
16581 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16582 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16583 +#else
16584 +#define ktla_ktva(addr) (addr)
16585 +#define ktva_ktla(addr) (addr)
16586 +#endif
16587 +
16588 #define MODULES_VADDR VMALLOC_START
16589 #define MODULES_END VMALLOC_END
16590 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16591 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16592 index e22c1db..23a625a 100644
16593 --- a/arch/x86/include/asm/pgtable_64.h
16594 +++ b/arch/x86/include/asm/pgtable_64.h
16595 @@ -16,10 +16,14 @@
16596
16597 extern pud_t level3_kernel_pgt[512];
16598 extern pud_t level3_ident_pgt[512];
16599 +extern pud_t level3_vmalloc_start_pgt[512];
16600 +extern pud_t level3_vmalloc_end_pgt[512];
16601 +extern pud_t level3_vmemmap_pgt[512];
16602 +extern pud_t level2_vmemmap_pgt[512];
16603 extern pmd_t level2_kernel_pgt[512];
16604 extern pmd_t level2_fixmap_pgt[512];
16605 -extern pmd_t level2_ident_pgt[512];
16606 -extern pgd_t init_level4_pgt[];
16607 +extern pmd_t level2_ident_pgt[512*2];
16608 +extern pgd_t init_level4_pgt[512];
16609
16610 #define swapper_pg_dir init_level4_pgt
16611
16612 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16613
16614 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16615 {
16616 + pax_open_kernel();
16617 *pmdp = pmd;
16618 + pax_close_kernel();
16619 }
16620
16621 static inline void native_pmd_clear(pmd_t *pmd)
16622 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16623
16624 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16625 {
16626 + pax_open_kernel();
16627 *pudp = pud;
16628 + pax_close_kernel();
16629 }
16630
16631 static inline void native_pud_clear(pud_t *pud)
16632 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16633
16634 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16635 {
16636 + pax_open_kernel();
16637 + *pgdp = pgd;
16638 + pax_close_kernel();
16639 +}
16640 +
16641 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16642 +{
16643 *pgdp = pgd;
16644 }
16645
16646 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16647 index 2d88344..4679fc3 100644
16648 --- a/arch/x86/include/asm/pgtable_64_types.h
16649 +++ b/arch/x86/include/asm/pgtable_64_types.h
16650 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16651 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16652 #define MODULES_END _AC(0xffffffffff000000, UL)
16653 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16654 +#define MODULES_EXEC_VADDR MODULES_VADDR
16655 +#define MODULES_EXEC_END MODULES_END
16656 +
16657 +#define ktla_ktva(addr) (addr)
16658 +#define ktva_ktla(addr) (addr)
16659
16660 #define EARLY_DYNAMIC_PAGE_TABLES 64
16661
16662 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16663 index f4843e0..a2526f8 100644
16664 --- a/arch/x86/include/asm/pgtable_types.h
16665 +++ b/arch/x86/include/asm/pgtable_types.h
16666 @@ -16,13 +16,12 @@
16667 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16668 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16669 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16670 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16671 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16672 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16673 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16674 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16675 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16676 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16677 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16678 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16679 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16680 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16681
16682 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16683 @@ -40,7 +39,6 @@
16684 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16685 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16686 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16687 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16688 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16689 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16690 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16691 @@ -84,8 +82,10 @@
16692
16693 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16694 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16695 -#else
16696 +#elif defined(CONFIG_KMEMCHECK)
16697 #define _PAGE_NX (_AT(pteval_t, 0))
16698 +#else
16699 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16700 #endif
16701
16702 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16703 @@ -143,6 +143,9 @@
16704 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16705 _PAGE_ACCESSED)
16706
16707 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16708 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16709 +
16710 #define __PAGE_KERNEL_EXEC \
16711 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16712 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16713 @@ -153,7 +156,7 @@
16714 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16715 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16716 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16717 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16718 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16719 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16720 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16721 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16722 @@ -215,8 +218,8 @@
16723 * bits are combined, this will alow user to access the high address mapped
16724 * VDSO in the presence of CONFIG_COMPAT_VDSO
16725 */
16726 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16727 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16728 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16729 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16730 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16731 #endif
16732
16733 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16734 {
16735 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16736 }
16737 +#endif
16738
16739 +#if PAGETABLE_LEVELS == 3
16740 +#include <asm-generic/pgtable-nopud.h>
16741 +#endif
16742 +
16743 +#if PAGETABLE_LEVELS == 2
16744 +#include <asm-generic/pgtable-nopmd.h>
16745 +#endif
16746 +
16747 +#ifndef __ASSEMBLY__
16748 #if PAGETABLE_LEVELS > 3
16749 typedef struct { pudval_t pud; } pud_t;
16750
16751 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16752 return pud.pud;
16753 }
16754 #else
16755 -#include <asm-generic/pgtable-nopud.h>
16756 -
16757 static inline pudval_t native_pud_val(pud_t pud)
16758 {
16759 return native_pgd_val(pud.pgd);
16760 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16761 return pmd.pmd;
16762 }
16763 #else
16764 -#include <asm-generic/pgtable-nopmd.h>
16765 -
16766 static inline pmdval_t native_pmd_val(pmd_t pmd)
16767 {
16768 return native_pgd_val(pmd.pud.pgd);
16769 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16770
16771 extern pteval_t __supported_pte_mask;
16772 extern void set_nx(void);
16773 -extern int nx_enabled;
16774
16775 #define pgprot_writecombine pgprot_writecombine
16776 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16777 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16778 index 24cf5ae..4d9fa2d 100644
16779 --- a/arch/x86/include/asm/processor.h
16780 +++ b/arch/x86/include/asm/processor.h
16781 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16782 : "memory");
16783 }
16784
16785 +/* invpcid (%rdx),%rax */
16786 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16787 +
16788 +#define INVPCID_SINGLE_ADDRESS 0UL
16789 +#define INVPCID_SINGLE_CONTEXT 1UL
16790 +#define INVPCID_ALL_GLOBAL 2UL
16791 +#define INVPCID_ALL_MONGLOBAL 3UL
16792 +
16793 +#define PCID_KERNEL 0UL
16794 +#define PCID_USER 1UL
16795 +#define PCID_NOFLUSH (1UL << 63)
16796 +
16797 static inline void load_cr3(pgd_t *pgdir)
16798 {
16799 - write_cr3(__pa(pgdir));
16800 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16801 }
16802
16803 #ifdef CONFIG_X86_32
16804 @@ -283,7 +295,7 @@ struct tss_struct {
16805
16806 } ____cacheline_aligned;
16807
16808 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16809 +extern struct tss_struct init_tss[NR_CPUS];
16810
16811 /*
16812 * Save the original ist values for checking stack pointers during debugging
16813 @@ -453,6 +465,7 @@ struct thread_struct {
16814 unsigned short ds;
16815 unsigned short fsindex;
16816 unsigned short gsindex;
16817 + unsigned short ss;
16818 #endif
16819 #ifdef CONFIG_X86_32
16820 unsigned long ip;
16821 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16822 extern unsigned long mmu_cr4_features;
16823 extern u32 *trampoline_cr4_features;
16824
16825 -static inline void set_in_cr4(unsigned long mask)
16826 -{
16827 - unsigned long cr4;
16828 -
16829 - mmu_cr4_features |= mask;
16830 - if (trampoline_cr4_features)
16831 - *trampoline_cr4_features = mmu_cr4_features;
16832 - cr4 = read_cr4();
16833 - cr4 |= mask;
16834 - write_cr4(cr4);
16835 -}
16836 -
16837 -static inline void clear_in_cr4(unsigned long mask)
16838 -{
16839 - unsigned long cr4;
16840 -
16841 - mmu_cr4_features &= ~mask;
16842 - if (trampoline_cr4_features)
16843 - *trampoline_cr4_features = mmu_cr4_features;
16844 - cr4 = read_cr4();
16845 - cr4 &= ~mask;
16846 - write_cr4(cr4);
16847 -}
16848 +extern void set_in_cr4(unsigned long mask);
16849 +extern void clear_in_cr4(unsigned long mask);
16850
16851 typedef struct {
16852 unsigned long seg;
16853 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16854 */
16855 #define TASK_SIZE PAGE_OFFSET
16856 #define TASK_SIZE_MAX TASK_SIZE
16857 +
16858 +#ifdef CONFIG_PAX_SEGMEXEC
16859 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16860 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16861 +#else
16862 #define STACK_TOP TASK_SIZE
16863 -#define STACK_TOP_MAX STACK_TOP
16864 +#endif
16865 +
16866 +#define STACK_TOP_MAX TASK_SIZE
16867
16868 #define INIT_THREAD { \
16869 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16870 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16871 .vm86_info = NULL, \
16872 .sysenter_cs = __KERNEL_CS, \
16873 .io_bitmap_ptr = NULL, \
16874 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16875 */
16876 #define INIT_TSS { \
16877 .x86_tss = { \
16878 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16879 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16880 .ss0 = __KERNEL_DS, \
16881 .ss1 = __KERNEL_CS, \
16882 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16883 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16884 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16885
16886 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16887 -#define KSTK_TOP(info) \
16888 -({ \
16889 - unsigned long *__ptr = (unsigned long *)(info); \
16890 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16891 -})
16892 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16893
16894 /*
16895 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16896 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16897 #define task_pt_regs(task) \
16898 ({ \
16899 struct pt_regs *__regs__; \
16900 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16901 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16902 __regs__ - 1; \
16903 })
16904
16905 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16906 /*
16907 * User space process size. 47bits minus one guard page.
16908 */
16909 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16910 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16911
16912 /* This decides where the kernel will search for a free chunk of vm
16913 * space during mmap's.
16914 */
16915 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16916 - 0xc0000000 : 0xFFFFe000)
16917 + 0xc0000000 : 0xFFFFf000)
16918
16919 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16920 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16921 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16922 #define STACK_TOP_MAX TASK_SIZE_MAX
16923
16924 #define INIT_THREAD { \
16925 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16926 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16927 }
16928
16929 #define INIT_TSS { \
16930 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16931 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16932 }
16933
16934 /*
16935 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16936 */
16937 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16938
16939 +#ifdef CONFIG_PAX_SEGMEXEC
16940 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16941 +#endif
16942 +
16943 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16944
16945 /* Get/set a process' ability to use the timestamp counter instruction */
16946 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16947 extern u16 amd_get_nb_id(int cpu);
16948
16949 struct aperfmperf {
16950 - u64 aperf, mperf;
16951 + u64 aperf __intentional_overflow(0);
16952 + u64 mperf __intentional_overflow(0);
16953 };
16954
16955 static inline void get_aperfmperf(struct aperfmperf *am)
16956 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16957 return ratio;
16958 }
16959
16960 -extern unsigned long arch_align_stack(unsigned long sp);
16961 +#define arch_align_stack(x) ((x) & ~0xfUL)
16962 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16963
16964 void default_idle(void);
16965 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16966 #define xen_set_default_idle 0
16967 #endif
16968
16969 -void stop_this_cpu(void *dummy);
16970 +void stop_this_cpu(void *dummy) __noreturn;
16971 void df_debug(struct pt_regs *regs, long error_code);
16972 #endif /* _ASM_X86_PROCESSOR_H */
16973 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16974 index 942a086..6c26446 100644
16975 --- a/arch/x86/include/asm/ptrace.h
16976 +++ b/arch/x86/include/asm/ptrace.h
16977 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16978 }
16979
16980 /*
16981 - * user_mode_vm(regs) determines whether a register set came from user mode.
16982 + * user_mode(regs) determines whether a register set came from user mode.
16983 * This is true if V8086 mode was enabled OR if the register set was from
16984 * protected mode with RPL-3 CS value. This tricky test checks that with
16985 * one comparison. Many places in the kernel can bypass this full check
16986 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16987 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16988 + * be used.
16989 */
16990 -static inline int user_mode(struct pt_regs *regs)
16991 +static inline int user_mode_novm(struct pt_regs *regs)
16992 {
16993 #ifdef CONFIG_X86_32
16994 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16995 #else
16996 - return !!(regs->cs & 3);
16997 + return !!(regs->cs & SEGMENT_RPL_MASK);
16998 #endif
16999 }
17000
17001 -static inline int user_mode_vm(struct pt_regs *regs)
17002 +static inline int user_mode(struct pt_regs *regs)
17003 {
17004 #ifdef CONFIG_X86_32
17005 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17006 USER_RPL;
17007 #else
17008 - return user_mode(regs);
17009 + return user_mode_novm(regs);
17010 #endif
17011 }
17012
17013 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17014 #ifdef CONFIG_X86_64
17015 static inline bool user_64bit_mode(struct pt_regs *regs)
17016 {
17017 + unsigned long cs = regs->cs & 0xffff;
17018 #ifndef CONFIG_PARAVIRT
17019 /*
17020 * On non-paravirt systems, this is the only long mode CPL 3
17021 * selector. We do not allow long mode selectors in the LDT.
17022 */
17023 - return regs->cs == __USER_CS;
17024 + return cs == __USER_CS;
17025 #else
17026 /* Headers are too twisted for this to go in paravirt.h. */
17027 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17028 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17029 #endif
17030 }
17031
17032 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17033 * Traps from the kernel do not save sp and ss.
17034 * Use the helper function to retrieve sp.
17035 */
17036 - if (offset == offsetof(struct pt_regs, sp) &&
17037 - regs->cs == __KERNEL_CS)
17038 - return kernel_stack_pointer(regs);
17039 + if (offset == offsetof(struct pt_regs, sp)) {
17040 + unsigned long cs = regs->cs & 0xffff;
17041 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17042 + return kernel_stack_pointer(regs);
17043 + }
17044 #endif
17045 return *(unsigned long *)((unsigned long)regs + offset);
17046 }
17047 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17048 index 9c6b890..5305f53 100644
17049 --- a/arch/x86/include/asm/realmode.h
17050 +++ b/arch/x86/include/asm/realmode.h
17051 @@ -22,16 +22,14 @@ struct real_mode_header {
17052 #endif
17053 /* APM/BIOS reboot */
17054 u32 machine_real_restart_asm;
17055 -#ifdef CONFIG_X86_64
17056 u32 machine_real_restart_seg;
17057 -#endif
17058 };
17059
17060 /* This must match data at trampoline_32/64.S */
17061 struct trampoline_header {
17062 #ifdef CONFIG_X86_32
17063 u32 start;
17064 - u16 gdt_pad;
17065 + u16 boot_cs;
17066 u16 gdt_limit;
17067 u32 gdt_base;
17068 #else
17069 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17070 index a82c4f1..ac45053 100644
17071 --- a/arch/x86/include/asm/reboot.h
17072 +++ b/arch/x86/include/asm/reboot.h
17073 @@ -6,13 +6,13 @@
17074 struct pt_regs;
17075
17076 struct machine_ops {
17077 - void (*restart)(char *cmd);
17078 - void (*halt)(void);
17079 - void (*power_off)(void);
17080 + void (* __noreturn restart)(char *cmd);
17081 + void (* __noreturn halt)(void);
17082 + void (* __noreturn power_off)(void);
17083 void (*shutdown)(void);
17084 void (*crash_shutdown)(struct pt_regs *);
17085 - void (*emergency_restart)(void);
17086 -};
17087 + void (* __noreturn emergency_restart)(void);
17088 +} __no_const;
17089
17090 extern struct machine_ops machine_ops;
17091
17092 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17093 index cad82c9..2e5c5c1 100644
17094 --- a/arch/x86/include/asm/rwsem.h
17095 +++ b/arch/x86/include/asm/rwsem.h
17096 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17097 {
17098 asm volatile("# beginning down_read\n\t"
17099 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17100 +
17101 +#ifdef CONFIG_PAX_REFCOUNT
17102 + "jno 0f\n"
17103 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17104 + "int $4\n0:\n"
17105 + _ASM_EXTABLE(0b, 0b)
17106 +#endif
17107 +
17108 /* adds 0x00000001 */
17109 " jns 1f\n"
17110 " call call_rwsem_down_read_failed\n"
17111 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17112 "1:\n\t"
17113 " mov %1,%2\n\t"
17114 " add %3,%2\n\t"
17115 +
17116 +#ifdef CONFIG_PAX_REFCOUNT
17117 + "jno 0f\n"
17118 + "sub %3,%2\n"
17119 + "int $4\n0:\n"
17120 + _ASM_EXTABLE(0b, 0b)
17121 +#endif
17122 +
17123 " jle 2f\n\t"
17124 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17125 " jnz 1b\n\t"
17126 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17127 long tmp;
17128 asm volatile("# beginning down_write\n\t"
17129 LOCK_PREFIX " xadd %1,(%2)\n\t"
17130 +
17131 +#ifdef CONFIG_PAX_REFCOUNT
17132 + "jno 0f\n"
17133 + "mov %1,(%2)\n"
17134 + "int $4\n0:\n"
17135 + _ASM_EXTABLE(0b, 0b)
17136 +#endif
17137 +
17138 /* adds 0xffff0001, returns the old value */
17139 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17140 /* was the active mask 0 before? */
17141 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17142 long tmp;
17143 asm volatile("# beginning __up_read\n\t"
17144 LOCK_PREFIX " xadd %1,(%2)\n\t"
17145 +
17146 +#ifdef CONFIG_PAX_REFCOUNT
17147 + "jno 0f\n"
17148 + "mov %1,(%2)\n"
17149 + "int $4\n0:\n"
17150 + _ASM_EXTABLE(0b, 0b)
17151 +#endif
17152 +
17153 /* subtracts 1, returns the old value */
17154 " jns 1f\n\t"
17155 " call call_rwsem_wake\n" /* expects old value in %edx */
17156 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17157 long tmp;
17158 asm volatile("# beginning __up_write\n\t"
17159 LOCK_PREFIX " xadd %1,(%2)\n\t"
17160 +
17161 +#ifdef CONFIG_PAX_REFCOUNT
17162 + "jno 0f\n"
17163 + "mov %1,(%2)\n"
17164 + "int $4\n0:\n"
17165 + _ASM_EXTABLE(0b, 0b)
17166 +#endif
17167 +
17168 /* subtracts 0xffff0001, returns the old value */
17169 " jns 1f\n\t"
17170 " call call_rwsem_wake\n" /* expects old value in %edx */
17171 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17172 {
17173 asm volatile("# beginning __downgrade_write\n\t"
17174 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17175 +
17176 +#ifdef CONFIG_PAX_REFCOUNT
17177 + "jno 0f\n"
17178 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17179 + "int $4\n0:\n"
17180 + _ASM_EXTABLE(0b, 0b)
17181 +#endif
17182 +
17183 /*
17184 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17185 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17186 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17187 */
17188 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17189 {
17190 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17191 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17192 +
17193 +#ifdef CONFIG_PAX_REFCOUNT
17194 + "jno 0f\n"
17195 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17196 + "int $4\n0:\n"
17197 + _ASM_EXTABLE(0b, 0b)
17198 +#endif
17199 +
17200 : "+m" (sem->count)
17201 : "er" (delta));
17202 }
17203 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17204 */
17205 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17206 {
17207 - return delta + xadd(&sem->count, delta);
17208 + return delta + xadd_check_overflow(&sem->count, delta);
17209 }
17210
17211 #endif /* __KERNEL__ */
17212 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17213 index c48a950..bc40804 100644
17214 --- a/arch/x86/include/asm/segment.h
17215 +++ b/arch/x86/include/asm/segment.h
17216 @@ -64,10 +64,15 @@
17217 * 26 - ESPFIX small SS
17218 * 27 - per-cpu [ offset to per-cpu data area ]
17219 * 28 - stack_canary-20 [ for stack protector ]
17220 - * 29 - unused
17221 - * 30 - unused
17222 + * 29 - PCI BIOS CS
17223 + * 30 - PCI BIOS DS
17224 * 31 - TSS for double fault handler
17225 */
17226 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17227 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17228 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17229 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17230 +
17231 #define GDT_ENTRY_TLS_MIN 6
17232 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17233
17234 @@ -79,6 +84,8 @@
17235
17236 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17237
17238 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17239 +
17240 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17241
17242 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17243 @@ -104,6 +111,12 @@
17244 #define __KERNEL_STACK_CANARY 0
17245 #endif
17246
17247 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17248 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17249 +
17250 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17251 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17252 +
17253 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17254
17255 /*
17256 @@ -141,7 +154,7 @@
17257 */
17258
17259 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17260 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17261 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17262
17263
17264 #else
17265 @@ -165,6 +178,8 @@
17266 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17267 #define __USER32_DS __USER_DS
17268
17269 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17270 +
17271 #define GDT_ENTRY_TSS 8 /* needs two entries */
17272 #define GDT_ENTRY_LDT 10 /* needs two entries */
17273 #define GDT_ENTRY_TLS_MIN 12
17274 @@ -173,6 +188,8 @@
17275 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17276 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17277
17278 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17279 +
17280 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17281 #define FS_TLS 0
17282 #define GS_TLS 1
17283 @@ -180,12 +197,14 @@
17284 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17285 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17286
17287 -#define GDT_ENTRIES 16
17288 +#define GDT_ENTRIES 17
17289
17290 #endif
17291
17292 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17293 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17294 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17295 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17296 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17297 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17298 #ifndef CONFIG_PARAVIRT
17299 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17300 {
17301 unsigned long __limit;
17302 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17303 - return __limit + 1;
17304 + return __limit;
17305 }
17306
17307 #endif /* !__ASSEMBLY__ */
17308 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17309 index 8d3120f..352b440 100644
17310 --- a/arch/x86/include/asm/smap.h
17311 +++ b/arch/x86/include/asm/smap.h
17312 @@ -25,11 +25,40 @@
17313
17314 #include <asm/alternative-asm.h>
17315
17316 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17317 +#define ASM_PAX_OPEN_USERLAND \
17318 + 661: jmp 663f; \
17319 + .pushsection .altinstr_replacement, "a" ; \
17320 + 662: pushq %rax; nop; \
17321 + .popsection ; \
17322 + .pushsection .altinstructions, "a" ; \
17323 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17324 + .popsection ; \
17325 + call __pax_open_userland; \
17326 + popq %rax; \
17327 + 663:
17328 +
17329 +#define ASM_PAX_CLOSE_USERLAND \
17330 + 661: jmp 663f; \
17331 + .pushsection .altinstr_replacement, "a" ; \
17332 + 662: pushq %rax; nop; \
17333 + .popsection; \
17334 + .pushsection .altinstructions, "a" ; \
17335 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17336 + .popsection; \
17337 + call __pax_close_userland; \
17338 + popq %rax; \
17339 + 663:
17340 +#else
17341 +#define ASM_PAX_OPEN_USERLAND
17342 +#define ASM_PAX_CLOSE_USERLAND
17343 +#endif
17344 +
17345 #ifdef CONFIG_X86_SMAP
17346
17347 #define ASM_CLAC \
17348 661: ASM_NOP3 ; \
17349 - .pushsection .altinstr_replacement, "ax" ; \
17350 + .pushsection .altinstr_replacement, "a" ; \
17351 662: __ASM_CLAC ; \
17352 .popsection ; \
17353 .pushsection .altinstructions, "a" ; \
17354 @@ -38,7 +67,7 @@
17355
17356 #define ASM_STAC \
17357 661: ASM_NOP3 ; \
17358 - .pushsection .altinstr_replacement, "ax" ; \
17359 + .pushsection .altinstr_replacement, "a" ; \
17360 662: __ASM_STAC ; \
17361 .popsection ; \
17362 .pushsection .altinstructions, "a" ; \
17363 @@ -56,6 +85,37 @@
17364
17365 #include <asm/alternative.h>
17366
17367 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17368 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17369 +
17370 +extern void __pax_open_userland(void);
17371 +static __always_inline unsigned long pax_open_userland(void)
17372 +{
17373 +
17374 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17375 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17376 + :
17377 + : [open] "i" (__pax_open_userland)
17378 + : "memory", "rax");
17379 +#endif
17380 +
17381 + return 0;
17382 +}
17383 +
17384 +extern void __pax_close_userland(void);
17385 +static __always_inline unsigned long pax_close_userland(void)
17386 +{
17387 +
17388 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17389 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17390 + :
17391 + : [close] "i" (__pax_close_userland)
17392 + : "memory", "rax");
17393 +#endif
17394 +
17395 + return 0;
17396 +}
17397 +
17398 #ifdef CONFIG_X86_SMAP
17399
17400 static __always_inline void clac(void)
17401 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17402 index 4137890..03fa172 100644
17403 --- a/arch/x86/include/asm/smp.h
17404 +++ b/arch/x86/include/asm/smp.h
17405 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17406 /* cpus sharing the last level cache: */
17407 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17408 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17409 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17410 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17411
17412 static inline struct cpumask *cpu_sibling_mask(int cpu)
17413 {
17414 @@ -79,7 +79,7 @@ struct smp_ops {
17415
17416 void (*send_call_func_ipi)(const struct cpumask *mask);
17417 void (*send_call_func_single_ipi)(int cpu);
17418 -};
17419 +} __no_const;
17420
17421 /* Globals due to paravirt */
17422 extern void set_cpu_sibling_map(int cpu);
17423 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17424 extern int safe_smp_processor_id(void);
17425
17426 #elif defined(CONFIG_X86_64_SMP)
17427 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17428 -
17429 -#define stack_smp_processor_id() \
17430 -({ \
17431 - struct thread_info *ti; \
17432 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17433 - ti->cpu; \
17434 -})
17435 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17436 +#define stack_smp_processor_id() raw_smp_processor_id()
17437 #define safe_smp_processor_id() smp_processor_id()
17438
17439 #endif
17440 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17441 index e3ddd7d..3611fce 100644
17442 --- a/arch/x86/include/asm/spinlock.h
17443 +++ b/arch/x86/include/asm/spinlock.h
17444 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17445 static inline void arch_read_lock(arch_rwlock_t *rw)
17446 {
17447 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17448 +
17449 +#ifdef CONFIG_PAX_REFCOUNT
17450 + "jno 0f\n"
17451 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17452 + "int $4\n0:\n"
17453 + _ASM_EXTABLE(0b, 0b)
17454 +#endif
17455 +
17456 "jns 1f\n"
17457 "call __read_lock_failed\n\t"
17458 "1:\n"
17459 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17460 static inline void arch_write_lock(arch_rwlock_t *rw)
17461 {
17462 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17463 +
17464 +#ifdef CONFIG_PAX_REFCOUNT
17465 + "jno 0f\n"
17466 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17467 + "int $4\n0:\n"
17468 + _ASM_EXTABLE(0b, 0b)
17469 +#endif
17470 +
17471 "jz 1f\n"
17472 "call __write_lock_failed\n\t"
17473 "1:\n"
17474 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17475
17476 static inline void arch_read_unlock(arch_rwlock_t *rw)
17477 {
17478 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17479 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17480 +
17481 +#ifdef CONFIG_PAX_REFCOUNT
17482 + "jno 0f\n"
17483 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17484 + "int $4\n0:\n"
17485 + _ASM_EXTABLE(0b, 0b)
17486 +#endif
17487 +
17488 :"+m" (rw->lock) : : "memory");
17489 }
17490
17491 static inline void arch_write_unlock(arch_rwlock_t *rw)
17492 {
17493 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17494 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17495 +
17496 +#ifdef CONFIG_PAX_REFCOUNT
17497 + "jno 0f\n"
17498 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17499 + "int $4\n0:\n"
17500 + _ASM_EXTABLE(0b, 0b)
17501 +#endif
17502 +
17503 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17504 }
17505
17506 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17507 index 6a99859..03cb807 100644
17508 --- a/arch/x86/include/asm/stackprotector.h
17509 +++ b/arch/x86/include/asm/stackprotector.h
17510 @@ -47,7 +47,7 @@
17511 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17512 */
17513 #define GDT_STACK_CANARY_INIT \
17514 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17515 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17516
17517 /*
17518 * Initialize the stackprotector canary value.
17519 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17520
17521 static inline void load_stack_canary_segment(void)
17522 {
17523 -#ifdef CONFIG_X86_32
17524 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17525 asm volatile ("mov %0, %%gs" : : "r" (0));
17526 #endif
17527 }
17528 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17529 index 70bbe39..4ae2bd4 100644
17530 --- a/arch/x86/include/asm/stacktrace.h
17531 +++ b/arch/x86/include/asm/stacktrace.h
17532 @@ -11,28 +11,20 @@
17533
17534 extern int kstack_depth_to_print;
17535
17536 -struct thread_info;
17537 +struct task_struct;
17538 struct stacktrace_ops;
17539
17540 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17541 - unsigned long *stack,
17542 - unsigned long bp,
17543 - const struct stacktrace_ops *ops,
17544 - void *data,
17545 - unsigned long *end,
17546 - int *graph);
17547 +typedef unsigned long walk_stack_t(struct task_struct *task,
17548 + void *stack_start,
17549 + unsigned long *stack,
17550 + unsigned long bp,
17551 + const struct stacktrace_ops *ops,
17552 + void *data,
17553 + unsigned long *end,
17554 + int *graph);
17555
17556 -extern unsigned long
17557 -print_context_stack(struct thread_info *tinfo,
17558 - unsigned long *stack, unsigned long bp,
17559 - const struct stacktrace_ops *ops, void *data,
17560 - unsigned long *end, int *graph);
17561 -
17562 -extern unsigned long
17563 -print_context_stack_bp(struct thread_info *tinfo,
17564 - unsigned long *stack, unsigned long bp,
17565 - const struct stacktrace_ops *ops, void *data,
17566 - unsigned long *end, int *graph);
17567 +extern walk_stack_t print_context_stack;
17568 +extern walk_stack_t print_context_stack_bp;
17569
17570 /* Generic stack tracer with callbacks */
17571
17572 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17573 void (*address)(void *data, unsigned long address, int reliable);
17574 /* On negative return stop dumping */
17575 int (*stack)(void *data, char *name);
17576 - walk_stack_t walk_stack;
17577 + walk_stack_t *walk_stack;
17578 };
17579
17580 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17581 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17582 index 4ec45b3..a4f0a8a 100644
17583 --- a/arch/x86/include/asm/switch_to.h
17584 +++ b/arch/x86/include/asm/switch_to.h
17585 @@ -108,7 +108,7 @@ do { \
17586 "call __switch_to\n\t" \
17587 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17588 __switch_canary \
17589 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17590 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17591 "movq %%rax,%%rdi\n\t" \
17592 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17593 "jnz ret_from_fork\n\t" \
17594 @@ -119,7 +119,7 @@ do { \
17595 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17596 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17597 [_tif_fork] "i" (_TIF_FORK), \
17598 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17599 + [thread_info] "m" (current_tinfo), \
17600 [current_task] "m" (current_task) \
17601 __switch_canary_iparam \
17602 : "memory", "cc" __EXTRA_CLOBBER)
17603 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17604 index 2781119..618b59b 100644
17605 --- a/arch/x86/include/asm/thread_info.h
17606 +++ b/arch/x86/include/asm/thread_info.h
17607 @@ -10,6 +10,7 @@
17608 #include <linux/compiler.h>
17609 #include <asm/page.h>
17610 #include <asm/types.h>
17611 +#include <asm/percpu.h>
17612
17613 /*
17614 * low level task data that entry.S needs immediate access to
17615 @@ -23,7 +24,6 @@ struct exec_domain;
17616 #include <linux/atomic.h>
17617
17618 struct thread_info {
17619 - struct task_struct *task; /* main task structure */
17620 struct exec_domain *exec_domain; /* execution domain */
17621 __u32 flags; /* low level flags */
17622 __u32 status; /* thread synchronous flags */
17623 @@ -33,19 +33,13 @@ struct thread_info {
17624 mm_segment_t addr_limit;
17625 struct restart_block restart_block;
17626 void __user *sysenter_return;
17627 -#ifdef CONFIG_X86_32
17628 - unsigned long previous_esp; /* ESP of the previous stack in
17629 - case of nested (IRQ) stacks
17630 - */
17631 - __u8 supervisor_stack[0];
17632 -#endif
17633 + unsigned long lowest_stack;
17634 unsigned int sig_on_uaccess_error:1;
17635 unsigned int uaccess_err:1; /* uaccess failed */
17636 };
17637
17638 -#define INIT_THREAD_INFO(tsk) \
17639 +#define INIT_THREAD_INFO \
17640 { \
17641 - .task = &tsk, \
17642 .exec_domain = &default_exec_domain, \
17643 .flags = 0, \
17644 .cpu = 0, \
17645 @@ -56,7 +50,7 @@ struct thread_info {
17646 }, \
17647 }
17648
17649 -#define init_thread_info (init_thread_union.thread_info)
17650 +#define init_thread_info (init_thread_union.stack)
17651 #define init_stack (init_thread_union.stack)
17652
17653 #else /* !__ASSEMBLY__ */
17654 @@ -96,6 +90,7 @@ struct thread_info {
17655 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17656 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17657 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17658 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17659
17660 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17661 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17662 @@ -119,17 +114,18 @@ struct thread_info {
17663 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17664 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17665 #define _TIF_X32 (1 << TIF_X32)
17666 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17667
17668 /* work to do in syscall_trace_enter() */
17669 #define _TIF_WORK_SYSCALL_ENTRY \
17670 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17671 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17672 - _TIF_NOHZ)
17673 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17674
17675 /* work to do in syscall_trace_leave() */
17676 #define _TIF_WORK_SYSCALL_EXIT \
17677 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17678 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17679 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17680
17681 /* work to do on interrupt/exception return */
17682 #define _TIF_WORK_MASK \
17683 @@ -140,7 +136,7 @@ struct thread_info {
17684 /* work to do on any return to user space */
17685 #define _TIF_ALLWORK_MASK \
17686 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17687 - _TIF_NOHZ)
17688 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17689
17690 /* Only used for 64 bit */
17691 #define _TIF_DO_NOTIFY_MASK \
17692 @@ -156,45 +152,40 @@ struct thread_info {
17693
17694 #define PREEMPT_ACTIVE 0x10000000
17695
17696 -#ifdef CONFIG_X86_32
17697 -
17698 -#define STACK_WARN (THREAD_SIZE/8)
17699 -/*
17700 - * macros/functions for gaining access to the thread information structure
17701 - *
17702 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17703 - */
17704 -#ifndef __ASSEMBLY__
17705 -
17706 -
17707 -/* how to get the current stack pointer from C */
17708 -register unsigned long current_stack_pointer asm("esp") __used;
17709 -
17710 -/* how to get the thread information struct from C */
17711 -static inline struct thread_info *current_thread_info(void)
17712 -{
17713 - return (struct thread_info *)
17714 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17715 -}
17716 -
17717 -#else /* !__ASSEMBLY__ */
17718 -
17719 +#ifdef __ASSEMBLY__
17720 /* how to get the thread information struct from ASM */
17721 #define GET_THREAD_INFO(reg) \
17722 - movl $-THREAD_SIZE, reg; \
17723 - andl %esp, reg
17724 + mov PER_CPU_VAR(current_tinfo), reg
17725
17726 /* use this one if reg already contains %esp */
17727 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17728 - andl $-THREAD_SIZE, reg
17729 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17730 +#else
17731 +/* how to get the thread information struct from C */
17732 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17733 +
17734 +static __always_inline struct thread_info *current_thread_info(void)
17735 +{
17736 + return this_cpu_read_stable(current_tinfo);
17737 +}
17738 +#endif
17739 +
17740 +#ifdef CONFIG_X86_32
17741 +
17742 +#define STACK_WARN (THREAD_SIZE/8)
17743 +/*
17744 + * macros/functions for gaining access to the thread information structure
17745 + *
17746 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17747 + */
17748 +#ifndef __ASSEMBLY__
17749 +
17750 +/* how to get the current stack pointer from C */
17751 +register unsigned long current_stack_pointer asm("esp") __used;
17752
17753 #endif
17754
17755 #else /* X86_32 */
17756
17757 -#include <asm/percpu.h>
17758 -#define KERNEL_STACK_OFFSET (5*8)
17759 -
17760 /*
17761 * macros/functions for gaining access to the thread information structure
17762 * preempt_count needs to be 1 initially, until the scheduler is functional.
17763 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17764 #ifndef __ASSEMBLY__
17765 DECLARE_PER_CPU(unsigned long, kernel_stack);
17766
17767 -static inline struct thread_info *current_thread_info(void)
17768 -{
17769 - struct thread_info *ti;
17770 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17771 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17772 - return ti;
17773 -}
17774 -
17775 -#else /* !__ASSEMBLY__ */
17776 -
17777 -/* how to get the thread information struct from ASM */
17778 -#define GET_THREAD_INFO(reg) \
17779 - movq PER_CPU_VAR(kernel_stack),reg ; \
17780 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17781 -
17782 -/*
17783 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17784 - * a certain register (to be used in assembler memory operands).
17785 - */
17786 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17787 -
17788 +/* how to get the current stack pointer from C */
17789 +register unsigned long current_stack_pointer asm("rsp") __used;
17790 #endif
17791
17792 #endif /* !X86_32 */
17793 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17794 extern void arch_task_cache_init(void);
17795 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17796 extern void arch_release_task_struct(struct task_struct *tsk);
17797 +
17798 +#define __HAVE_THREAD_FUNCTIONS
17799 +#define task_thread_info(task) (&(task)->tinfo)
17800 +#define task_stack_page(task) ((task)->stack)
17801 +#define setup_thread_stack(p, org) do {} while (0)
17802 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17803 +
17804 #endif
17805 #endif /* _ASM_X86_THREAD_INFO_H */
17806 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17807 index cf51200..63ff068 100644
17808 --- a/arch/x86/include/asm/tlbflush.h
17809 +++ b/arch/x86/include/asm/tlbflush.h
17810 @@ -17,18 +17,44 @@
17811
17812 static inline void __native_flush_tlb(void)
17813 {
17814 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17815 + u64 descriptor[2];
17816 +
17817 + descriptor[0] = PCID_KERNEL;
17818 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17819 + return;
17820 + }
17821 +
17822 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17823 + if (static_cpu_has(X86_FEATURE_PCID)) {
17824 + unsigned int cpu = raw_get_cpu();
17825 +
17826 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17827 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17828 + raw_put_cpu_no_resched();
17829 + return;
17830 + }
17831 +#endif
17832 +
17833 native_write_cr3(native_read_cr3());
17834 }
17835
17836 static inline void __native_flush_tlb_global_irq_disabled(void)
17837 {
17838 - unsigned long cr4;
17839 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17840 + u64 descriptor[2];
17841
17842 - cr4 = native_read_cr4();
17843 - /* clear PGE */
17844 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17845 - /* write old PGE again and flush TLBs */
17846 - native_write_cr4(cr4);
17847 + descriptor[0] = PCID_KERNEL;
17848 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17849 + } else {
17850 + unsigned long cr4;
17851 +
17852 + cr4 = native_read_cr4();
17853 + /* clear PGE */
17854 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17855 + /* write old PGE again and flush TLBs */
17856 + native_write_cr4(cr4);
17857 + }
17858 }
17859
17860 static inline void __native_flush_tlb_global(void)
17861 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17862
17863 static inline void __native_flush_tlb_single(unsigned long addr)
17864 {
17865 +
17866 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17867 + u64 descriptor[2];
17868 +
17869 + descriptor[0] = PCID_KERNEL;
17870 + descriptor[1] = addr;
17871 +
17872 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17873 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17874 + if (addr < TASK_SIZE_MAX)
17875 + descriptor[1] += pax_user_shadow_base;
17876 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17877 + }
17878 +
17879 + descriptor[0] = PCID_USER;
17880 + descriptor[1] = addr;
17881 +#endif
17882 +
17883 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17884 + return;
17885 + }
17886 +
17887 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17888 + if (static_cpu_has(X86_FEATURE_PCID)) {
17889 + unsigned int cpu = raw_get_cpu();
17890 +
17891 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17892 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17893 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17894 + raw_put_cpu_no_resched();
17895 +
17896 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17897 + addr += pax_user_shadow_base;
17898 + }
17899 +#endif
17900 +
17901 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17902 }
17903
17904 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17905 index 5ee2687..74590b9 100644
17906 --- a/arch/x86/include/asm/uaccess.h
17907 +++ b/arch/x86/include/asm/uaccess.h
17908 @@ -7,6 +7,7 @@
17909 #include <linux/compiler.h>
17910 #include <linux/thread_info.h>
17911 #include <linux/string.h>
17912 +#include <linux/sched.h>
17913 #include <asm/asm.h>
17914 #include <asm/page.h>
17915 #include <asm/smap.h>
17916 @@ -29,7 +30,12 @@
17917
17918 #define get_ds() (KERNEL_DS)
17919 #define get_fs() (current_thread_info()->addr_limit)
17920 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17921 +void __set_fs(mm_segment_t x);
17922 +void set_fs(mm_segment_t x);
17923 +#else
17924 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17925 +#endif
17926
17927 #define segment_eq(a, b) ((a).seg == (b).seg)
17928
17929 @@ -77,8 +83,33 @@
17930 * checks that the pointer is in the user space range - after calling
17931 * this function, memory access functions may still return -EFAULT.
17932 */
17933 -#define access_ok(type, addr, size) \
17934 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17935 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17936 +#define access_ok(type, addr, size) \
17937 +({ \
17938 + long __size = size; \
17939 + unsigned long __addr = (unsigned long)addr; \
17940 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17941 + unsigned long __end_ao = __addr + __size - 1; \
17942 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17943 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17944 + while(__addr_ao <= __end_ao) { \
17945 + char __c_ao; \
17946 + __addr_ao += PAGE_SIZE; \
17947 + if (__size > PAGE_SIZE) \
17948 + cond_resched(); \
17949 + if (__get_user(__c_ao, (char __user *)__addr)) \
17950 + break; \
17951 + if (type != VERIFY_WRITE) { \
17952 + __addr = __addr_ao; \
17953 + continue; \
17954 + } \
17955 + if (__put_user(__c_ao, (char __user *)__addr)) \
17956 + break; \
17957 + __addr = __addr_ao; \
17958 + } \
17959 + } \
17960 + __ret_ao; \
17961 +})
17962
17963 /*
17964 * The exception table consists of pairs of addresses relative to the
17965 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17966 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17967 __chk_user_ptr(ptr); \
17968 might_fault(); \
17969 + pax_open_userland(); \
17970 asm volatile("call __get_user_%P3" \
17971 : "=a" (__ret_gu), "=r" (__val_gu) \
17972 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17973 (x) = (__typeof__(*(ptr))) __val_gu; \
17974 + pax_close_userland(); \
17975 __ret_gu; \
17976 })
17977
17978 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17979 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17980 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17981
17982 -
17983 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17984 +#define __copyuser_seg "gs;"
17985 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17986 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17987 +#else
17988 +#define __copyuser_seg
17989 +#define __COPYUSER_SET_ES
17990 +#define __COPYUSER_RESTORE_ES
17991 +#endif
17992
17993 #ifdef CONFIG_X86_32
17994 #define __put_user_asm_u64(x, addr, err, errret) \
17995 asm volatile(ASM_STAC "\n" \
17996 - "1: movl %%eax,0(%2)\n" \
17997 - "2: movl %%edx,4(%2)\n" \
17998 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17999 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18000 "3: " ASM_CLAC "\n" \
18001 ".section .fixup,\"ax\"\n" \
18002 "4: movl %3,%0\n" \
18003 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18004
18005 #define __put_user_asm_ex_u64(x, addr) \
18006 asm volatile(ASM_STAC "\n" \
18007 - "1: movl %%eax,0(%1)\n" \
18008 - "2: movl %%edx,4(%1)\n" \
18009 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18010 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18011 "3: " ASM_CLAC "\n" \
18012 _ASM_EXTABLE_EX(1b, 2b) \
18013 _ASM_EXTABLE_EX(2b, 3b) \
18014 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18015 __typeof__(*(ptr)) __pu_val; \
18016 __chk_user_ptr(ptr); \
18017 might_fault(); \
18018 - __pu_val = x; \
18019 + __pu_val = (x); \
18020 + pax_open_userland(); \
18021 switch (sizeof(*(ptr))) { \
18022 case 1: \
18023 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18024 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18025 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18026 break; \
18027 } \
18028 + pax_close_userland(); \
18029 __ret_pu; \
18030 })
18031
18032 @@ -344,8 +387,10 @@ do { \
18033 } while (0)
18034
18035 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18036 +do { \
18037 + pax_open_userland(); \
18038 asm volatile(ASM_STAC "\n" \
18039 - "1: mov"itype" %2,%"rtype"1\n" \
18040 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18041 "2: " ASM_CLAC "\n" \
18042 ".section .fixup,\"ax\"\n" \
18043 "3: mov %3,%0\n" \
18044 @@ -353,8 +398,10 @@ do { \
18045 " jmp 2b\n" \
18046 ".previous\n" \
18047 _ASM_EXTABLE(1b, 3b) \
18048 - : "=r" (err), ltype(x) \
18049 - : "m" (__m(addr)), "i" (errret), "0" (err))
18050 + : "=r" (err), ltype (x) \
18051 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18052 + pax_close_userland(); \
18053 +} while (0)
18054
18055 #define __get_user_size_ex(x, ptr, size) \
18056 do { \
18057 @@ -378,7 +425,7 @@ do { \
18058 } while (0)
18059
18060 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18061 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18062 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18063 "2:\n" \
18064 _ASM_EXTABLE_EX(1b, 2b) \
18065 : ltype(x) : "m" (__m(addr)))
18066 @@ -395,13 +442,24 @@ do { \
18067 int __gu_err; \
18068 unsigned long __gu_val; \
18069 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18070 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18071 + (x) = (__typeof__(*(ptr)))__gu_val; \
18072 __gu_err; \
18073 })
18074
18075 /* FIXME: this hack is definitely wrong -AK */
18076 struct __large_struct { unsigned long buf[100]; };
18077 -#define __m(x) (*(struct __large_struct __user *)(x))
18078 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18079 +#define ____m(x) \
18080 +({ \
18081 + unsigned long ____x = (unsigned long)(x); \
18082 + if (____x < pax_user_shadow_base) \
18083 + ____x += pax_user_shadow_base; \
18084 + (typeof(x))____x; \
18085 +})
18086 +#else
18087 +#define ____m(x) (x)
18088 +#endif
18089 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18090
18091 /*
18092 * Tell gcc we read from memory instead of writing: this is because
18093 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18094 * aliasing issues.
18095 */
18096 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18097 +do { \
18098 + pax_open_userland(); \
18099 asm volatile(ASM_STAC "\n" \
18100 - "1: mov"itype" %"rtype"1,%2\n" \
18101 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18102 "2: " ASM_CLAC "\n" \
18103 ".section .fixup,\"ax\"\n" \
18104 "3: mov %3,%0\n" \
18105 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18106 ".previous\n" \
18107 _ASM_EXTABLE(1b, 3b) \
18108 : "=r"(err) \
18109 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18110 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18111 + pax_close_userland(); \
18112 +} while (0)
18113
18114 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18115 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18116 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18117 "2:\n" \
18118 _ASM_EXTABLE_EX(1b, 2b) \
18119 : : ltype(x), "m" (__m(addr)))
18120 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18121 */
18122 #define uaccess_try do { \
18123 current_thread_info()->uaccess_err = 0; \
18124 + pax_open_userland(); \
18125 stac(); \
18126 barrier();
18127
18128 #define uaccess_catch(err) \
18129 clac(); \
18130 + pax_close_userland(); \
18131 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18132 } while (0)
18133
18134 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18135 * On error, the variable @x is set to zero.
18136 */
18137
18138 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18139 +#define __get_user(x, ptr) get_user((x), (ptr))
18140 +#else
18141 #define __get_user(x, ptr) \
18142 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18143 +#endif
18144
18145 /**
18146 * __put_user: - Write a simple value into user space, with less checking.
18147 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18148 * Returns zero on success, or -EFAULT on error.
18149 */
18150
18151 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18152 +#define __put_user(x, ptr) put_user((x), (ptr))
18153 +#else
18154 #define __put_user(x, ptr) \
18155 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18156 +#endif
18157
18158 #define __get_user_unaligned __get_user
18159 #define __put_user_unaligned __put_user
18160 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18161 #define get_user_ex(x, ptr) do { \
18162 unsigned long __gue_val; \
18163 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18164 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18165 + (x) = (__typeof__(*(ptr)))__gue_val; \
18166 } while (0)
18167
18168 #define put_user_try uaccess_try
18169 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18170 extern __must_check long strlen_user(const char __user *str);
18171 extern __must_check long strnlen_user(const char __user *str, long n);
18172
18173 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18174 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18175 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18176 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18177
18178 /*
18179 * movsl can be slow when source and dest are not both 8-byte aligned
18180 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18181 index 7f760a9..04b1c65 100644
18182 --- a/arch/x86/include/asm/uaccess_32.h
18183 +++ b/arch/x86/include/asm/uaccess_32.h
18184 @@ -11,15 +11,15 @@
18185 #include <asm/page.h>
18186
18187 unsigned long __must_check __copy_to_user_ll
18188 - (void __user *to, const void *from, unsigned long n);
18189 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18190 unsigned long __must_check __copy_from_user_ll
18191 - (void *to, const void __user *from, unsigned long n);
18192 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18193 unsigned long __must_check __copy_from_user_ll_nozero
18194 - (void *to, const void __user *from, unsigned long n);
18195 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18196 unsigned long __must_check __copy_from_user_ll_nocache
18197 - (void *to, const void __user *from, unsigned long n);
18198 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18199 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18200 - (void *to, const void __user *from, unsigned long n);
18201 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18202
18203 /**
18204 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18205 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18206 static __always_inline unsigned long __must_check
18207 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18208 {
18209 + if ((long)n < 0)
18210 + return n;
18211 +
18212 + check_object_size(from, n, true);
18213 +
18214 if (__builtin_constant_p(n)) {
18215 unsigned long ret;
18216
18217 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18218 __copy_to_user(void __user *to, const void *from, unsigned long n)
18219 {
18220 might_fault();
18221 +
18222 return __copy_to_user_inatomic(to, from, n);
18223 }
18224
18225 static __always_inline unsigned long
18226 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18227 {
18228 + if ((long)n < 0)
18229 + return n;
18230 +
18231 /* Avoid zeroing the tail if the copy fails..
18232 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18233 * but as the zeroing behaviour is only significant when n is not
18234 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18235 __copy_from_user(void *to, const void __user *from, unsigned long n)
18236 {
18237 might_fault();
18238 +
18239 + if ((long)n < 0)
18240 + return n;
18241 +
18242 + check_object_size(to, n, false);
18243 +
18244 if (__builtin_constant_p(n)) {
18245 unsigned long ret;
18246
18247 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18248 const void __user *from, unsigned long n)
18249 {
18250 might_fault();
18251 +
18252 + if ((long)n < 0)
18253 + return n;
18254 +
18255 if (__builtin_constant_p(n)) {
18256 unsigned long ret;
18257
18258 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18259 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18260 unsigned long n)
18261 {
18262 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18263 + if ((long)n < 0)
18264 + return n;
18265 +
18266 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18267 }
18268
18269 -unsigned long __must_check copy_to_user(void __user *to,
18270 - const void *from, unsigned long n);
18271 -unsigned long __must_check _copy_from_user(void *to,
18272 - const void __user *from,
18273 - unsigned long n);
18274 -
18275 +extern void copy_to_user_overflow(void)
18276 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18277 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18278 +#else
18279 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18280 +#endif
18281 +;
18282
18283 extern void copy_from_user_overflow(void)
18284 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18285 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18286 #endif
18287 ;
18288
18289 -static inline unsigned long __must_check copy_from_user(void *to,
18290 - const void __user *from,
18291 - unsigned long n)
18292 +/**
18293 + * copy_to_user: - Copy a block of data into user space.
18294 + * @to: Destination address, in user space.
18295 + * @from: Source address, in kernel space.
18296 + * @n: Number of bytes to copy.
18297 + *
18298 + * Context: User context only. This function may sleep.
18299 + *
18300 + * Copy data from kernel space to user space.
18301 + *
18302 + * Returns number of bytes that could not be copied.
18303 + * On success, this will be zero.
18304 + */
18305 +static inline unsigned long __must_check
18306 +copy_to_user(void __user *to, const void *from, unsigned long n)
18307 {
18308 - int sz = __compiletime_object_size(to);
18309 + size_t sz = __compiletime_object_size(from);
18310
18311 - if (likely(sz == -1 || sz >= n))
18312 - n = _copy_from_user(to, from, n);
18313 - else
18314 + if (unlikely(sz != (size_t)-1 && sz < n))
18315 + copy_to_user_overflow();
18316 + else if (access_ok(VERIFY_WRITE, to, n))
18317 + n = __copy_to_user(to, from, n);
18318 + return n;
18319 +}
18320 +
18321 +/**
18322 + * copy_from_user: - Copy a block of data from user space.
18323 + * @to: Destination address, in kernel space.
18324 + * @from: Source address, in user space.
18325 + * @n: Number of bytes to copy.
18326 + *
18327 + * Context: User context only. This function may sleep.
18328 + *
18329 + * Copy data from user space to kernel space.
18330 + *
18331 + * Returns number of bytes that could not be copied.
18332 + * On success, this will be zero.
18333 + *
18334 + * If some data could not be copied, this function will pad the copied
18335 + * data to the requested size using zero bytes.
18336 + */
18337 +static inline unsigned long __must_check
18338 +copy_from_user(void *to, const void __user *from, unsigned long n)
18339 +{
18340 + size_t sz = __compiletime_object_size(to);
18341 +
18342 + check_object_size(to, n, false);
18343 +
18344 + if (unlikely(sz != (size_t)-1 && sz < n))
18345 copy_from_user_overflow();
18346 -
18347 + else if (access_ok(VERIFY_READ, from, n))
18348 + n = __copy_from_user(to, from, n);
18349 + else if ((long)n > 0)
18350 + memset(to, 0, n);
18351 return n;
18352 }
18353
18354 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18355 index 4f7923d..d3526c1 100644
18356 --- a/arch/x86/include/asm/uaccess_64.h
18357 +++ b/arch/x86/include/asm/uaccess_64.h
18358 @@ -10,6 +10,9 @@
18359 #include <asm/alternative.h>
18360 #include <asm/cpufeature.h>
18361 #include <asm/page.h>
18362 +#include <asm/pgtable.h>
18363 +
18364 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18365
18366 /*
18367 * Copy To/From Userspace
18368 @@ -17,14 +20,14 @@
18369
18370 /* Handles exceptions in both to and from, but doesn't do access_ok */
18371 __must_check unsigned long
18372 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18373 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18374 __must_check unsigned long
18375 -copy_user_generic_string(void *to, const void *from, unsigned len);
18376 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18377 __must_check unsigned long
18378 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18379 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18380
18381 -static __always_inline __must_check unsigned long
18382 -copy_user_generic(void *to, const void *from, unsigned len)
18383 +static __always_inline __must_check __size_overflow(3) unsigned long
18384 +copy_user_generic(void *to, const void *from, unsigned long len)
18385 {
18386 unsigned ret;
18387
18388 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18389 return ret;
18390 }
18391
18392 +static __always_inline __must_check unsigned long
18393 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18394 +static __always_inline __must_check unsigned long
18395 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18396 __must_check unsigned long
18397 -_copy_to_user(void __user *to, const void *from, unsigned len);
18398 -__must_check unsigned long
18399 -_copy_from_user(void *to, const void __user *from, unsigned len);
18400 -__must_check unsigned long
18401 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18402 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18403 +
18404 +extern void copy_to_user_overflow(void)
18405 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18406 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18407 +#else
18408 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18409 +#endif
18410 +;
18411 +
18412 +extern void copy_from_user_overflow(void)
18413 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18414 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18415 +#else
18416 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18417 +#endif
18418 +;
18419
18420 static inline unsigned long __must_check copy_from_user(void *to,
18421 const void __user *from,
18422 unsigned long n)
18423 {
18424 - int sz = __compiletime_object_size(to);
18425 -
18426 might_fault();
18427 - if (likely(sz == -1 || sz >= n))
18428 - n = _copy_from_user(to, from, n);
18429 -#ifdef CONFIG_DEBUG_VM
18430 - else
18431 - WARN(1, "Buffer overflow detected!\n");
18432 -#endif
18433 +
18434 + check_object_size(to, n, false);
18435 +
18436 + if (access_ok(VERIFY_READ, from, n))
18437 + n = __copy_from_user(to, from, n);
18438 + else if (n < INT_MAX)
18439 + memset(to, 0, n);
18440 return n;
18441 }
18442
18443 static __always_inline __must_check
18444 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18445 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18446 {
18447 might_fault();
18448
18449 - return _copy_to_user(dst, src, size);
18450 + if (access_ok(VERIFY_WRITE, dst, size))
18451 + size = __copy_to_user(dst, src, size);
18452 + return size;
18453 }
18454
18455 static __always_inline __must_check
18456 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18457 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18458 {
18459 - int ret = 0;
18460 + size_t sz = __compiletime_object_size(dst);
18461 + unsigned ret = 0;
18462
18463 might_fault();
18464 +
18465 + if (size > INT_MAX)
18466 + return size;
18467 +
18468 + check_object_size(dst, size, false);
18469 +
18470 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18471 + if (!__access_ok(VERIFY_READ, src, size))
18472 + return size;
18473 +#endif
18474 +
18475 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18476 + copy_from_user_overflow();
18477 + return size;
18478 + }
18479 +
18480 if (!__builtin_constant_p(size))
18481 - return copy_user_generic(dst, (__force void *)src, size);
18482 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18483 switch (size) {
18484 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18485 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18486 ret, "b", "b", "=q", 1);
18487 return ret;
18488 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18489 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18490 ret, "w", "w", "=r", 2);
18491 return ret;
18492 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18493 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18494 ret, "l", "k", "=r", 4);
18495 return ret;
18496 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18497 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18498 ret, "q", "", "=r", 8);
18499 return ret;
18500 case 10:
18501 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18502 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18503 ret, "q", "", "=r", 10);
18504 if (unlikely(ret))
18505 return ret;
18506 __get_user_asm(*(u16 *)(8 + (char *)dst),
18507 - (u16 __user *)(8 + (char __user *)src),
18508 + (const u16 __user *)(8 + (const char __user *)src),
18509 ret, "w", "w", "=r", 2);
18510 return ret;
18511 case 16:
18512 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18513 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18514 ret, "q", "", "=r", 16);
18515 if (unlikely(ret))
18516 return ret;
18517 __get_user_asm(*(u64 *)(8 + (char *)dst),
18518 - (u64 __user *)(8 + (char __user *)src),
18519 + (const u64 __user *)(8 + (const char __user *)src),
18520 ret, "q", "", "=r", 8);
18521 return ret;
18522 default:
18523 - return copy_user_generic(dst, (__force void *)src, size);
18524 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18525 }
18526 }
18527
18528 static __always_inline __must_check
18529 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18530 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18531 {
18532 - int ret = 0;
18533 + size_t sz = __compiletime_object_size(src);
18534 + unsigned ret = 0;
18535
18536 might_fault();
18537 +
18538 + if (size > INT_MAX)
18539 + return size;
18540 +
18541 + check_object_size(src, size, true);
18542 +
18543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18544 + if (!__access_ok(VERIFY_WRITE, dst, size))
18545 + return size;
18546 +#endif
18547 +
18548 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18549 + copy_to_user_overflow();
18550 + return size;
18551 + }
18552 +
18553 if (!__builtin_constant_p(size))
18554 - return copy_user_generic((__force void *)dst, src, size);
18555 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18556 switch (size) {
18557 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18558 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18559 ret, "b", "b", "iq", 1);
18560 return ret;
18561 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18562 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18563 ret, "w", "w", "ir", 2);
18564 return ret;
18565 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18566 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18567 ret, "l", "k", "ir", 4);
18568 return ret;
18569 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18570 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18571 ret, "q", "", "er", 8);
18572 return ret;
18573 case 10:
18574 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18575 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18576 ret, "q", "", "er", 10);
18577 if (unlikely(ret))
18578 return ret;
18579 asm("":::"memory");
18580 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18581 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18582 ret, "w", "w", "ir", 2);
18583 return ret;
18584 case 16:
18585 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18586 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18587 ret, "q", "", "er", 16);
18588 if (unlikely(ret))
18589 return ret;
18590 asm("":::"memory");
18591 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18592 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18593 ret, "q", "", "er", 8);
18594 return ret;
18595 default:
18596 - return copy_user_generic((__force void *)dst, src, size);
18597 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18598 }
18599 }
18600
18601 static __always_inline __must_check
18602 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18603 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18604 {
18605 - int ret = 0;
18606 + unsigned ret = 0;
18607
18608 might_fault();
18609 +
18610 + if (size > INT_MAX)
18611 + return size;
18612 +
18613 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18614 + if (!__access_ok(VERIFY_READ, src, size))
18615 + return size;
18616 + if (!__access_ok(VERIFY_WRITE, dst, size))
18617 + return size;
18618 +#endif
18619 +
18620 if (!__builtin_constant_p(size))
18621 - return copy_user_generic((__force void *)dst,
18622 - (__force void *)src, size);
18623 + return copy_user_generic((__force_kernel void *)____m(dst),
18624 + (__force_kernel const void *)____m(src), size);
18625 switch (size) {
18626 case 1: {
18627 u8 tmp;
18628 - __get_user_asm(tmp, (u8 __user *)src,
18629 + __get_user_asm(tmp, (const u8 __user *)src,
18630 ret, "b", "b", "=q", 1);
18631 if (likely(!ret))
18632 __put_user_asm(tmp, (u8 __user *)dst,
18633 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18634 }
18635 case 2: {
18636 u16 tmp;
18637 - __get_user_asm(tmp, (u16 __user *)src,
18638 + __get_user_asm(tmp, (const u16 __user *)src,
18639 ret, "w", "w", "=r", 2);
18640 if (likely(!ret))
18641 __put_user_asm(tmp, (u16 __user *)dst,
18642 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18643
18644 case 4: {
18645 u32 tmp;
18646 - __get_user_asm(tmp, (u32 __user *)src,
18647 + __get_user_asm(tmp, (const u32 __user *)src,
18648 ret, "l", "k", "=r", 4);
18649 if (likely(!ret))
18650 __put_user_asm(tmp, (u32 __user *)dst,
18651 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18652 }
18653 case 8: {
18654 u64 tmp;
18655 - __get_user_asm(tmp, (u64 __user *)src,
18656 + __get_user_asm(tmp, (const u64 __user *)src,
18657 ret, "q", "", "=r", 8);
18658 if (likely(!ret))
18659 __put_user_asm(tmp, (u64 __user *)dst,
18660 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18661 return ret;
18662 }
18663 default:
18664 - return copy_user_generic((__force void *)dst,
18665 - (__force void *)src, size);
18666 + return copy_user_generic((__force_kernel void *)____m(dst),
18667 + (__force_kernel const void *)____m(src), size);
18668 }
18669 }
18670
18671 -static __must_check __always_inline int
18672 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18673 +static __must_check __always_inline unsigned long
18674 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18675 {
18676 - return copy_user_generic(dst, (__force const void *)src, size);
18677 + if (size > INT_MAX)
18678 + return size;
18679 +
18680 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18681 + if (!__access_ok(VERIFY_READ, src, size))
18682 + return size;
18683 +#endif
18684 +
18685 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18686 }
18687
18688 -static __must_check __always_inline int
18689 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18690 +static __must_check __always_inline unsigned long
18691 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18692 {
18693 - return copy_user_generic((__force void *)dst, src, size);
18694 + if (size > INT_MAX)
18695 + return size;
18696 +
18697 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18698 + if (!__access_ok(VERIFY_WRITE, dst, size))
18699 + return size;
18700 +#endif
18701 +
18702 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18703 }
18704
18705 -extern long __copy_user_nocache(void *dst, const void __user *src,
18706 - unsigned size, int zerorest);
18707 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18708 + unsigned long size, int zerorest) __size_overflow(3);
18709
18710 -static inline int
18711 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18712 +static inline unsigned long
18713 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18714 {
18715 might_fault();
18716 +
18717 + if (size > INT_MAX)
18718 + return size;
18719 +
18720 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18721 + if (!__access_ok(VERIFY_READ, src, size))
18722 + return size;
18723 +#endif
18724 +
18725 return __copy_user_nocache(dst, src, size, 1);
18726 }
18727
18728 -static inline int
18729 +static inline unsigned long
18730 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18731 - unsigned size)
18732 + unsigned long size)
18733 {
18734 + if (size > INT_MAX)
18735 + return size;
18736 +
18737 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18738 + if (!__access_ok(VERIFY_READ, src, size))
18739 + return size;
18740 +#endif
18741 +
18742 return __copy_user_nocache(dst, src, size, 0);
18743 }
18744
18745 unsigned long
18746 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18747 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18748
18749 #endif /* _ASM_X86_UACCESS_64_H */
18750 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18751 index 5b238981..77fdd78 100644
18752 --- a/arch/x86/include/asm/word-at-a-time.h
18753 +++ b/arch/x86/include/asm/word-at-a-time.h
18754 @@ -11,7 +11,7 @@
18755 * and shift, for example.
18756 */
18757 struct word_at_a_time {
18758 - const unsigned long one_bits, high_bits;
18759 + unsigned long one_bits, high_bits;
18760 };
18761
18762 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18763 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18764 index 828a156..650e625 100644
18765 --- a/arch/x86/include/asm/x86_init.h
18766 +++ b/arch/x86/include/asm/x86_init.h
18767 @@ -129,7 +129,7 @@ struct x86_init_ops {
18768 struct x86_init_timers timers;
18769 struct x86_init_iommu iommu;
18770 struct x86_init_pci pci;
18771 -};
18772 +} __no_const;
18773
18774 /**
18775 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18776 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18777 void (*setup_percpu_clockev)(void);
18778 void (*early_percpu_clock_init)(void);
18779 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18780 -};
18781 +} __no_const;
18782
18783 struct timespec;
18784
18785 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18786 void (*save_sched_clock_state)(void);
18787 void (*restore_sched_clock_state)(void);
18788 void (*apic_post_init)(void);
18789 -};
18790 +} __no_const;
18791
18792 struct pci_dev;
18793 struct msi_msg;
18794 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18795 void (*teardown_msi_irqs)(struct pci_dev *dev);
18796 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18797 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18798 -};
18799 +} __no_const;
18800
18801 struct IO_APIC_route_entry;
18802 struct io_apic_irq_attr;
18803 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18804 unsigned int destination, int vector,
18805 struct io_apic_irq_attr *attr);
18806 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18807 -};
18808 +} __no_const;
18809
18810 extern struct x86_init_ops x86_init;
18811 extern struct x86_cpuinit_ops x86_cpuinit;
18812 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18813 index 0415cda..3b22adc 100644
18814 --- a/arch/x86/include/asm/xsave.h
18815 +++ b/arch/x86/include/asm/xsave.h
18816 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18817 if (unlikely(err))
18818 return -EFAULT;
18819
18820 + pax_open_userland();
18821 __asm__ __volatile__(ASM_STAC "\n"
18822 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18823 + "1:"
18824 + __copyuser_seg
18825 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18826 "2: " ASM_CLAC "\n"
18827 ".section .fixup,\"ax\"\n"
18828 "3: movl $-1,%[err]\n"
18829 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18830 : [err] "=r" (err)
18831 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18832 : "memory");
18833 + pax_close_userland();
18834 return err;
18835 }
18836
18837 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18838 {
18839 int err;
18840 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18841 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18842 u32 lmask = mask;
18843 u32 hmask = mask >> 32;
18844
18845 + pax_open_userland();
18846 __asm__ __volatile__(ASM_STAC "\n"
18847 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18848 + "1:"
18849 + __copyuser_seg
18850 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18851 "2: " ASM_CLAC "\n"
18852 ".section .fixup,\"ax\"\n"
18853 "3: movl $-1,%[err]\n"
18854 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18855 : [err] "=r" (err)
18856 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18857 : "memory"); /* memory required? */
18858 + pax_close_userland();
18859 return err;
18860 }
18861
18862 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18863 index bbae024..e1528f9 100644
18864 --- a/arch/x86/include/uapi/asm/e820.h
18865 +++ b/arch/x86/include/uapi/asm/e820.h
18866 @@ -63,7 +63,7 @@ struct e820map {
18867 #define ISA_START_ADDRESS 0xa0000
18868 #define ISA_END_ADDRESS 0x100000
18869
18870 -#define BIOS_BEGIN 0x000a0000
18871 +#define BIOS_BEGIN 0x000c0000
18872 #define BIOS_END 0x00100000
18873
18874 #define BIOS_ROM_BASE 0xffe00000
18875 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18876 index 88d99ea..9fc7e17 100644
18877 --- a/arch/x86/kernel/Makefile
18878 +++ b/arch/x86/kernel/Makefile
18879 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18880 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18881 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18882 obj-y += probe_roms.o
18883 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18884 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18885 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18886 obj-y += syscall_$(BITS).o
18887 obj-$(CONFIG_X86_64) += vsyscall_64.o
18888 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18889 index 2627a81..cd8325e 100644
18890 --- a/arch/x86/kernel/acpi/boot.c
18891 +++ b/arch/x86/kernel/acpi/boot.c
18892 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18893 * If your system is blacklisted here, but you find that acpi=force
18894 * works for you, please contact linux-acpi@vger.kernel.org
18895 */
18896 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18897 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18898 /*
18899 * Boxes that need ACPI disabled
18900 */
18901 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18902 };
18903
18904 /* second table for DMI checks that should run after early-quirks */
18905 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18906 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18907 /*
18908 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18909 * which includes some code which overrides all temperature
18910 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18911 index 3312010..a65ca7b 100644
18912 --- a/arch/x86/kernel/acpi/sleep.c
18913 +++ b/arch/x86/kernel/acpi/sleep.c
18914 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18915 #else /* CONFIG_64BIT */
18916 #ifdef CONFIG_SMP
18917 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18918 +
18919 + pax_open_kernel();
18920 early_gdt_descr.address =
18921 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18922 + pax_close_kernel();
18923 +
18924 initial_gs = per_cpu_offset(smp_processor_id());
18925 #endif
18926 initial_code = (unsigned long)wakeup_long64;
18927 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18928 index d1daa66..59fecba 100644
18929 --- a/arch/x86/kernel/acpi/wakeup_32.S
18930 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18931 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18932 # and restore the stack ... but you need gdt for this to work
18933 movl saved_context_esp, %esp
18934
18935 - movl %cs:saved_magic, %eax
18936 - cmpl $0x12345678, %eax
18937 + cmpl $0x12345678, saved_magic
18938 jne bogus_magic
18939
18940 # jump to place where we left off
18941 - movl saved_eip, %eax
18942 - jmp *%eax
18943 + jmp *(saved_eip)
18944
18945 bogus_magic:
18946 jmp bogus_magic
18947 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18948 index c15cf9a..0e63558 100644
18949 --- a/arch/x86/kernel/alternative.c
18950 +++ b/arch/x86/kernel/alternative.c
18951 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18952 */
18953 for (a = start; a < end; a++) {
18954 instr = (u8 *)&a->instr_offset + a->instr_offset;
18955 +
18956 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18957 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18958 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18959 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18960 +#endif
18961 +
18962 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18963 BUG_ON(a->replacementlen > a->instrlen);
18964 BUG_ON(a->instrlen > sizeof(insnbuf));
18965 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18966 for (poff = start; poff < end; poff++) {
18967 u8 *ptr = (u8 *)poff + *poff;
18968
18969 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18970 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18971 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18972 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18973 +#endif
18974 +
18975 if (!*poff || ptr < text || ptr >= text_end)
18976 continue;
18977 /* turn DS segment override prefix into lock prefix */
18978 - if (*ptr == 0x3e)
18979 + if (*ktla_ktva(ptr) == 0x3e)
18980 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18981 }
18982 mutex_unlock(&text_mutex);
18983 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18984 for (poff = start; poff < end; poff++) {
18985 u8 *ptr = (u8 *)poff + *poff;
18986
18987 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18988 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18989 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18990 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18991 +#endif
18992 +
18993 if (!*poff || ptr < text || ptr >= text_end)
18994 continue;
18995 /* turn lock prefix into DS segment override prefix */
18996 - if (*ptr == 0xf0)
18997 + if (*ktla_ktva(ptr) == 0xf0)
18998 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18999 }
19000 mutex_unlock(&text_mutex);
19001 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19002
19003 BUG_ON(p->len > MAX_PATCH_LEN);
19004 /* prep the buffer with the original instructions */
19005 - memcpy(insnbuf, p->instr, p->len);
19006 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19007 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19008 (unsigned long)p->instr, p->len);
19009
19010 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19011 if (!uniproc_patched || num_possible_cpus() == 1)
19012 free_init_pages("SMP alternatives",
19013 (unsigned long)__smp_locks,
19014 - (unsigned long)__smp_locks_end);
19015 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19016 #endif
19017
19018 apply_paravirt(__parainstructions, __parainstructions_end);
19019 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19020 * instructions. And on the local CPU you need to be protected again NMI or MCE
19021 * handlers seeing an inconsistent instruction while you patch.
19022 */
19023 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19024 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19025 size_t len)
19026 {
19027 unsigned long flags;
19028 local_irq_save(flags);
19029 - memcpy(addr, opcode, len);
19030 +
19031 + pax_open_kernel();
19032 + memcpy(ktla_ktva(addr), opcode, len);
19033 sync_core();
19034 + pax_close_kernel();
19035 +
19036 local_irq_restore(flags);
19037 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19038 that causes hangs on some VIA CPUs. */
19039 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19040 */
19041 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19042 {
19043 - unsigned long flags;
19044 - char *vaddr;
19045 + unsigned char *vaddr = ktla_ktva(addr);
19046 struct page *pages[2];
19047 - int i;
19048 + size_t i;
19049
19050 if (!core_kernel_text((unsigned long)addr)) {
19051 - pages[0] = vmalloc_to_page(addr);
19052 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19053 + pages[0] = vmalloc_to_page(vaddr);
19054 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19055 } else {
19056 - pages[0] = virt_to_page(addr);
19057 + pages[0] = virt_to_page(vaddr);
19058 WARN_ON(!PageReserved(pages[0]));
19059 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19060 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19061 }
19062 BUG_ON(!pages[0]);
19063 - local_irq_save(flags);
19064 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19065 - if (pages[1])
19066 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19067 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19068 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19069 - clear_fixmap(FIX_TEXT_POKE0);
19070 - if (pages[1])
19071 - clear_fixmap(FIX_TEXT_POKE1);
19072 - local_flush_tlb();
19073 - sync_core();
19074 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19075 - that causes hangs on some VIA CPUs. */
19076 + text_poke_early(addr, opcode, len);
19077 for (i = 0; i < len; i++)
19078 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19079 - local_irq_restore(flags);
19080 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19081 return addr;
19082 }
19083
19084 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19085 index eca89c5..d566b78 100644
19086 --- a/arch/x86/kernel/apic/apic.c
19087 +++ b/arch/x86/kernel/apic/apic.c
19088 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19089 /*
19090 * Debug level, exported for io_apic.c
19091 */
19092 -unsigned int apic_verbosity;
19093 +int apic_verbosity;
19094
19095 int pic_mode;
19096
19097 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19098 apic_write(APIC_ESR, 0);
19099 v1 = apic_read(APIC_ESR);
19100 ack_APIC_irq();
19101 - atomic_inc(&irq_err_count);
19102 + atomic_inc_unchecked(&irq_err_count);
19103
19104 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19105 smp_processor_id(), v0 , v1);
19106 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19107 index 00c77cf..2dc6a2d 100644
19108 --- a/arch/x86/kernel/apic/apic_flat_64.c
19109 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19110 @@ -157,7 +157,7 @@ static int flat_probe(void)
19111 return 1;
19112 }
19113
19114 -static struct apic apic_flat = {
19115 +static struct apic apic_flat __read_only = {
19116 .name = "flat",
19117 .probe = flat_probe,
19118 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19119 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19120 return 0;
19121 }
19122
19123 -static struct apic apic_physflat = {
19124 +static struct apic apic_physflat __read_only = {
19125
19126 .name = "physical flat",
19127 .probe = physflat_probe,
19128 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19129 index e145f28..2752888 100644
19130 --- a/arch/x86/kernel/apic/apic_noop.c
19131 +++ b/arch/x86/kernel/apic/apic_noop.c
19132 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19133 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19134 }
19135
19136 -struct apic apic_noop = {
19137 +struct apic apic_noop __read_only = {
19138 .name = "noop",
19139 .probe = noop_probe,
19140 .acpi_madt_oem_check = NULL,
19141 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19142 index d50e364..543bee3 100644
19143 --- a/arch/x86/kernel/apic/bigsmp_32.c
19144 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19145 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19146 return dmi_bigsmp;
19147 }
19148
19149 -static struct apic apic_bigsmp = {
19150 +static struct apic apic_bigsmp __read_only = {
19151
19152 .name = "bigsmp",
19153 .probe = probe_bigsmp,
19154 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19155 index c552247..587a316 100644
19156 --- a/arch/x86/kernel/apic/es7000_32.c
19157 +++ b/arch/x86/kernel/apic/es7000_32.c
19158 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19159 return ret && es7000_apic_is_cluster();
19160 }
19161
19162 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19163 -static struct apic __refdata apic_es7000_cluster = {
19164 +static struct apic apic_es7000_cluster __read_only = {
19165
19166 .name = "es7000",
19167 .probe = probe_es7000,
19168 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19169 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19170 };
19171
19172 -static struct apic __refdata apic_es7000 = {
19173 +static struct apic apic_es7000 __read_only = {
19174
19175 .name = "es7000",
19176 .probe = probe_es7000,
19177 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19178 index 9ed796c..e930fe4 100644
19179 --- a/arch/x86/kernel/apic/io_apic.c
19180 +++ b/arch/x86/kernel/apic/io_apic.c
19181 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19182 }
19183 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19184
19185 -void lock_vector_lock(void)
19186 +void lock_vector_lock(void) __acquires(vector_lock)
19187 {
19188 /* Used to the online set of cpus does not change
19189 * during assign_irq_vector.
19190 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19191 raw_spin_lock(&vector_lock);
19192 }
19193
19194 -void unlock_vector_lock(void)
19195 +void unlock_vector_lock(void) __releases(vector_lock)
19196 {
19197 raw_spin_unlock(&vector_lock);
19198 }
19199 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19200 ack_APIC_irq();
19201 }
19202
19203 -atomic_t irq_mis_count;
19204 +atomic_unchecked_t irq_mis_count;
19205
19206 #ifdef CONFIG_GENERIC_PENDING_IRQ
19207 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19208 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19209 * at the cpu.
19210 */
19211 if (!(v & (1 << (i & 0x1f)))) {
19212 - atomic_inc(&irq_mis_count);
19213 + atomic_inc_unchecked(&irq_mis_count);
19214
19215 eoi_ioapic_irq(irq, cfg);
19216 }
19217 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19218 index 1e42e8f..daacf44 100644
19219 --- a/arch/x86/kernel/apic/numaq_32.c
19220 +++ b/arch/x86/kernel/apic/numaq_32.c
19221 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19222 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19223 }
19224
19225 -/* Use __refdata to keep false positive warning calm. */
19226 -static struct apic __refdata apic_numaq = {
19227 +static struct apic apic_numaq __read_only = {
19228
19229 .name = "NUMAQ",
19230 .probe = probe_numaq,
19231 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19232 index eb35ef9..f184a21 100644
19233 --- a/arch/x86/kernel/apic/probe_32.c
19234 +++ b/arch/x86/kernel/apic/probe_32.c
19235 @@ -72,7 +72,7 @@ static int probe_default(void)
19236 return 1;
19237 }
19238
19239 -static struct apic apic_default = {
19240 +static struct apic apic_default __read_only = {
19241
19242 .name = "default",
19243 .probe = probe_default,
19244 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19245 index 77c95c0..434f8a4 100644
19246 --- a/arch/x86/kernel/apic/summit_32.c
19247 +++ b/arch/x86/kernel/apic/summit_32.c
19248 @@ -486,7 +486,7 @@ void setup_summit(void)
19249 }
19250 #endif
19251
19252 -static struct apic apic_summit = {
19253 +static struct apic apic_summit __read_only = {
19254
19255 .name = "summit",
19256 .probe = probe_summit,
19257 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19258 index 140e29d..d88bc95 100644
19259 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19260 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19261 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19262 return notifier_from_errno(err);
19263 }
19264
19265 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19266 +static struct notifier_block x2apic_cpu_notifier = {
19267 .notifier_call = update_clusterinfo,
19268 };
19269
19270 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19271 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19272 }
19273
19274 -static struct apic apic_x2apic_cluster = {
19275 +static struct apic apic_x2apic_cluster __read_only = {
19276
19277 .name = "cluster x2apic",
19278 .probe = x2apic_cluster_probe,
19279 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19280 index 562a76d..a003c0f 100644
19281 --- a/arch/x86/kernel/apic/x2apic_phys.c
19282 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19283 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19284 return apic == &apic_x2apic_phys;
19285 }
19286
19287 -static struct apic apic_x2apic_phys = {
19288 +static struct apic apic_x2apic_phys __read_only = {
19289
19290 .name = "physical x2apic",
19291 .probe = x2apic_phys_probe,
19292 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19293 index a419814..1dd34a0 100644
19294 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19295 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19296 @@ -357,7 +357,7 @@ static int uv_probe(void)
19297 return apic == &apic_x2apic_uv_x;
19298 }
19299
19300 -static struct apic __refdata apic_x2apic_uv_x = {
19301 +static struct apic apic_x2apic_uv_x __read_only = {
19302
19303 .name = "UV large system",
19304 .probe = uv_probe,
19305 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19306 index 53a4e27..038760a 100644
19307 --- a/arch/x86/kernel/apm_32.c
19308 +++ b/arch/x86/kernel/apm_32.c
19309 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19310 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19311 * even though they are called in protected mode.
19312 */
19313 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19314 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19315 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19316
19317 static const char driver_version[] = "1.16ac"; /* no spaces */
19318 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19319 BUG_ON(cpu != 0);
19320 gdt = get_cpu_gdt_table(cpu);
19321 save_desc_40 = gdt[0x40 / 8];
19322 +
19323 + pax_open_kernel();
19324 gdt[0x40 / 8] = bad_bios_desc;
19325 + pax_close_kernel();
19326
19327 apm_irq_save(flags);
19328 APM_DO_SAVE_SEGS;
19329 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19330 &call->esi);
19331 APM_DO_RESTORE_SEGS;
19332 apm_irq_restore(flags);
19333 +
19334 + pax_open_kernel();
19335 gdt[0x40 / 8] = save_desc_40;
19336 + pax_close_kernel();
19337 +
19338 put_cpu();
19339
19340 return call->eax & 0xff;
19341 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19342 BUG_ON(cpu != 0);
19343 gdt = get_cpu_gdt_table(cpu);
19344 save_desc_40 = gdt[0x40 / 8];
19345 +
19346 + pax_open_kernel();
19347 gdt[0x40 / 8] = bad_bios_desc;
19348 + pax_close_kernel();
19349
19350 apm_irq_save(flags);
19351 APM_DO_SAVE_SEGS;
19352 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19353 &call->eax);
19354 APM_DO_RESTORE_SEGS;
19355 apm_irq_restore(flags);
19356 +
19357 + pax_open_kernel();
19358 gdt[0x40 / 8] = save_desc_40;
19359 + pax_close_kernel();
19360 +
19361 put_cpu();
19362 return error;
19363 }
19364 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19365 * code to that CPU.
19366 */
19367 gdt = get_cpu_gdt_table(0);
19368 +
19369 + pax_open_kernel();
19370 set_desc_base(&gdt[APM_CS >> 3],
19371 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19372 set_desc_base(&gdt[APM_CS_16 >> 3],
19373 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19374 set_desc_base(&gdt[APM_DS >> 3],
19375 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19376 + pax_close_kernel();
19377
19378 proc_create("apm", 0, NULL, &apm_file_ops);
19379
19380 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19381 index 2861082..6d4718e 100644
19382 --- a/arch/x86/kernel/asm-offsets.c
19383 +++ b/arch/x86/kernel/asm-offsets.c
19384 @@ -33,6 +33,8 @@ void common(void) {
19385 OFFSET(TI_status, thread_info, status);
19386 OFFSET(TI_addr_limit, thread_info, addr_limit);
19387 OFFSET(TI_preempt_count, thread_info, preempt_count);
19388 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19389 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19390
19391 BLANK();
19392 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19393 @@ -53,8 +55,26 @@ void common(void) {
19394 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19395 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19396 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19397 +
19398 +#ifdef CONFIG_PAX_KERNEXEC
19399 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19400 #endif
19401
19402 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19403 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19404 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19405 +#ifdef CONFIG_X86_64
19406 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19407 +#endif
19408 +#endif
19409 +
19410 +#endif
19411 +
19412 + BLANK();
19413 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19414 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19415 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19416 +
19417 #ifdef CONFIG_XEN
19418 BLANK();
19419 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19420 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19421 index e7c798b..2b2019b 100644
19422 --- a/arch/x86/kernel/asm-offsets_64.c
19423 +++ b/arch/x86/kernel/asm-offsets_64.c
19424 @@ -77,6 +77,7 @@ int main(void)
19425 BLANK();
19426 #undef ENTRY
19427
19428 + DEFINE(TSS_size, sizeof(struct tss_struct));
19429 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19430 BLANK();
19431
19432 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19433 index 47b56a7..efc2bc6 100644
19434 --- a/arch/x86/kernel/cpu/Makefile
19435 +++ b/arch/x86/kernel/cpu/Makefile
19436 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19437 CFLAGS_REMOVE_perf_event.o = -pg
19438 endif
19439
19440 -# Make sure load_percpu_segment has no stackprotector
19441 -nostackp := $(call cc-option, -fno-stack-protector)
19442 -CFLAGS_common.o := $(nostackp)
19443 -
19444 obj-y := intel_cacheinfo.o scattered.o topology.o
19445 obj-y += proc.o capflags.o powerflags.o common.o
19446 obj-y += rdrand.o
19447 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19448 index 08a0890..e557865 100644
19449 --- a/arch/x86/kernel/cpu/amd.c
19450 +++ b/arch/x86/kernel/cpu/amd.c
19451 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19452 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19453 {
19454 /* AMD errata T13 (order #21922) */
19455 - if ((c->x86 == 6)) {
19456 + if (c->x86 == 6) {
19457 /* Duron Rev A0 */
19458 if (c->x86_model == 3 && c->x86_mask == 0)
19459 size = 64;
19460 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19461 index 25eb274..3a92d93 100644
19462 --- a/arch/x86/kernel/cpu/common.c
19463 +++ b/arch/x86/kernel/cpu/common.c
19464 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19465
19466 static const struct cpu_dev *this_cpu = &default_cpu;
19467
19468 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19469 -#ifdef CONFIG_X86_64
19470 - /*
19471 - * We need valid kernel segments for data and code in long mode too
19472 - * IRET will check the segment types kkeil 2000/10/28
19473 - * Also sysret mandates a special GDT layout
19474 - *
19475 - * TLS descriptors are currently at a different place compared to i386.
19476 - * Hopefully nobody expects them at a fixed place (Wine?)
19477 - */
19478 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19479 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19480 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19481 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19482 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19483 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19484 -#else
19485 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19486 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19487 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19488 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19489 - /*
19490 - * Segments used for calling PnP BIOS have byte granularity.
19491 - * They code segments and data segments have fixed 64k limits,
19492 - * the transfer segment sizes are set at run time.
19493 - */
19494 - /* 32-bit code */
19495 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19496 - /* 16-bit code */
19497 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19498 - /* 16-bit data */
19499 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19500 - /* 16-bit data */
19501 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19502 - /* 16-bit data */
19503 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19504 - /*
19505 - * The APM segments have byte granularity and their bases
19506 - * are set at run time. All have 64k limits.
19507 - */
19508 - /* 32-bit code */
19509 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19510 - /* 16-bit code */
19511 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19512 - /* data */
19513 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19514 -
19515 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19516 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19517 - GDT_STACK_CANARY_INIT
19518 -#endif
19519 -} };
19520 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19521 -
19522 static int __init x86_xsave_setup(char *s)
19523 {
19524 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19525 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19526 set_in_cr4(X86_CR4_SMAP);
19527 }
19528
19529 +#ifdef CONFIG_X86_64
19530 +static __init int setup_disable_pcid(char *arg)
19531 +{
19532 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19533 +
19534 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19535 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19536 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19537 +#endif
19538 +
19539 + return 1;
19540 +}
19541 +__setup("nopcid", setup_disable_pcid);
19542 +
19543 +static void setup_pcid(struct cpuinfo_x86 *c)
19544 +{
19545 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19546 +
19547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19548 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19549 + pax_open_kernel();
19550 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19551 + pax_close_kernel();
19552 + printk("PAX: slow and weak UDEREF enabled\n");
19553 + } else
19554 + printk("PAX: UDEREF disabled\n");
19555 +#endif
19556 +
19557 + return;
19558 + }
19559 +
19560 + printk("PAX: PCID detected\n");
19561 + set_in_cr4(X86_CR4_PCIDE);
19562 +
19563 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19564 + pax_open_kernel();
19565 + clone_pgd_mask = ~(pgdval_t)0UL;
19566 + pax_close_kernel();
19567 + if (pax_user_shadow_base)
19568 + printk("PAX: weak UDEREF enabled\n");
19569 + else {
19570 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19571 + printk("PAX: strong UDEREF enabled\n");
19572 + }
19573 +#endif
19574 +
19575 + if (cpu_has(c, X86_FEATURE_INVPCID))
19576 + printk("PAX: INVPCID detected\n");
19577 +}
19578 +#endif
19579 +
19580 /*
19581 * Some CPU features depend on higher CPUID levels, which may not always
19582 * be available due to CPUID level capping or broken virtualization
19583 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19584 {
19585 struct desc_ptr gdt_descr;
19586
19587 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19588 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19589 gdt_descr.size = GDT_SIZE - 1;
19590 load_gdt(&gdt_descr);
19591 /* Reload the per-cpu base */
19592 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19593 setup_smep(c);
19594 setup_smap(c);
19595
19596 +#ifdef CONFIG_X86_64
19597 + setup_pcid(c);
19598 +#endif
19599 +
19600 /*
19601 * The vendor-specific functions might have changed features.
19602 * Now we do "generic changes."
19603 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19604 /* Filter out anything that depends on CPUID levels we don't have */
19605 filter_cpuid_features(c, true);
19606
19607 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19608 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19609 +#endif
19610 +
19611 /* If the model name is still unset, do table lookup. */
19612 if (!c->x86_model_id[0]) {
19613 const char *p;
19614 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19615 }
19616 __setup("clearcpuid=", setup_disablecpuid);
19617
19618 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19619 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19620 +
19621 #ifdef CONFIG_X86_64
19622 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19623 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19624 - (unsigned long) debug_idt_table };
19625 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19626 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19627
19628 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19629 irq_stack_union) __aligned(PAGE_SIZE);
19630 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19631 EXPORT_PER_CPU_SYMBOL(current_task);
19632
19633 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19634 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19635 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19636 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19637
19638 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19639 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19640 load_ucode_ap();
19641
19642 cpu = stack_smp_processor_id();
19643 - t = &per_cpu(init_tss, cpu);
19644 + t = init_tss + cpu;
19645 oist = &per_cpu(orig_ist, cpu);
19646
19647 #ifdef CONFIG_NUMA
19648 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19649 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19650 barrier();
19651
19652 - x86_configure_nx();
19653 enable_x2apic();
19654
19655 /*
19656 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19657 {
19658 int cpu = smp_processor_id();
19659 struct task_struct *curr = current;
19660 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19661 + struct tss_struct *t = init_tss + cpu;
19662 struct thread_struct *thread = &curr->thread;
19663
19664 show_ucode_info_early();
19665 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19666 index 1414c90..1159406 100644
19667 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19668 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19669 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19670 };
19671
19672 #ifdef CONFIG_AMD_NB
19673 +static struct attribute *default_attrs_amd_nb[] = {
19674 + &type.attr,
19675 + &level.attr,
19676 + &coherency_line_size.attr,
19677 + &physical_line_partition.attr,
19678 + &ways_of_associativity.attr,
19679 + &number_of_sets.attr,
19680 + &size.attr,
19681 + &shared_cpu_map.attr,
19682 + &shared_cpu_list.attr,
19683 + NULL,
19684 + NULL,
19685 + NULL,
19686 + NULL
19687 +};
19688 +
19689 static struct attribute **amd_l3_attrs(void)
19690 {
19691 static struct attribute **attrs;
19692 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19693
19694 n = ARRAY_SIZE(default_attrs);
19695
19696 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19697 - n += 2;
19698 -
19699 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19700 - n += 1;
19701 -
19702 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19703 - if (attrs == NULL)
19704 - return attrs = default_attrs;
19705 -
19706 - for (n = 0; default_attrs[n]; n++)
19707 - attrs[n] = default_attrs[n];
19708 + attrs = default_attrs_amd_nb;
19709
19710 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19711 attrs[n++] = &cache_disable_0.attr;
19712 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19713 .default_attrs = default_attrs,
19714 };
19715
19716 +#ifdef CONFIG_AMD_NB
19717 +static struct kobj_type ktype_cache_amd_nb = {
19718 + .sysfs_ops = &sysfs_ops,
19719 + .default_attrs = default_attrs_amd_nb,
19720 +};
19721 +#endif
19722 +
19723 static struct kobj_type ktype_percpu_entry = {
19724 .sysfs_ops = &sysfs_ops,
19725 };
19726 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19727 return retval;
19728 }
19729
19730 +#ifdef CONFIG_AMD_NB
19731 + amd_l3_attrs();
19732 +#endif
19733 +
19734 for (i = 0; i < num_cache_leaves; i++) {
19735 + struct kobj_type *ktype;
19736 +
19737 this_object = INDEX_KOBJECT_PTR(cpu, i);
19738 this_object->cpu = cpu;
19739 this_object->index = i;
19740
19741 this_leaf = CPUID4_INFO_IDX(cpu, i);
19742
19743 - ktype_cache.default_attrs = default_attrs;
19744 + ktype = &ktype_cache;
19745 #ifdef CONFIG_AMD_NB
19746 if (this_leaf->base.nb)
19747 - ktype_cache.default_attrs = amd_l3_attrs();
19748 + ktype = &ktype_cache_amd_nb;
19749 #endif
19750 retval = kobject_init_and_add(&(this_object->kobj),
19751 - &ktype_cache,
19752 + ktype,
19753 per_cpu(ici_cache_kobject, cpu),
19754 "index%1lu", i);
19755 if (unlikely(retval)) {
19756 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19757 index 87a65c9..92fcce6 100644
19758 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19759 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19760 @@ -45,6 +45,7 @@
19761 #include <asm/processor.h>
19762 #include <asm/mce.h>
19763 #include <asm/msr.h>
19764 +#include <asm/local.h>
19765
19766 #include "mce-internal.h"
19767
19768 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19769 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19770 m->cs, m->ip);
19771
19772 - if (m->cs == __KERNEL_CS)
19773 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19774 print_symbol("{%s}", m->ip);
19775 pr_cont("\n");
19776 }
19777 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19778
19779 #define PANIC_TIMEOUT 5 /* 5 seconds */
19780
19781 -static atomic_t mce_paniced;
19782 +static atomic_unchecked_t mce_paniced;
19783
19784 static int fake_panic;
19785 -static atomic_t mce_fake_paniced;
19786 +static atomic_unchecked_t mce_fake_paniced;
19787
19788 /* Panic in progress. Enable interrupts and wait for final IPI */
19789 static void wait_for_panic(void)
19790 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19791 /*
19792 * Make sure only one CPU runs in machine check panic
19793 */
19794 - if (atomic_inc_return(&mce_paniced) > 1)
19795 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19796 wait_for_panic();
19797 barrier();
19798
19799 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19800 console_verbose();
19801 } else {
19802 /* Don't log too much for fake panic */
19803 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19804 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19805 return;
19806 }
19807 /* First print corrected ones that are still unlogged */
19808 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19809 if (!fake_panic) {
19810 if (panic_timeout == 0)
19811 panic_timeout = mca_cfg.panic_timeout;
19812 - panic(msg);
19813 + panic("%s", msg);
19814 } else
19815 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19816 }
19817 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19818 * might have been modified by someone else.
19819 */
19820 rmb();
19821 - if (atomic_read(&mce_paniced))
19822 + if (atomic_read_unchecked(&mce_paniced))
19823 wait_for_panic();
19824 if (!mca_cfg.monarch_timeout)
19825 goto out;
19826 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19827 }
19828
19829 /* Call the installed machine check handler for this CPU setup. */
19830 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19831 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19832 unexpected_machine_check;
19833
19834 /*
19835 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19836 return;
19837 }
19838
19839 + pax_open_kernel();
19840 machine_check_vector = do_machine_check;
19841 + pax_close_kernel();
19842
19843 __mcheck_cpu_init_generic();
19844 __mcheck_cpu_init_vendor(c);
19845 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19846 */
19847
19848 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19849 -static int mce_chrdev_open_count; /* #times opened */
19850 +static local_t mce_chrdev_open_count; /* #times opened */
19851 static int mce_chrdev_open_exclu; /* already open exclusive? */
19852
19853 static int mce_chrdev_open(struct inode *inode, struct file *file)
19854 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19855 spin_lock(&mce_chrdev_state_lock);
19856
19857 if (mce_chrdev_open_exclu ||
19858 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19859 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19860 spin_unlock(&mce_chrdev_state_lock);
19861
19862 return -EBUSY;
19863 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19864
19865 if (file->f_flags & O_EXCL)
19866 mce_chrdev_open_exclu = 1;
19867 - mce_chrdev_open_count++;
19868 + local_inc(&mce_chrdev_open_count);
19869
19870 spin_unlock(&mce_chrdev_state_lock);
19871
19872 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19873 {
19874 spin_lock(&mce_chrdev_state_lock);
19875
19876 - mce_chrdev_open_count--;
19877 + local_dec(&mce_chrdev_open_count);
19878 mce_chrdev_open_exclu = 0;
19879
19880 spin_unlock(&mce_chrdev_state_lock);
19881 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19882
19883 for (i = 0; i < mca_cfg.banks; i++) {
19884 struct mce_bank *b = &mce_banks[i];
19885 - struct device_attribute *a = &b->attr;
19886 + device_attribute_no_const *a = &b->attr;
19887
19888 sysfs_attr_init(&a->attr);
19889 a->attr.name = b->attrname;
19890 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19891 static void mce_reset(void)
19892 {
19893 cpu_missing = 0;
19894 - atomic_set(&mce_fake_paniced, 0);
19895 + atomic_set_unchecked(&mce_fake_paniced, 0);
19896 atomic_set(&mce_executing, 0);
19897 atomic_set(&mce_callin, 0);
19898 atomic_set(&global_nwo, 0);
19899 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19900 index 1c044b1..37a2a43 100644
19901 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19902 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19903 @@ -11,6 +11,7 @@
19904 #include <asm/processor.h>
19905 #include <asm/mce.h>
19906 #include <asm/msr.h>
19907 +#include <asm/pgtable.h>
19908
19909 /* By default disabled */
19910 int mce_p5_enabled __read_mostly;
19911 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19912 if (!cpu_has(c, X86_FEATURE_MCE))
19913 return;
19914
19915 + pax_open_kernel();
19916 machine_check_vector = pentium_machine_check;
19917 + pax_close_kernel();
19918 /* Make sure the vector pointer is visible before we enable MCEs: */
19919 wmb();
19920
19921 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19922 index e9a701a..35317d6 100644
19923 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19924 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19925 @@ -10,6 +10,7 @@
19926 #include <asm/processor.h>
19927 #include <asm/mce.h>
19928 #include <asm/msr.h>
19929 +#include <asm/pgtable.h>
19930
19931 /* Machine check handler for WinChip C6: */
19932 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19933 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19934 {
19935 u32 lo, hi;
19936
19937 + pax_open_kernel();
19938 machine_check_vector = winchip_machine_check;
19939 + pax_close_kernel();
19940 /* Make sure the vector pointer is visible before we enable MCEs: */
19941 wmb();
19942
19943 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19944 index f961de9..8a9d332 100644
19945 --- a/arch/x86/kernel/cpu/mtrr/main.c
19946 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19947 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19948 u64 size_or_mask, size_and_mask;
19949 static bool mtrr_aps_delayed_init;
19950
19951 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19952 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19953
19954 const struct mtrr_ops *mtrr_if;
19955
19956 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19957 index df5e41f..816c719 100644
19958 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19959 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19960 @@ -25,7 +25,7 @@ struct mtrr_ops {
19961 int (*validate_add_page)(unsigned long base, unsigned long size,
19962 unsigned int type);
19963 int (*have_wrcomb)(void);
19964 -};
19965 +} __do_const;
19966
19967 extern int generic_get_free_region(unsigned long base, unsigned long size,
19968 int replace_reg);
19969 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19970 index a7c7305..b9705ab 100644
19971 --- a/arch/x86/kernel/cpu/perf_event.c
19972 +++ b/arch/x86/kernel/cpu/perf_event.c
19973 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19974 pr_info("no hardware sampling interrupt available.\n");
19975 }
19976
19977 -static struct attribute_group x86_pmu_format_group = {
19978 +static attribute_group_no_const x86_pmu_format_group = {
19979 .name = "format",
19980 .attrs = NULL,
19981 };
19982 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19983 NULL,
19984 };
19985
19986 -static struct attribute_group x86_pmu_events_group = {
19987 +static attribute_group_no_const x86_pmu_events_group = {
19988 .name = "events",
19989 .attrs = events_attr,
19990 };
19991 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19992 if (idx > GDT_ENTRIES)
19993 return 0;
19994
19995 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19996 + desc = get_cpu_gdt_table(smp_processor_id());
19997 }
19998
19999 return get_desc_base(desc + idx);
20000 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20001 break;
20002
20003 perf_callchain_store(entry, frame.return_address);
20004 - fp = frame.next_frame;
20005 + fp = (const void __force_user *)frame.next_frame;
20006 }
20007 }
20008
20009 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20010 index 639d128..e92d7e5 100644
20011 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20012 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20013 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20014 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20015 {
20016 struct attribute **attrs;
20017 - struct attribute_group *attr_group;
20018 + attribute_group_no_const *attr_group;
20019 int i = 0, j;
20020
20021 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20022 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20023 index a45d8d4..8abd32c 100644
20024 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20025 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20026 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20027 * v2 and above have a perf capabilities MSR
20028 */
20029 if (version > 1) {
20030 - u64 capabilities;
20031 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20032
20033 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20034 - x86_pmu.intel_cap.capabilities = capabilities;
20035 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20036 + x86_pmu.intel_cap.capabilities = capabilities;
20037 }
20038
20039 intel_ds_init();
20040 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20041 index 1fb6c72..f5fa2a3 100644
20042 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20043 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20044 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20045 static int __init uncore_type_init(struct intel_uncore_type *type)
20046 {
20047 struct intel_uncore_pmu *pmus;
20048 - struct attribute_group *attr_group;
20049 + attribute_group_no_const *attr_group;
20050 struct attribute **attrs;
20051 int i, j;
20052
20053 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20054 index 47b3d00c..2cf1751 100644
20055 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20056 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20057 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20058 struct uncore_event_desc {
20059 struct kobj_attribute attr;
20060 const char *config;
20061 -};
20062 +} __do_const;
20063
20064 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20065 { \
20066 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20067 index 7d9481c..99c7e4b 100644
20068 --- a/arch/x86/kernel/cpuid.c
20069 +++ b/arch/x86/kernel/cpuid.c
20070 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20071 return notifier_from_errno(err);
20072 }
20073
20074 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20075 +static struct notifier_block cpuid_class_cpu_notifier =
20076 {
20077 .notifier_call = cpuid_class_cpu_callback,
20078 };
20079 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20080 index 74467fe..18793d5 100644
20081 --- a/arch/x86/kernel/crash.c
20082 +++ b/arch/x86/kernel/crash.c
20083 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20084 {
20085 #ifdef CONFIG_X86_32
20086 struct pt_regs fixed_regs;
20087 -#endif
20088
20089 -#ifdef CONFIG_X86_32
20090 - if (!user_mode_vm(regs)) {
20091 + if (!user_mode(regs)) {
20092 crash_fixup_ss_esp(&fixed_regs, regs);
20093 regs = &fixed_regs;
20094 }
20095 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20096 index afa64ad..dce67dd 100644
20097 --- a/arch/x86/kernel/crash_dump_64.c
20098 +++ b/arch/x86/kernel/crash_dump_64.c
20099 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20100 return -ENOMEM;
20101
20102 if (userbuf) {
20103 - if (copy_to_user(buf, vaddr + offset, csize)) {
20104 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20105 iounmap(vaddr);
20106 return -EFAULT;
20107 }
20108 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20109 index 5d3fe8d..02e1429 100644
20110 --- a/arch/x86/kernel/doublefault.c
20111 +++ b/arch/x86/kernel/doublefault.c
20112 @@ -13,7 +13,7 @@
20113
20114 #define DOUBLEFAULT_STACKSIZE (1024)
20115 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20116 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20117 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20118
20119 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20120
20121 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20122 unsigned long gdt, tss;
20123
20124 native_store_gdt(&gdt_desc);
20125 - gdt = gdt_desc.address;
20126 + gdt = (unsigned long)gdt_desc.address;
20127
20128 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20129
20130 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20131 /* 0x2 bit is always set */
20132 .flags = X86_EFLAGS_SF | 0x2,
20133 .sp = STACK_START,
20134 - .es = __USER_DS,
20135 + .es = __KERNEL_DS,
20136 .cs = __KERNEL_CS,
20137 .ss = __KERNEL_DS,
20138 - .ds = __USER_DS,
20139 + .ds = __KERNEL_DS,
20140 .fs = __KERNEL_PERCPU,
20141
20142 .__cr3 = __pa_nodebug(swapper_pg_dir),
20143 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20144 index deb6421..76bbc12 100644
20145 --- a/arch/x86/kernel/dumpstack.c
20146 +++ b/arch/x86/kernel/dumpstack.c
20147 @@ -2,6 +2,9 @@
20148 * Copyright (C) 1991, 1992 Linus Torvalds
20149 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20150 */
20151 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20152 +#define __INCLUDED_BY_HIDESYM 1
20153 +#endif
20154 #include <linux/kallsyms.h>
20155 #include <linux/kprobes.h>
20156 #include <linux/uaccess.h>
20157 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20158 static void
20159 print_ftrace_graph_addr(unsigned long addr, void *data,
20160 const struct stacktrace_ops *ops,
20161 - struct thread_info *tinfo, int *graph)
20162 + struct task_struct *task, int *graph)
20163 {
20164 - struct task_struct *task;
20165 unsigned long ret_addr;
20166 int index;
20167
20168 if (addr != (unsigned long)return_to_handler)
20169 return;
20170
20171 - task = tinfo->task;
20172 index = task->curr_ret_stack;
20173
20174 if (!task->ret_stack || index < *graph)
20175 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20176 static inline void
20177 print_ftrace_graph_addr(unsigned long addr, void *data,
20178 const struct stacktrace_ops *ops,
20179 - struct thread_info *tinfo, int *graph)
20180 + struct task_struct *task, int *graph)
20181 { }
20182 #endif
20183
20184 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20185 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20186 */
20187
20188 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20189 - void *p, unsigned int size, void *end)
20190 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20191 {
20192 - void *t = tinfo;
20193 if (end) {
20194 if (p < end && p >= (end-THREAD_SIZE))
20195 return 1;
20196 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20197 }
20198
20199 unsigned long
20200 -print_context_stack(struct thread_info *tinfo,
20201 +print_context_stack(struct task_struct *task, void *stack_start,
20202 unsigned long *stack, unsigned long bp,
20203 const struct stacktrace_ops *ops, void *data,
20204 unsigned long *end, int *graph)
20205 {
20206 struct stack_frame *frame = (struct stack_frame *)bp;
20207
20208 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20209 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20210 unsigned long addr;
20211
20212 addr = *stack;
20213 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20214 } else {
20215 ops->address(data, addr, 0);
20216 }
20217 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20218 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20219 }
20220 stack++;
20221 }
20222 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20223 EXPORT_SYMBOL_GPL(print_context_stack);
20224
20225 unsigned long
20226 -print_context_stack_bp(struct thread_info *tinfo,
20227 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20228 unsigned long *stack, unsigned long bp,
20229 const struct stacktrace_ops *ops, void *data,
20230 unsigned long *end, int *graph)
20231 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20232 struct stack_frame *frame = (struct stack_frame *)bp;
20233 unsigned long *ret_addr = &frame->return_address;
20234
20235 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20236 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20237 unsigned long addr = *ret_addr;
20238
20239 if (!__kernel_text_address(addr))
20240 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20241 ops->address(data, addr, 1);
20242 frame = frame->next_frame;
20243 ret_addr = &frame->return_address;
20244 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20245 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20246 }
20247
20248 return (unsigned long)frame;
20249 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20250 static void print_trace_address(void *data, unsigned long addr, int reliable)
20251 {
20252 touch_nmi_watchdog();
20253 - printk(data);
20254 + printk("%s", (char *)data);
20255 printk_address(addr, reliable);
20256 }
20257
20258 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20259 }
20260 EXPORT_SYMBOL_GPL(oops_begin);
20261
20262 +extern void gr_handle_kernel_exploit(void);
20263 +
20264 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20265 {
20266 if (regs && kexec_should_crash(current))
20267 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20268 panic("Fatal exception in interrupt");
20269 if (panic_on_oops)
20270 panic("Fatal exception");
20271 - do_exit(signr);
20272 +
20273 + gr_handle_kernel_exploit();
20274 +
20275 + do_group_exit(signr);
20276 }
20277
20278 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20279 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20280 print_modules();
20281 show_regs(regs);
20282 #ifdef CONFIG_X86_32
20283 - if (user_mode_vm(regs)) {
20284 + if (user_mode(regs)) {
20285 sp = regs->sp;
20286 ss = regs->ss & 0xffff;
20287 } else {
20288 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20289 unsigned long flags = oops_begin();
20290 int sig = SIGSEGV;
20291
20292 - if (!user_mode_vm(regs))
20293 + if (!user_mode(regs))
20294 report_bug(regs->ip, regs);
20295
20296 if (__die(str, regs, err))
20297 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20298 index f2a1770..540657f 100644
20299 --- a/arch/x86/kernel/dumpstack_32.c
20300 +++ b/arch/x86/kernel/dumpstack_32.c
20301 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20302 bp = stack_frame(task, regs);
20303
20304 for (;;) {
20305 - struct thread_info *context;
20306 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20307
20308 - context = (struct thread_info *)
20309 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20310 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20311 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20312
20313 - stack = (unsigned long *)context->previous_esp;
20314 - if (!stack)
20315 + if (stack_start == task_stack_page(task))
20316 break;
20317 + stack = *(unsigned long **)stack_start;
20318 if (ops->stack(data, "IRQ") < 0)
20319 break;
20320 touch_nmi_watchdog();
20321 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20322 int i;
20323
20324 show_regs_print_info(KERN_EMERG);
20325 - __show_regs(regs, !user_mode_vm(regs));
20326 + __show_regs(regs, !user_mode(regs));
20327
20328 /*
20329 * When in-kernel, we also print out the stack and code at the
20330 * time of the fault..
20331 */
20332 - if (!user_mode_vm(regs)) {
20333 + if (!user_mode(regs)) {
20334 unsigned int code_prologue = code_bytes * 43 / 64;
20335 unsigned int code_len = code_bytes;
20336 unsigned char c;
20337 u8 *ip;
20338 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20339
20340 pr_emerg("Stack:\n");
20341 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20342
20343 pr_emerg("Code:");
20344
20345 - ip = (u8 *)regs->ip - code_prologue;
20346 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20347 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20348 /* try starting at IP */
20349 - ip = (u8 *)regs->ip;
20350 + ip = (u8 *)regs->ip + cs_base;
20351 code_len = code_len - code_prologue + 1;
20352 }
20353 for (i = 0; i < code_len; i++, ip++) {
20354 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20355 pr_cont(" Bad EIP value.");
20356 break;
20357 }
20358 - if (ip == (u8 *)regs->ip)
20359 + if (ip == (u8 *)regs->ip + cs_base)
20360 pr_cont(" <%02x>", c);
20361 else
20362 pr_cont(" %02x", c);
20363 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20364 {
20365 unsigned short ud2;
20366
20367 + ip = ktla_ktva(ip);
20368 if (ip < PAGE_OFFSET)
20369 return 0;
20370 if (probe_kernel_address((unsigned short *)ip, ud2))
20371 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20372
20373 return ud2 == 0x0b0f;
20374 }
20375 +
20376 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20377 +void pax_check_alloca(unsigned long size)
20378 +{
20379 + unsigned long sp = (unsigned long)&sp, stack_left;
20380 +
20381 + /* all kernel stacks are of the same size */
20382 + stack_left = sp & (THREAD_SIZE - 1);
20383 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20384 +}
20385 +EXPORT_SYMBOL(pax_check_alloca);
20386 +#endif
20387 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20388 index addb207..99635fa 100644
20389 --- a/arch/x86/kernel/dumpstack_64.c
20390 +++ b/arch/x86/kernel/dumpstack_64.c
20391 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20392 unsigned long *irq_stack_end =
20393 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20394 unsigned used = 0;
20395 - struct thread_info *tinfo;
20396 int graph = 0;
20397 unsigned long dummy;
20398 + void *stack_start;
20399
20400 if (!task)
20401 task = current;
20402 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20403 * current stack address. If the stacks consist of nested
20404 * exceptions
20405 */
20406 - tinfo = task_thread_info(task);
20407 for (;;) {
20408 char *id;
20409 unsigned long *estack_end;
20410 +
20411 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20412 &used, &id);
20413
20414 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20415 if (ops->stack(data, id) < 0)
20416 break;
20417
20418 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20419 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20420 data, estack_end, &graph);
20421 ops->stack(data, "<EOE>");
20422 /*
20423 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20424 * second-to-last pointer (index -2 to end) in the
20425 * exception stack:
20426 */
20427 + if ((u16)estack_end[-1] != __KERNEL_DS)
20428 + goto out;
20429 stack = (unsigned long *) estack_end[-2];
20430 continue;
20431 }
20432 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20433 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20434 if (ops->stack(data, "IRQ") < 0)
20435 break;
20436 - bp = ops->walk_stack(tinfo, stack, bp,
20437 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20438 ops, data, irq_stack_end, &graph);
20439 /*
20440 * We link to the next stack (which would be
20441 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20442 /*
20443 * This handles the process stack:
20444 */
20445 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20446 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20447 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20448 +out:
20449 put_cpu();
20450 }
20451 EXPORT_SYMBOL(dump_trace);
20452 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20453
20454 return ud2 == 0x0b0f;
20455 }
20456 +
20457 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20458 +void pax_check_alloca(unsigned long size)
20459 +{
20460 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20461 + unsigned cpu, used;
20462 + char *id;
20463 +
20464 + /* check the process stack first */
20465 + stack_start = (unsigned long)task_stack_page(current);
20466 + stack_end = stack_start + THREAD_SIZE;
20467 + if (likely(stack_start <= sp && sp < stack_end)) {
20468 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20469 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20470 + return;
20471 + }
20472 +
20473 + cpu = get_cpu();
20474 +
20475 + /* check the irq stacks */
20476 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20477 + stack_start = stack_end - IRQ_STACK_SIZE;
20478 + if (stack_start <= sp && sp < stack_end) {
20479 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20480 + put_cpu();
20481 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20482 + return;
20483 + }
20484 +
20485 + /* check the exception stacks */
20486 + used = 0;
20487 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20488 + stack_start = stack_end - EXCEPTION_STKSZ;
20489 + if (stack_end && stack_start <= sp && sp < stack_end) {
20490 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20491 + put_cpu();
20492 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20493 + return;
20494 + }
20495 +
20496 + put_cpu();
20497 +
20498 + /* unknown stack */
20499 + BUG();
20500 +}
20501 +EXPORT_SYMBOL(pax_check_alloca);
20502 +#endif
20503 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20504 index 174da5f..5e55606 100644
20505 --- a/arch/x86/kernel/e820.c
20506 +++ b/arch/x86/kernel/e820.c
20507 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20508
20509 static void early_panic(char *msg)
20510 {
20511 - early_printk(msg);
20512 - panic(msg);
20513 + early_printk("%s", msg);
20514 + panic("%s", msg);
20515 }
20516
20517 static int userdef __initdata;
20518 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20519 index d15f575..d692043 100644
20520 --- a/arch/x86/kernel/early_printk.c
20521 +++ b/arch/x86/kernel/early_printk.c
20522 @@ -7,6 +7,7 @@
20523 #include <linux/pci_regs.h>
20524 #include <linux/pci_ids.h>
20525 #include <linux/errno.h>
20526 +#include <linux/sched.h>
20527 #include <asm/io.h>
20528 #include <asm/processor.h>
20529 #include <asm/fcntl.h>
20530 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20531 index 2cfbc3a..b756682 100644
20532 --- a/arch/x86/kernel/entry_32.S
20533 +++ b/arch/x86/kernel/entry_32.S
20534 @@ -177,13 +177,153 @@
20535 /*CFI_REL_OFFSET gs, PT_GS*/
20536 .endm
20537 .macro SET_KERNEL_GS reg
20538 +
20539 +#ifdef CONFIG_CC_STACKPROTECTOR
20540 movl $(__KERNEL_STACK_CANARY), \reg
20541 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20542 + movl $(__USER_DS), \reg
20543 +#else
20544 + xorl \reg, \reg
20545 +#endif
20546 +
20547 movl \reg, %gs
20548 .endm
20549
20550 #endif /* CONFIG_X86_32_LAZY_GS */
20551
20552 -.macro SAVE_ALL
20553 +.macro pax_enter_kernel
20554 +#ifdef CONFIG_PAX_KERNEXEC
20555 + call pax_enter_kernel
20556 +#endif
20557 +.endm
20558 +
20559 +.macro pax_exit_kernel
20560 +#ifdef CONFIG_PAX_KERNEXEC
20561 + call pax_exit_kernel
20562 +#endif
20563 +.endm
20564 +
20565 +#ifdef CONFIG_PAX_KERNEXEC
20566 +ENTRY(pax_enter_kernel)
20567 +#ifdef CONFIG_PARAVIRT
20568 + pushl %eax
20569 + pushl %ecx
20570 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20571 + mov %eax, %esi
20572 +#else
20573 + mov %cr0, %esi
20574 +#endif
20575 + bts $16, %esi
20576 + jnc 1f
20577 + mov %cs, %esi
20578 + cmp $__KERNEL_CS, %esi
20579 + jz 3f
20580 + ljmp $__KERNEL_CS, $3f
20581 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20582 +2:
20583 +#ifdef CONFIG_PARAVIRT
20584 + mov %esi, %eax
20585 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20586 +#else
20587 + mov %esi, %cr0
20588 +#endif
20589 +3:
20590 +#ifdef CONFIG_PARAVIRT
20591 + popl %ecx
20592 + popl %eax
20593 +#endif
20594 + ret
20595 +ENDPROC(pax_enter_kernel)
20596 +
20597 +ENTRY(pax_exit_kernel)
20598 +#ifdef CONFIG_PARAVIRT
20599 + pushl %eax
20600 + pushl %ecx
20601 +#endif
20602 + mov %cs, %esi
20603 + cmp $__KERNEXEC_KERNEL_CS, %esi
20604 + jnz 2f
20605 +#ifdef CONFIG_PARAVIRT
20606 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20607 + mov %eax, %esi
20608 +#else
20609 + mov %cr0, %esi
20610 +#endif
20611 + btr $16, %esi
20612 + ljmp $__KERNEL_CS, $1f
20613 +1:
20614 +#ifdef CONFIG_PARAVIRT
20615 + mov %esi, %eax
20616 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20617 +#else
20618 + mov %esi, %cr0
20619 +#endif
20620 +2:
20621 +#ifdef CONFIG_PARAVIRT
20622 + popl %ecx
20623 + popl %eax
20624 +#endif
20625 + ret
20626 +ENDPROC(pax_exit_kernel)
20627 +#endif
20628 +
20629 + .macro pax_erase_kstack
20630 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20631 + call pax_erase_kstack
20632 +#endif
20633 + .endm
20634 +
20635 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20636 +/*
20637 + * ebp: thread_info
20638 + */
20639 +ENTRY(pax_erase_kstack)
20640 + pushl %edi
20641 + pushl %ecx
20642 + pushl %eax
20643 +
20644 + mov TI_lowest_stack(%ebp), %edi
20645 + mov $-0xBEEF, %eax
20646 + std
20647 +
20648 +1: mov %edi, %ecx
20649 + and $THREAD_SIZE_asm - 1, %ecx
20650 + shr $2, %ecx
20651 + repne scasl
20652 + jecxz 2f
20653 +
20654 + cmp $2*16, %ecx
20655 + jc 2f
20656 +
20657 + mov $2*16, %ecx
20658 + repe scasl
20659 + jecxz 2f
20660 + jne 1b
20661 +
20662 +2: cld
20663 + mov %esp, %ecx
20664 + sub %edi, %ecx
20665 +
20666 + cmp $THREAD_SIZE_asm, %ecx
20667 + jb 3f
20668 + ud2
20669 +3:
20670 +
20671 + shr $2, %ecx
20672 + rep stosl
20673 +
20674 + mov TI_task_thread_sp0(%ebp), %edi
20675 + sub $128, %edi
20676 + mov %edi, TI_lowest_stack(%ebp)
20677 +
20678 + popl %eax
20679 + popl %ecx
20680 + popl %edi
20681 + ret
20682 +ENDPROC(pax_erase_kstack)
20683 +#endif
20684 +
20685 +.macro __SAVE_ALL _DS
20686 cld
20687 PUSH_GS
20688 pushl_cfi %fs
20689 @@ -206,7 +346,7 @@
20690 CFI_REL_OFFSET ecx, 0
20691 pushl_cfi %ebx
20692 CFI_REL_OFFSET ebx, 0
20693 - movl $(__USER_DS), %edx
20694 + movl $\_DS, %edx
20695 movl %edx, %ds
20696 movl %edx, %es
20697 movl $(__KERNEL_PERCPU), %edx
20698 @@ -214,6 +354,15 @@
20699 SET_KERNEL_GS %edx
20700 .endm
20701
20702 +.macro SAVE_ALL
20703 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20704 + __SAVE_ALL __KERNEL_DS
20705 + pax_enter_kernel
20706 +#else
20707 + __SAVE_ALL __USER_DS
20708 +#endif
20709 +.endm
20710 +
20711 .macro RESTORE_INT_REGS
20712 popl_cfi %ebx
20713 CFI_RESTORE ebx
20714 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20715 popfl_cfi
20716 jmp syscall_exit
20717 CFI_ENDPROC
20718 -END(ret_from_fork)
20719 +ENDPROC(ret_from_fork)
20720
20721 ENTRY(ret_from_kernel_thread)
20722 CFI_STARTPROC
20723 @@ -344,7 +493,15 @@ ret_from_intr:
20724 andl $SEGMENT_RPL_MASK, %eax
20725 #endif
20726 cmpl $USER_RPL, %eax
20727 +
20728 +#ifdef CONFIG_PAX_KERNEXEC
20729 + jae resume_userspace
20730 +
20731 + pax_exit_kernel
20732 + jmp resume_kernel
20733 +#else
20734 jb resume_kernel # not returning to v8086 or userspace
20735 +#endif
20736
20737 ENTRY(resume_userspace)
20738 LOCKDEP_SYS_EXIT
20739 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20740 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20741 # int/exception return?
20742 jne work_pending
20743 - jmp restore_all
20744 -END(ret_from_exception)
20745 + jmp restore_all_pax
20746 +ENDPROC(ret_from_exception)
20747
20748 #ifdef CONFIG_PREEMPT
20749 ENTRY(resume_kernel)
20750 @@ -372,7 +529,7 @@ need_resched:
20751 jz restore_all
20752 call preempt_schedule_irq
20753 jmp need_resched
20754 -END(resume_kernel)
20755 +ENDPROC(resume_kernel)
20756 #endif
20757 CFI_ENDPROC
20758 /*
20759 @@ -406,30 +563,45 @@ sysenter_past_esp:
20760 /*CFI_REL_OFFSET cs, 0*/
20761 /*
20762 * Push current_thread_info()->sysenter_return to the stack.
20763 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20764 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20765 */
20766 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20767 + pushl_cfi $0
20768 CFI_REL_OFFSET eip, 0
20769
20770 pushl_cfi %eax
20771 SAVE_ALL
20772 + GET_THREAD_INFO(%ebp)
20773 + movl TI_sysenter_return(%ebp),%ebp
20774 + movl %ebp,PT_EIP(%esp)
20775 ENABLE_INTERRUPTS(CLBR_NONE)
20776
20777 /*
20778 * Load the potential sixth argument from user stack.
20779 * Careful about security.
20780 */
20781 + movl PT_OLDESP(%esp),%ebp
20782 +
20783 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20784 + mov PT_OLDSS(%esp),%ds
20785 +1: movl %ds:(%ebp),%ebp
20786 + push %ss
20787 + pop %ds
20788 +#else
20789 cmpl $__PAGE_OFFSET-3,%ebp
20790 jae syscall_fault
20791 ASM_STAC
20792 1: movl (%ebp),%ebp
20793 ASM_CLAC
20794 +#endif
20795 +
20796 movl %ebp,PT_EBP(%esp)
20797 _ASM_EXTABLE(1b,syscall_fault)
20798
20799 GET_THREAD_INFO(%ebp)
20800
20801 +#ifdef CONFIG_PAX_RANDKSTACK
20802 + pax_erase_kstack
20803 +#endif
20804 +
20805 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20806 jnz sysenter_audit
20807 sysenter_do_call:
20808 @@ -444,12 +616,24 @@ sysenter_do_call:
20809 testl $_TIF_ALLWORK_MASK, %ecx
20810 jne sysexit_audit
20811 sysenter_exit:
20812 +
20813 +#ifdef CONFIG_PAX_RANDKSTACK
20814 + pushl_cfi %eax
20815 + movl %esp, %eax
20816 + call pax_randomize_kstack
20817 + popl_cfi %eax
20818 +#endif
20819 +
20820 + pax_erase_kstack
20821 +
20822 /* if something modifies registers it must also disable sysexit */
20823 movl PT_EIP(%esp), %edx
20824 movl PT_OLDESP(%esp), %ecx
20825 xorl %ebp,%ebp
20826 TRACE_IRQS_ON
20827 1: mov PT_FS(%esp), %fs
20828 +2: mov PT_DS(%esp), %ds
20829 +3: mov PT_ES(%esp), %es
20830 PTGS_TO_GS
20831 ENABLE_INTERRUPTS_SYSEXIT
20832
20833 @@ -466,6 +650,9 @@ sysenter_audit:
20834 movl %eax,%edx /* 2nd arg: syscall number */
20835 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20836 call __audit_syscall_entry
20837 +
20838 + pax_erase_kstack
20839 +
20840 pushl_cfi %ebx
20841 movl PT_EAX(%esp),%eax /* reload syscall number */
20842 jmp sysenter_do_call
20843 @@ -491,10 +678,16 @@ sysexit_audit:
20844
20845 CFI_ENDPROC
20846 .pushsection .fixup,"ax"
20847 -2: movl $0,PT_FS(%esp)
20848 +4: movl $0,PT_FS(%esp)
20849 + jmp 1b
20850 +5: movl $0,PT_DS(%esp)
20851 + jmp 1b
20852 +6: movl $0,PT_ES(%esp)
20853 jmp 1b
20854 .popsection
20855 - _ASM_EXTABLE(1b,2b)
20856 + _ASM_EXTABLE(1b,4b)
20857 + _ASM_EXTABLE(2b,5b)
20858 + _ASM_EXTABLE(3b,6b)
20859 PTGS_TO_GS_EX
20860 ENDPROC(ia32_sysenter_target)
20861
20862 @@ -509,6 +702,11 @@ ENTRY(system_call)
20863 pushl_cfi %eax # save orig_eax
20864 SAVE_ALL
20865 GET_THREAD_INFO(%ebp)
20866 +
20867 +#ifdef CONFIG_PAX_RANDKSTACK
20868 + pax_erase_kstack
20869 +#endif
20870 +
20871 # system call tracing in operation / emulation
20872 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20873 jnz syscall_trace_entry
20874 @@ -527,6 +725,15 @@ syscall_exit:
20875 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20876 jne syscall_exit_work
20877
20878 +restore_all_pax:
20879 +
20880 +#ifdef CONFIG_PAX_RANDKSTACK
20881 + movl %esp, %eax
20882 + call pax_randomize_kstack
20883 +#endif
20884 +
20885 + pax_erase_kstack
20886 +
20887 restore_all:
20888 TRACE_IRQS_IRET
20889 restore_all_notrace:
20890 @@ -583,14 +790,34 @@ ldt_ss:
20891 * compensating for the offset by changing to the ESPFIX segment with
20892 * a base address that matches for the difference.
20893 */
20894 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20895 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20896 mov %esp, %edx /* load kernel esp */
20897 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20898 mov %dx, %ax /* eax: new kernel esp */
20899 sub %eax, %edx /* offset (low word is 0) */
20900 +#ifdef CONFIG_SMP
20901 + movl PER_CPU_VAR(cpu_number), %ebx
20902 + shll $PAGE_SHIFT_asm, %ebx
20903 + addl $cpu_gdt_table, %ebx
20904 +#else
20905 + movl $cpu_gdt_table, %ebx
20906 +#endif
20907 shr $16, %edx
20908 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20909 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20910 +
20911 +#ifdef CONFIG_PAX_KERNEXEC
20912 + mov %cr0, %esi
20913 + btr $16, %esi
20914 + mov %esi, %cr0
20915 +#endif
20916 +
20917 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20918 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20919 +
20920 +#ifdef CONFIG_PAX_KERNEXEC
20921 + bts $16, %esi
20922 + mov %esi, %cr0
20923 +#endif
20924 +
20925 pushl_cfi $__ESPFIX_SS
20926 pushl_cfi %eax /* new kernel esp */
20927 /* Disable interrupts, but do not irqtrace this section: we
20928 @@ -619,20 +846,18 @@ work_resched:
20929 movl TI_flags(%ebp), %ecx
20930 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20931 # than syscall tracing?
20932 - jz restore_all
20933 + jz restore_all_pax
20934 testb $_TIF_NEED_RESCHED, %cl
20935 jnz work_resched
20936
20937 work_notifysig: # deal with pending signals and
20938 # notify-resume requests
20939 + movl %esp, %eax
20940 #ifdef CONFIG_VM86
20941 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20942 - movl %esp, %eax
20943 jne work_notifysig_v86 # returning to kernel-space or
20944 # vm86-space
20945 1:
20946 -#else
20947 - movl %esp, %eax
20948 #endif
20949 TRACE_IRQS_ON
20950 ENABLE_INTERRUPTS(CLBR_NONE)
20951 @@ -653,7 +878,7 @@ work_notifysig_v86:
20952 movl %eax, %esp
20953 jmp 1b
20954 #endif
20955 -END(work_pending)
20956 +ENDPROC(work_pending)
20957
20958 # perform syscall exit tracing
20959 ALIGN
20960 @@ -661,11 +886,14 @@ syscall_trace_entry:
20961 movl $-ENOSYS,PT_EAX(%esp)
20962 movl %esp, %eax
20963 call syscall_trace_enter
20964 +
20965 + pax_erase_kstack
20966 +
20967 /* What it returned is what we'll actually use. */
20968 cmpl $(NR_syscalls), %eax
20969 jnae syscall_call
20970 jmp syscall_exit
20971 -END(syscall_trace_entry)
20972 +ENDPROC(syscall_trace_entry)
20973
20974 # perform syscall exit tracing
20975 ALIGN
20976 @@ -678,21 +906,25 @@ syscall_exit_work:
20977 movl %esp, %eax
20978 call syscall_trace_leave
20979 jmp resume_userspace
20980 -END(syscall_exit_work)
20981 +ENDPROC(syscall_exit_work)
20982 CFI_ENDPROC
20983
20984 RING0_INT_FRAME # can't unwind into user space anyway
20985 syscall_fault:
20986 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20987 + push %ss
20988 + pop %ds
20989 +#endif
20990 ASM_CLAC
20991 GET_THREAD_INFO(%ebp)
20992 movl $-EFAULT,PT_EAX(%esp)
20993 jmp resume_userspace
20994 -END(syscall_fault)
20995 +ENDPROC(syscall_fault)
20996
20997 syscall_badsys:
20998 movl $-ENOSYS,PT_EAX(%esp)
20999 jmp resume_userspace
21000 -END(syscall_badsys)
21001 +ENDPROC(syscall_badsys)
21002 CFI_ENDPROC
21003 /*
21004 * End of kprobes section
21005 @@ -708,8 +940,15 @@ END(syscall_badsys)
21006 * normal stack and adjusts ESP with the matching offset.
21007 */
21008 /* fixup the stack */
21009 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21010 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21011 +#ifdef CONFIG_SMP
21012 + movl PER_CPU_VAR(cpu_number), %ebx
21013 + shll $PAGE_SHIFT_asm, %ebx
21014 + addl $cpu_gdt_table, %ebx
21015 +#else
21016 + movl $cpu_gdt_table, %ebx
21017 +#endif
21018 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21019 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21020 shl $16, %eax
21021 addl %esp, %eax /* the adjusted stack pointer */
21022 pushl_cfi $__KERNEL_DS
21023 @@ -762,7 +1001,7 @@ vector=vector+1
21024 .endr
21025 2: jmp common_interrupt
21026 .endr
21027 -END(irq_entries_start)
21028 +ENDPROC(irq_entries_start)
21029
21030 .previous
21031 END(interrupt)
21032 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21033 pushl_cfi $do_coprocessor_error
21034 jmp error_code
21035 CFI_ENDPROC
21036 -END(coprocessor_error)
21037 +ENDPROC(coprocessor_error)
21038
21039 ENTRY(simd_coprocessor_error)
21040 RING0_INT_FRAME
21041 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21042 .section .altinstructions,"a"
21043 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21044 .previous
21045 -.section .altinstr_replacement,"ax"
21046 +.section .altinstr_replacement,"a"
21047 663: pushl $do_simd_coprocessor_error
21048 664:
21049 .previous
21050 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21051 #endif
21052 jmp error_code
21053 CFI_ENDPROC
21054 -END(simd_coprocessor_error)
21055 +ENDPROC(simd_coprocessor_error)
21056
21057 ENTRY(device_not_available)
21058 RING0_INT_FRAME
21059 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21060 pushl_cfi $do_device_not_available
21061 jmp error_code
21062 CFI_ENDPROC
21063 -END(device_not_available)
21064 +ENDPROC(device_not_available)
21065
21066 #ifdef CONFIG_PARAVIRT
21067 ENTRY(native_iret)
21068 iret
21069 _ASM_EXTABLE(native_iret, iret_exc)
21070 -END(native_iret)
21071 +ENDPROC(native_iret)
21072
21073 ENTRY(native_irq_enable_sysexit)
21074 sti
21075 sysexit
21076 -END(native_irq_enable_sysexit)
21077 +ENDPROC(native_irq_enable_sysexit)
21078 #endif
21079
21080 ENTRY(overflow)
21081 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21082 pushl_cfi $do_overflow
21083 jmp error_code
21084 CFI_ENDPROC
21085 -END(overflow)
21086 +ENDPROC(overflow)
21087
21088 ENTRY(bounds)
21089 RING0_INT_FRAME
21090 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21091 pushl_cfi $do_bounds
21092 jmp error_code
21093 CFI_ENDPROC
21094 -END(bounds)
21095 +ENDPROC(bounds)
21096
21097 ENTRY(invalid_op)
21098 RING0_INT_FRAME
21099 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21100 pushl_cfi $do_invalid_op
21101 jmp error_code
21102 CFI_ENDPROC
21103 -END(invalid_op)
21104 +ENDPROC(invalid_op)
21105
21106 ENTRY(coprocessor_segment_overrun)
21107 RING0_INT_FRAME
21108 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21109 pushl_cfi $do_coprocessor_segment_overrun
21110 jmp error_code
21111 CFI_ENDPROC
21112 -END(coprocessor_segment_overrun)
21113 +ENDPROC(coprocessor_segment_overrun)
21114
21115 ENTRY(invalid_TSS)
21116 RING0_EC_FRAME
21117 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21118 pushl_cfi $do_invalid_TSS
21119 jmp error_code
21120 CFI_ENDPROC
21121 -END(invalid_TSS)
21122 +ENDPROC(invalid_TSS)
21123
21124 ENTRY(segment_not_present)
21125 RING0_EC_FRAME
21126 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21127 pushl_cfi $do_segment_not_present
21128 jmp error_code
21129 CFI_ENDPROC
21130 -END(segment_not_present)
21131 +ENDPROC(segment_not_present)
21132
21133 ENTRY(stack_segment)
21134 RING0_EC_FRAME
21135 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21136 pushl_cfi $do_stack_segment
21137 jmp error_code
21138 CFI_ENDPROC
21139 -END(stack_segment)
21140 +ENDPROC(stack_segment)
21141
21142 ENTRY(alignment_check)
21143 RING0_EC_FRAME
21144 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21145 pushl_cfi $do_alignment_check
21146 jmp error_code
21147 CFI_ENDPROC
21148 -END(alignment_check)
21149 +ENDPROC(alignment_check)
21150
21151 ENTRY(divide_error)
21152 RING0_INT_FRAME
21153 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21154 pushl_cfi $do_divide_error
21155 jmp error_code
21156 CFI_ENDPROC
21157 -END(divide_error)
21158 +ENDPROC(divide_error)
21159
21160 #ifdef CONFIG_X86_MCE
21161 ENTRY(machine_check)
21162 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21163 pushl_cfi machine_check_vector
21164 jmp error_code
21165 CFI_ENDPROC
21166 -END(machine_check)
21167 +ENDPROC(machine_check)
21168 #endif
21169
21170 ENTRY(spurious_interrupt_bug)
21171 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21172 pushl_cfi $do_spurious_interrupt_bug
21173 jmp error_code
21174 CFI_ENDPROC
21175 -END(spurious_interrupt_bug)
21176 +ENDPROC(spurious_interrupt_bug)
21177 /*
21178 * End of kprobes section
21179 */
21180 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21181
21182 ENTRY(mcount)
21183 ret
21184 -END(mcount)
21185 +ENDPROC(mcount)
21186
21187 ENTRY(ftrace_caller)
21188 cmpl $0, function_trace_stop
21189 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21190 .globl ftrace_stub
21191 ftrace_stub:
21192 ret
21193 -END(ftrace_caller)
21194 +ENDPROC(ftrace_caller)
21195
21196 ENTRY(ftrace_regs_caller)
21197 pushf /* push flags before compare (in cs location) */
21198 @@ -1207,7 +1446,7 @@ trace:
21199 popl %ecx
21200 popl %eax
21201 jmp ftrace_stub
21202 -END(mcount)
21203 +ENDPROC(mcount)
21204 #endif /* CONFIG_DYNAMIC_FTRACE */
21205 #endif /* CONFIG_FUNCTION_TRACER */
21206
21207 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21208 popl %ecx
21209 popl %eax
21210 ret
21211 -END(ftrace_graph_caller)
21212 +ENDPROC(ftrace_graph_caller)
21213
21214 .globl return_to_handler
21215 return_to_handler:
21216 @@ -1281,15 +1520,18 @@ error_code:
21217 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21218 REG_TO_PTGS %ecx
21219 SET_KERNEL_GS %ecx
21220 - movl $(__USER_DS), %ecx
21221 + movl $(__KERNEL_DS), %ecx
21222 movl %ecx, %ds
21223 movl %ecx, %es
21224 +
21225 + pax_enter_kernel
21226 +
21227 TRACE_IRQS_OFF
21228 movl %esp,%eax # pt_regs pointer
21229 call *%edi
21230 jmp ret_from_exception
21231 CFI_ENDPROC
21232 -END(page_fault)
21233 +ENDPROC(page_fault)
21234
21235 /*
21236 * Debug traps and NMI can happen at the one SYSENTER instruction
21237 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21238 call do_debug
21239 jmp ret_from_exception
21240 CFI_ENDPROC
21241 -END(debug)
21242 +ENDPROC(debug)
21243
21244 /*
21245 * NMI is doubly nasty. It can happen _while_ we're handling
21246 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21247 xorl %edx,%edx # zero error code
21248 movl %esp,%eax # pt_regs pointer
21249 call do_nmi
21250 +
21251 + pax_exit_kernel
21252 +
21253 jmp restore_all_notrace
21254 CFI_ENDPROC
21255
21256 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21257 FIXUP_ESPFIX_STACK # %eax == %esp
21258 xorl %edx,%edx # zero error code
21259 call do_nmi
21260 +
21261 + pax_exit_kernel
21262 +
21263 RESTORE_REGS
21264 lss 12+4(%esp), %esp # back to espfix stack
21265 CFI_ADJUST_CFA_OFFSET -24
21266 jmp irq_return
21267 CFI_ENDPROC
21268 -END(nmi)
21269 +ENDPROC(nmi)
21270
21271 ENTRY(int3)
21272 RING0_INT_FRAME
21273 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21274 call do_int3
21275 jmp ret_from_exception
21276 CFI_ENDPROC
21277 -END(int3)
21278 +ENDPROC(int3)
21279
21280 ENTRY(general_protection)
21281 RING0_EC_FRAME
21282 pushl_cfi $do_general_protection
21283 jmp error_code
21284 CFI_ENDPROC
21285 -END(general_protection)
21286 +ENDPROC(general_protection)
21287
21288 #ifdef CONFIG_KVM_GUEST
21289 ENTRY(async_page_fault)
21290 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21291 pushl_cfi $do_async_page_fault
21292 jmp error_code
21293 CFI_ENDPROC
21294 -END(async_page_fault)
21295 +ENDPROC(async_page_fault)
21296 #endif
21297
21298 /*
21299 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21300 index 1b69951..8430a6d 100644
21301 --- a/arch/x86/kernel/entry_64.S
21302 +++ b/arch/x86/kernel/entry_64.S
21303 @@ -59,6 +59,8 @@
21304 #include <asm/context_tracking.h>
21305 #include <asm/smap.h>
21306 #include <linux/err.h>
21307 +#include <asm/pgtable.h>
21308 +#include <asm/alternative-asm.h>
21309
21310 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21311 #include <linux/elf-em.h>
21312 @@ -80,8 +82,9 @@
21313 #ifdef CONFIG_DYNAMIC_FTRACE
21314
21315 ENTRY(function_hook)
21316 + pax_force_retaddr
21317 retq
21318 -END(function_hook)
21319 +ENDPROC(function_hook)
21320
21321 /* skip is set if stack has been adjusted */
21322 .macro ftrace_caller_setup skip=0
21323 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21324 #endif
21325
21326 GLOBAL(ftrace_stub)
21327 + pax_force_retaddr
21328 retq
21329 -END(ftrace_caller)
21330 +ENDPROC(ftrace_caller)
21331
21332 ENTRY(ftrace_regs_caller)
21333 /* Save the current flags before compare (in SS location)*/
21334 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21335 popfq
21336 jmp ftrace_stub
21337
21338 -END(ftrace_regs_caller)
21339 +ENDPROC(ftrace_regs_caller)
21340
21341
21342 #else /* ! CONFIG_DYNAMIC_FTRACE */
21343 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21344 #endif
21345
21346 GLOBAL(ftrace_stub)
21347 + pax_force_retaddr
21348 retq
21349
21350 trace:
21351 @@ -225,12 +230,13 @@ trace:
21352 #endif
21353 subq $MCOUNT_INSN_SIZE, %rdi
21354
21355 + pax_force_fptr ftrace_trace_function
21356 call *ftrace_trace_function
21357
21358 MCOUNT_RESTORE_FRAME
21359
21360 jmp ftrace_stub
21361 -END(function_hook)
21362 +ENDPROC(function_hook)
21363 #endif /* CONFIG_DYNAMIC_FTRACE */
21364 #endif /* CONFIG_FUNCTION_TRACER */
21365
21366 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21367
21368 MCOUNT_RESTORE_FRAME
21369
21370 + pax_force_retaddr
21371 retq
21372 -END(ftrace_graph_caller)
21373 +ENDPROC(ftrace_graph_caller)
21374
21375 GLOBAL(return_to_handler)
21376 subq $24, %rsp
21377 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21378 movq 8(%rsp), %rdx
21379 movq (%rsp), %rax
21380 addq $24, %rsp
21381 + pax_force_fptr %rdi
21382 jmp *%rdi
21383 +ENDPROC(return_to_handler)
21384 #endif
21385
21386
21387 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21388 ENDPROC(native_usergs_sysret64)
21389 #endif /* CONFIG_PARAVIRT */
21390
21391 + .macro ljmpq sel, off
21392 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21393 + .byte 0x48; ljmp *1234f(%rip)
21394 + .pushsection .rodata
21395 + .align 16
21396 + 1234: .quad \off; .word \sel
21397 + .popsection
21398 +#else
21399 + pushq $\sel
21400 + pushq $\off
21401 + lretq
21402 +#endif
21403 + .endm
21404 +
21405 + .macro pax_enter_kernel
21406 + pax_set_fptr_mask
21407 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21408 + call pax_enter_kernel
21409 +#endif
21410 + .endm
21411 +
21412 + .macro pax_exit_kernel
21413 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21414 + call pax_exit_kernel
21415 +#endif
21416 +
21417 + .endm
21418 +
21419 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21420 +ENTRY(pax_enter_kernel)
21421 + pushq %rdi
21422 +
21423 +#ifdef CONFIG_PARAVIRT
21424 + PV_SAVE_REGS(CLBR_RDI)
21425 +#endif
21426 +
21427 +#ifdef CONFIG_PAX_KERNEXEC
21428 + GET_CR0_INTO_RDI
21429 + bts $16,%rdi
21430 + jnc 3f
21431 + mov %cs,%edi
21432 + cmp $__KERNEL_CS,%edi
21433 + jnz 2f
21434 +1:
21435 +#endif
21436 +
21437 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21438 + 661: jmp 111f
21439 + .pushsection .altinstr_replacement, "a"
21440 + 662: ASM_NOP2
21441 + .popsection
21442 + .pushsection .altinstructions, "a"
21443 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21444 + .popsection
21445 + GET_CR3_INTO_RDI
21446 + cmp $0,%dil
21447 + jnz 112f
21448 + mov $__KERNEL_DS,%edi
21449 + mov %edi,%ss
21450 + jmp 111f
21451 +112: cmp $1,%dil
21452 + jz 113f
21453 + ud2
21454 +113: sub $4097,%rdi
21455 + bts $63,%rdi
21456 + SET_RDI_INTO_CR3
21457 + mov $__UDEREF_KERNEL_DS,%edi
21458 + mov %edi,%ss
21459 +111:
21460 +#endif
21461 +
21462 +#ifdef CONFIG_PARAVIRT
21463 + PV_RESTORE_REGS(CLBR_RDI)
21464 +#endif
21465 +
21466 + popq %rdi
21467 + pax_force_retaddr
21468 + retq
21469 +
21470 +#ifdef CONFIG_PAX_KERNEXEC
21471 +2: ljmpq __KERNEL_CS,1b
21472 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21473 +4: SET_RDI_INTO_CR0
21474 + jmp 1b
21475 +#endif
21476 +ENDPROC(pax_enter_kernel)
21477 +
21478 +ENTRY(pax_exit_kernel)
21479 + pushq %rdi
21480 +
21481 +#ifdef CONFIG_PARAVIRT
21482 + PV_SAVE_REGS(CLBR_RDI)
21483 +#endif
21484 +
21485 +#ifdef CONFIG_PAX_KERNEXEC
21486 + mov %cs,%rdi
21487 + cmp $__KERNEXEC_KERNEL_CS,%edi
21488 + jz 2f
21489 + GET_CR0_INTO_RDI
21490 + bts $16,%rdi
21491 + jnc 4f
21492 +1:
21493 +#endif
21494 +
21495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21496 + 661: jmp 111f
21497 + .pushsection .altinstr_replacement, "a"
21498 + 662: ASM_NOP2
21499 + .popsection
21500 + .pushsection .altinstructions, "a"
21501 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21502 + .popsection
21503 + mov %ss,%edi
21504 + cmp $__UDEREF_KERNEL_DS,%edi
21505 + jnz 111f
21506 + GET_CR3_INTO_RDI
21507 + cmp $0,%dil
21508 + jz 112f
21509 + ud2
21510 +112: add $4097,%rdi
21511 + bts $63,%rdi
21512 + SET_RDI_INTO_CR3
21513 + mov $__KERNEL_DS,%edi
21514 + mov %edi,%ss
21515 +111:
21516 +#endif
21517 +
21518 +#ifdef CONFIG_PARAVIRT
21519 + PV_RESTORE_REGS(CLBR_RDI);
21520 +#endif
21521 +
21522 + popq %rdi
21523 + pax_force_retaddr
21524 + retq
21525 +
21526 +#ifdef CONFIG_PAX_KERNEXEC
21527 +2: GET_CR0_INTO_RDI
21528 + btr $16,%rdi
21529 + jnc 4f
21530 + ljmpq __KERNEL_CS,3f
21531 +3: SET_RDI_INTO_CR0
21532 + jmp 1b
21533 +4: ud2
21534 + jmp 4b
21535 +#endif
21536 +ENDPROC(pax_exit_kernel)
21537 +#endif
21538 +
21539 + .macro pax_enter_kernel_user
21540 + pax_set_fptr_mask
21541 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21542 + call pax_enter_kernel_user
21543 +#endif
21544 + .endm
21545 +
21546 + .macro pax_exit_kernel_user
21547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21548 + call pax_exit_kernel_user
21549 +#endif
21550 +#ifdef CONFIG_PAX_RANDKSTACK
21551 + pushq %rax
21552 + pushq %r11
21553 + call pax_randomize_kstack
21554 + popq %r11
21555 + popq %rax
21556 +#endif
21557 + .endm
21558 +
21559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21560 +ENTRY(pax_enter_kernel_user)
21561 + pushq %rdi
21562 + pushq %rbx
21563 +
21564 +#ifdef CONFIG_PARAVIRT
21565 + PV_SAVE_REGS(CLBR_RDI)
21566 +#endif
21567 +
21568 + 661: jmp 111f
21569 + .pushsection .altinstr_replacement, "a"
21570 + 662: ASM_NOP2
21571 + .popsection
21572 + .pushsection .altinstructions, "a"
21573 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21574 + .popsection
21575 + GET_CR3_INTO_RDI
21576 + cmp $1,%dil
21577 + jnz 4f
21578 + sub $4097,%rdi
21579 + bts $63,%rdi
21580 + SET_RDI_INTO_CR3
21581 + jmp 3f
21582 +111:
21583 +
21584 + GET_CR3_INTO_RDI
21585 + mov %rdi,%rbx
21586 + add $__START_KERNEL_map,%rbx
21587 + sub phys_base(%rip),%rbx
21588 +
21589 +#ifdef CONFIG_PARAVIRT
21590 + cmpl $0, pv_info+PARAVIRT_enabled
21591 + jz 1f
21592 + pushq %rdi
21593 + i = 0
21594 + .rept USER_PGD_PTRS
21595 + mov i*8(%rbx),%rsi
21596 + mov $0,%sil
21597 + lea i*8(%rbx),%rdi
21598 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21599 + i = i + 1
21600 + .endr
21601 + popq %rdi
21602 + jmp 2f
21603 +1:
21604 +#endif
21605 +
21606 + i = 0
21607 + .rept USER_PGD_PTRS
21608 + movb $0,i*8(%rbx)
21609 + i = i + 1
21610 + .endr
21611 +
21612 +2: SET_RDI_INTO_CR3
21613 +
21614 +#ifdef CONFIG_PAX_KERNEXEC
21615 + GET_CR0_INTO_RDI
21616 + bts $16,%rdi
21617 + SET_RDI_INTO_CR0
21618 +#endif
21619 +
21620 +3:
21621 +
21622 +#ifdef CONFIG_PARAVIRT
21623 + PV_RESTORE_REGS(CLBR_RDI)
21624 +#endif
21625 +
21626 + popq %rbx
21627 + popq %rdi
21628 + pax_force_retaddr
21629 + retq
21630 +4: ud2
21631 +ENDPROC(pax_enter_kernel_user)
21632 +
21633 +ENTRY(pax_exit_kernel_user)
21634 + pushq %rdi
21635 + pushq %rbx
21636 +
21637 +#ifdef CONFIG_PARAVIRT
21638 + PV_SAVE_REGS(CLBR_RDI)
21639 +#endif
21640 +
21641 + GET_CR3_INTO_RDI
21642 + 661: jmp 1f
21643 + .pushsection .altinstr_replacement, "a"
21644 + 662: ASM_NOP2
21645 + .popsection
21646 + .pushsection .altinstructions, "a"
21647 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21648 + .popsection
21649 + cmp $0,%dil
21650 + jnz 3f
21651 + add $4097,%rdi
21652 + bts $63,%rdi
21653 + SET_RDI_INTO_CR3
21654 + jmp 2f
21655 +1:
21656 +
21657 + mov %rdi,%rbx
21658 +
21659 +#ifdef CONFIG_PAX_KERNEXEC
21660 + GET_CR0_INTO_RDI
21661 + btr $16,%rdi
21662 + jnc 3f
21663 + SET_RDI_INTO_CR0
21664 +#endif
21665 +
21666 + add $__START_KERNEL_map,%rbx
21667 + sub phys_base(%rip),%rbx
21668 +
21669 +#ifdef CONFIG_PARAVIRT
21670 + cmpl $0, pv_info+PARAVIRT_enabled
21671 + jz 1f
21672 + i = 0
21673 + .rept USER_PGD_PTRS
21674 + mov i*8(%rbx),%rsi
21675 + mov $0x67,%sil
21676 + lea i*8(%rbx),%rdi
21677 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21678 + i = i + 1
21679 + .endr
21680 + jmp 2f
21681 +1:
21682 +#endif
21683 +
21684 + i = 0
21685 + .rept USER_PGD_PTRS
21686 + movb $0x67,i*8(%rbx)
21687 + i = i + 1
21688 + .endr
21689 +2:
21690 +
21691 +#ifdef CONFIG_PARAVIRT
21692 + PV_RESTORE_REGS(CLBR_RDI)
21693 +#endif
21694 +
21695 + popq %rbx
21696 + popq %rdi
21697 + pax_force_retaddr
21698 + retq
21699 +3: ud2
21700 +ENDPROC(pax_exit_kernel_user)
21701 +#endif
21702 +
21703 + .macro pax_enter_kernel_nmi
21704 + pax_set_fptr_mask
21705 +
21706 +#ifdef CONFIG_PAX_KERNEXEC
21707 + GET_CR0_INTO_RDI
21708 + bts $16,%rdi
21709 + jc 110f
21710 + SET_RDI_INTO_CR0
21711 + or $2,%ebx
21712 +110:
21713 +#endif
21714 +
21715 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21716 + 661: jmp 111f
21717 + .pushsection .altinstr_replacement, "a"
21718 + 662: ASM_NOP2
21719 + .popsection
21720 + .pushsection .altinstructions, "a"
21721 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21722 + .popsection
21723 + GET_CR3_INTO_RDI
21724 + cmp $0,%dil
21725 + jz 111f
21726 + sub $4097,%rdi
21727 + or $4,%ebx
21728 + bts $63,%rdi
21729 + SET_RDI_INTO_CR3
21730 + mov $__UDEREF_KERNEL_DS,%edi
21731 + mov %edi,%ss
21732 +111:
21733 +#endif
21734 + .endm
21735 +
21736 + .macro pax_exit_kernel_nmi
21737 +#ifdef CONFIG_PAX_KERNEXEC
21738 + btr $1,%ebx
21739 + jnc 110f
21740 + GET_CR0_INTO_RDI
21741 + btr $16,%rdi
21742 + SET_RDI_INTO_CR0
21743 +110:
21744 +#endif
21745 +
21746 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21747 + btr $2,%ebx
21748 + jnc 111f
21749 + GET_CR3_INTO_RDI
21750 + add $4097,%rdi
21751 + bts $63,%rdi
21752 + SET_RDI_INTO_CR3
21753 + mov $__KERNEL_DS,%edi
21754 + mov %edi,%ss
21755 +111:
21756 +#endif
21757 + .endm
21758 +
21759 + .macro pax_erase_kstack
21760 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21761 + call pax_erase_kstack
21762 +#endif
21763 + .endm
21764 +
21765 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21766 +ENTRY(pax_erase_kstack)
21767 + pushq %rdi
21768 + pushq %rcx
21769 + pushq %rax
21770 + pushq %r11
21771 +
21772 + GET_THREAD_INFO(%r11)
21773 + mov TI_lowest_stack(%r11), %rdi
21774 + mov $-0xBEEF, %rax
21775 + std
21776 +
21777 +1: mov %edi, %ecx
21778 + and $THREAD_SIZE_asm - 1, %ecx
21779 + shr $3, %ecx
21780 + repne scasq
21781 + jecxz 2f
21782 +
21783 + cmp $2*8, %ecx
21784 + jc 2f
21785 +
21786 + mov $2*8, %ecx
21787 + repe scasq
21788 + jecxz 2f
21789 + jne 1b
21790 +
21791 +2: cld
21792 + mov %esp, %ecx
21793 + sub %edi, %ecx
21794 +
21795 + cmp $THREAD_SIZE_asm, %rcx
21796 + jb 3f
21797 + ud2
21798 +3:
21799 +
21800 + shr $3, %ecx
21801 + rep stosq
21802 +
21803 + mov TI_task_thread_sp0(%r11), %rdi
21804 + sub $256, %rdi
21805 + mov %rdi, TI_lowest_stack(%r11)
21806 +
21807 + popq %r11
21808 + popq %rax
21809 + popq %rcx
21810 + popq %rdi
21811 + pax_force_retaddr
21812 + ret
21813 +ENDPROC(pax_erase_kstack)
21814 +#endif
21815
21816 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21817 #ifdef CONFIG_TRACE_IRQFLAGS
21818 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21819 .endm
21820
21821 .macro UNFAKE_STACK_FRAME
21822 - addq $8*6, %rsp
21823 - CFI_ADJUST_CFA_OFFSET -(6*8)
21824 + addq $8*6 + ARG_SKIP, %rsp
21825 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21826 .endm
21827
21828 /*
21829 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21830 movq %rsp, %rsi
21831
21832 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21833 - testl $3, CS-RBP(%rsi)
21834 + testb $3, CS-RBP(%rsi)
21835 je 1f
21836 SWAPGS
21837 /*
21838 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21839 movq_cfi r15, R15+16
21840 movq %r11, 8(%rsp) /* return address */
21841 FIXUP_TOP_OF_STACK %r11, 16
21842 + pax_force_retaddr
21843 ret
21844 CFI_ENDPROC
21845 -END(save_rest)
21846 +ENDPROC(save_rest)
21847
21848 /* save complete stack frame */
21849 .pushsection .kprobes.text, "ax"
21850 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21851 js 1f /* negative -> in kernel */
21852 SWAPGS
21853 xorl %ebx,%ebx
21854 -1: ret
21855 +1: pax_force_retaddr_bts
21856 + ret
21857 CFI_ENDPROC
21858 -END(save_paranoid)
21859 +ENDPROC(save_paranoid)
21860 .popsection
21861
21862 /*
21863 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21864
21865 RESTORE_REST
21866
21867 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21868 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21869 jz 1f
21870
21871 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21872 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21873 RESTORE_REST
21874 jmp int_ret_from_sys_call
21875 CFI_ENDPROC
21876 -END(ret_from_fork)
21877 +ENDPROC(ret_from_fork)
21878
21879 /*
21880 * System call entry. Up to 6 arguments in registers are supported.
21881 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21882 ENTRY(system_call)
21883 CFI_STARTPROC simple
21884 CFI_SIGNAL_FRAME
21885 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21886 + CFI_DEF_CFA rsp,0
21887 CFI_REGISTER rip,rcx
21888 /*CFI_REGISTER rflags,r11*/
21889 SWAPGS_UNSAFE_STACK
21890 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21891
21892 movq %rsp,PER_CPU_VAR(old_rsp)
21893 movq PER_CPU_VAR(kernel_stack),%rsp
21894 + SAVE_ARGS 8*6,0
21895 + pax_enter_kernel_user
21896 +
21897 +#ifdef CONFIG_PAX_RANDKSTACK
21898 + pax_erase_kstack
21899 +#endif
21900 +
21901 /*
21902 * No need to follow this irqs off/on section - it's straight
21903 * and short:
21904 */
21905 ENABLE_INTERRUPTS(CLBR_NONE)
21906 - SAVE_ARGS 8,0
21907 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21908 movq %rcx,RIP-ARGOFFSET(%rsp)
21909 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21910 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21911 + GET_THREAD_INFO(%rcx)
21912 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21913 jnz tracesys
21914 system_call_fastpath:
21915 #if __SYSCALL_MASK == ~0
21916 @@ -640,7 +1082,7 @@ system_call_fastpath:
21917 cmpl $__NR_syscall_max,%eax
21918 #endif
21919 ja badsys
21920 - movq %r10,%rcx
21921 + movq R10-ARGOFFSET(%rsp),%rcx
21922 call *sys_call_table(,%rax,8) # XXX: rip relative
21923 movq %rax,RAX-ARGOFFSET(%rsp)
21924 /*
21925 @@ -654,10 +1096,13 @@ sysret_check:
21926 LOCKDEP_SYS_EXIT
21927 DISABLE_INTERRUPTS(CLBR_NONE)
21928 TRACE_IRQS_OFF
21929 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21930 + GET_THREAD_INFO(%rcx)
21931 + movl TI_flags(%rcx),%edx
21932 andl %edi,%edx
21933 jnz sysret_careful
21934 CFI_REMEMBER_STATE
21935 + pax_exit_kernel_user
21936 + pax_erase_kstack
21937 /*
21938 * sysretq will re-enable interrupts:
21939 */
21940 @@ -709,14 +1154,18 @@ badsys:
21941 * jump back to the normal fast path.
21942 */
21943 auditsys:
21944 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21945 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21946 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21947 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21948 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21949 movq %rax,%rsi /* 2nd arg: syscall number */
21950 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21951 call __audit_syscall_entry
21952 +
21953 + pax_erase_kstack
21954 +
21955 LOAD_ARGS 0 /* reload call-clobbered registers */
21956 + pax_set_fptr_mask
21957 jmp system_call_fastpath
21958
21959 /*
21960 @@ -737,7 +1186,7 @@ sysret_audit:
21961 /* Do syscall tracing */
21962 tracesys:
21963 #ifdef CONFIG_AUDITSYSCALL
21964 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21965 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21966 jz auditsys
21967 #endif
21968 SAVE_REST
21969 @@ -745,12 +1194,16 @@ tracesys:
21970 FIXUP_TOP_OF_STACK %rdi
21971 movq %rsp,%rdi
21972 call syscall_trace_enter
21973 +
21974 + pax_erase_kstack
21975 +
21976 /*
21977 * Reload arg registers from stack in case ptrace changed them.
21978 * We don't reload %rax because syscall_trace_enter() returned
21979 * the value it wants us to use in the table lookup.
21980 */
21981 LOAD_ARGS ARGOFFSET, 1
21982 + pax_set_fptr_mask
21983 RESTORE_REST
21984 #if __SYSCALL_MASK == ~0
21985 cmpq $__NR_syscall_max,%rax
21986 @@ -759,7 +1212,7 @@ tracesys:
21987 cmpl $__NR_syscall_max,%eax
21988 #endif
21989 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21990 - movq %r10,%rcx /* fixup for C */
21991 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21992 call *sys_call_table(,%rax,8)
21993 movq %rax,RAX-ARGOFFSET(%rsp)
21994 /* Use IRET because user could have changed frame */
21995 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21996 andl %edi,%edx
21997 jnz int_careful
21998 andl $~TS_COMPAT,TI_status(%rcx)
21999 - jmp retint_swapgs
22000 + pax_exit_kernel_user
22001 + pax_erase_kstack
22002 + jmp retint_swapgs_pax
22003
22004 /* Either reschedule or signal or syscall exit tracking needed. */
22005 /* First do a reschedule test. */
22006 @@ -826,7 +1281,7 @@ int_restore_rest:
22007 TRACE_IRQS_OFF
22008 jmp int_with_check
22009 CFI_ENDPROC
22010 -END(system_call)
22011 +ENDPROC(system_call)
22012
22013 .macro FORK_LIKE func
22014 ENTRY(stub_\func)
22015 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22016 DEFAULT_FRAME 0 8 /* offset 8: return address */
22017 call sys_\func
22018 RESTORE_TOP_OF_STACK %r11, 8
22019 + pax_force_retaddr
22020 ret $REST_SKIP /* pop extended registers */
22021 CFI_ENDPROC
22022 -END(stub_\func)
22023 +ENDPROC(stub_\func)
22024 .endm
22025
22026 .macro FIXED_FRAME label,func
22027 @@ -851,9 +1307,10 @@ ENTRY(\label)
22028 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22029 call \func
22030 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22031 + pax_force_retaddr
22032 ret
22033 CFI_ENDPROC
22034 -END(\label)
22035 +ENDPROC(\label)
22036 .endm
22037
22038 FORK_LIKE clone
22039 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22040 movq_cfi_restore R12+8, r12
22041 movq_cfi_restore RBP+8, rbp
22042 movq_cfi_restore RBX+8, rbx
22043 + pax_force_retaddr
22044 ret $REST_SKIP /* pop extended registers */
22045 CFI_ENDPROC
22046 -END(ptregscall_common)
22047 +ENDPROC(ptregscall_common)
22048
22049 ENTRY(stub_execve)
22050 CFI_STARTPROC
22051 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22052 RESTORE_REST
22053 jmp int_ret_from_sys_call
22054 CFI_ENDPROC
22055 -END(stub_execve)
22056 +ENDPROC(stub_execve)
22057
22058 /*
22059 * sigreturn is special because it needs to restore all registers on return.
22060 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22061 RESTORE_REST
22062 jmp int_ret_from_sys_call
22063 CFI_ENDPROC
22064 -END(stub_rt_sigreturn)
22065 +ENDPROC(stub_rt_sigreturn)
22066
22067 #ifdef CONFIG_X86_X32_ABI
22068 ENTRY(stub_x32_rt_sigreturn)
22069 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22070 RESTORE_REST
22071 jmp int_ret_from_sys_call
22072 CFI_ENDPROC
22073 -END(stub_x32_rt_sigreturn)
22074 +ENDPROC(stub_x32_rt_sigreturn)
22075
22076 ENTRY(stub_x32_execve)
22077 CFI_STARTPROC
22078 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22079 RESTORE_REST
22080 jmp int_ret_from_sys_call
22081 CFI_ENDPROC
22082 -END(stub_x32_execve)
22083 +ENDPROC(stub_x32_execve)
22084
22085 #endif
22086
22087 @@ -967,7 +1425,7 @@ vector=vector+1
22088 2: jmp common_interrupt
22089 .endr
22090 CFI_ENDPROC
22091 -END(irq_entries_start)
22092 +ENDPROC(irq_entries_start)
22093
22094 .previous
22095 END(interrupt)
22096 @@ -987,6 +1445,16 @@ END(interrupt)
22097 subq $ORIG_RAX-RBP, %rsp
22098 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22099 SAVE_ARGS_IRQ
22100 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22101 + testb $3, CS(%rdi)
22102 + jnz 1f
22103 + pax_enter_kernel
22104 + jmp 2f
22105 +1: pax_enter_kernel_user
22106 +2:
22107 +#else
22108 + pax_enter_kernel
22109 +#endif
22110 call \func
22111 .endm
22112
22113 @@ -1019,7 +1487,7 @@ ret_from_intr:
22114
22115 exit_intr:
22116 GET_THREAD_INFO(%rcx)
22117 - testl $3,CS-ARGOFFSET(%rsp)
22118 + testb $3,CS-ARGOFFSET(%rsp)
22119 je retint_kernel
22120
22121 /* Interrupt came from user space */
22122 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22123 * The iretq could re-enable interrupts:
22124 */
22125 DISABLE_INTERRUPTS(CLBR_ANY)
22126 + pax_exit_kernel_user
22127 +retint_swapgs_pax:
22128 TRACE_IRQS_IRETQ
22129 SWAPGS
22130 jmp restore_args
22131
22132 retint_restore_args: /* return to kernel space */
22133 DISABLE_INTERRUPTS(CLBR_ANY)
22134 + pax_exit_kernel
22135 + pax_force_retaddr (RIP-ARGOFFSET)
22136 /*
22137 * The iretq could re-enable interrupts:
22138 */
22139 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22140 #endif
22141
22142 CFI_ENDPROC
22143 -END(common_interrupt)
22144 +ENDPROC(common_interrupt)
22145 /*
22146 * End of kprobes section
22147 */
22148 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22149 interrupt \do_sym
22150 jmp ret_from_intr
22151 CFI_ENDPROC
22152 -END(\sym)
22153 +ENDPROC(\sym)
22154 .endm
22155
22156 #ifdef CONFIG_TRACING
22157 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22158 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22159 call error_entry
22160 DEFAULT_FRAME 0
22161 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22162 + testb $3, CS(%rsp)
22163 + jnz 1f
22164 + pax_enter_kernel
22165 + jmp 2f
22166 +1: pax_enter_kernel_user
22167 +2:
22168 +#else
22169 + pax_enter_kernel
22170 +#endif
22171 movq %rsp,%rdi /* pt_regs pointer */
22172 xorl %esi,%esi /* no error code */
22173 call \do_sym
22174 jmp error_exit /* %ebx: no swapgs flag */
22175 CFI_ENDPROC
22176 -END(\sym)
22177 +ENDPROC(\sym)
22178 .endm
22179
22180 .macro paranoidzeroentry sym do_sym
22181 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22182 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22183 call save_paranoid
22184 TRACE_IRQS_OFF
22185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22186 + testb $3, CS(%rsp)
22187 + jnz 1f
22188 + pax_enter_kernel
22189 + jmp 2f
22190 +1: pax_enter_kernel_user
22191 +2:
22192 +#else
22193 + pax_enter_kernel
22194 +#endif
22195 movq %rsp,%rdi /* pt_regs pointer */
22196 xorl %esi,%esi /* no error code */
22197 call \do_sym
22198 jmp paranoid_exit /* %ebx: no swapgs flag */
22199 CFI_ENDPROC
22200 -END(\sym)
22201 +ENDPROC(\sym)
22202 .endm
22203
22204 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22205 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22206 .macro paranoidzeroentry_ist sym do_sym ist
22207 ENTRY(\sym)
22208 INTR_FRAME
22209 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22210 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22211 call save_paranoid
22212 TRACE_IRQS_OFF_DEBUG
22213 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22214 + testb $3, CS(%rsp)
22215 + jnz 1f
22216 + pax_enter_kernel
22217 + jmp 2f
22218 +1: pax_enter_kernel_user
22219 +2:
22220 +#else
22221 + pax_enter_kernel
22222 +#endif
22223 movq %rsp,%rdi /* pt_regs pointer */
22224 xorl %esi,%esi /* no error code */
22225 +#ifdef CONFIG_SMP
22226 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22227 + lea init_tss(%r12), %r12
22228 +#else
22229 + lea init_tss(%rip), %r12
22230 +#endif
22231 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22232 call \do_sym
22233 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22234 jmp paranoid_exit /* %ebx: no swapgs flag */
22235 CFI_ENDPROC
22236 -END(\sym)
22237 +ENDPROC(\sym)
22238 .endm
22239
22240 .macro errorentry sym do_sym
22241 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22242 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22243 call error_entry
22244 DEFAULT_FRAME 0
22245 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22246 + testb $3, CS(%rsp)
22247 + jnz 1f
22248 + pax_enter_kernel
22249 + jmp 2f
22250 +1: pax_enter_kernel_user
22251 +2:
22252 +#else
22253 + pax_enter_kernel
22254 +#endif
22255 movq %rsp,%rdi /* pt_regs pointer */
22256 movq ORIG_RAX(%rsp),%rsi /* get error code */
22257 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22258 call \do_sym
22259 jmp error_exit /* %ebx: no swapgs flag */
22260 CFI_ENDPROC
22261 -END(\sym)
22262 +ENDPROC(\sym)
22263 .endm
22264
22265 /* error code is on the stack already */
22266 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22267 call save_paranoid
22268 DEFAULT_FRAME 0
22269 TRACE_IRQS_OFF
22270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22271 + testb $3, CS(%rsp)
22272 + jnz 1f
22273 + pax_enter_kernel
22274 + jmp 2f
22275 +1: pax_enter_kernel_user
22276 +2:
22277 +#else
22278 + pax_enter_kernel
22279 +#endif
22280 movq %rsp,%rdi /* pt_regs pointer */
22281 movq ORIG_RAX(%rsp),%rsi /* get error code */
22282 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22283 call \do_sym
22284 jmp paranoid_exit /* %ebx: no swapgs flag */
22285 CFI_ENDPROC
22286 -END(\sym)
22287 +ENDPROC(\sym)
22288 .endm
22289
22290 zeroentry divide_error do_divide_error
22291 @@ -1342,9 +1870,10 @@ gs_change:
22292 2: mfence /* workaround */
22293 SWAPGS
22294 popfq_cfi
22295 + pax_force_retaddr
22296 ret
22297 CFI_ENDPROC
22298 -END(native_load_gs_index)
22299 +ENDPROC(native_load_gs_index)
22300
22301 _ASM_EXTABLE(gs_change,bad_gs)
22302 .section .fixup,"ax"
22303 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22304 CFI_DEF_CFA_REGISTER rsp
22305 CFI_ADJUST_CFA_OFFSET -8
22306 decl PER_CPU_VAR(irq_count)
22307 + pax_force_retaddr
22308 ret
22309 CFI_ENDPROC
22310 -END(call_softirq)
22311 +ENDPROC(call_softirq)
22312
22313 #ifdef CONFIG_XEN
22314 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22315 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22316 decl PER_CPU_VAR(irq_count)
22317 jmp error_exit
22318 CFI_ENDPROC
22319 -END(xen_do_hypervisor_callback)
22320 +ENDPROC(xen_do_hypervisor_callback)
22321
22322 /*
22323 * Hypervisor uses this for application faults while it executes.
22324 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22325 SAVE_ALL
22326 jmp error_exit
22327 CFI_ENDPROC
22328 -END(xen_failsafe_callback)
22329 +ENDPROC(xen_failsafe_callback)
22330
22331 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22332 xen_hvm_callback_vector xen_evtchn_do_upcall
22333 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22334 DEFAULT_FRAME
22335 DISABLE_INTERRUPTS(CLBR_NONE)
22336 TRACE_IRQS_OFF_DEBUG
22337 - testl %ebx,%ebx /* swapgs needed? */
22338 + testl $1,%ebx /* swapgs needed? */
22339 jnz paranoid_restore
22340 - testl $3,CS(%rsp)
22341 + testb $3,CS(%rsp)
22342 jnz paranoid_userspace
22343 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22344 + pax_exit_kernel
22345 + TRACE_IRQS_IRETQ 0
22346 + SWAPGS_UNSAFE_STACK
22347 + RESTORE_ALL 8
22348 + pax_force_retaddr_bts
22349 + jmp irq_return
22350 +#endif
22351 paranoid_swapgs:
22352 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22353 + pax_exit_kernel_user
22354 +#else
22355 + pax_exit_kernel
22356 +#endif
22357 TRACE_IRQS_IRETQ 0
22358 SWAPGS_UNSAFE_STACK
22359 RESTORE_ALL 8
22360 jmp irq_return
22361 paranoid_restore:
22362 + pax_exit_kernel
22363 TRACE_IRQS_IRETQ_DEBUG 0
22364 RESTORE_ALL 8
22365 + pax_force_retaddr_bts
22366 jmp irq_return
22367 paranoid_userspace:
22368 GET_THREAD_INFO(%rcx)
22369 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22370 TRACE_IRQS_OFF
22371 jmp paranoid_userspace
22372 CFI_ENDPROC
22373 -END(paranoid_exit)
22374 +ENDPROC(paranoid_exit)
22375
22376 /*
22377 * Exception entry point. This expects an error code/orig_rax on the stack.
22378 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22379 movq_cfi r14, R14+8
22380 movq_cfi r15, R15+8
22381 xorl %ebx,%ebx
22382 - testl $3,CS+8(%rsp)
22383 + testb $3,CS+8(%rsp)
22384 je error_kernelspace
22385 error_swapgs:
22386 SWAPGS
22387 error_sti:
22388 TRACE_IRQS_OFF
22389 + pax_force_retaddr_bts
22390 ret
22391
22392 /*
22393 @@ -1622,7 +2168,7 @@ bstep_iret:
22394 movq %rcx,RIP+8(%rsp)
22395 jmp error_swapgs
22396 CFI_ENDPROC
22397 -END(error_entry)
22398 +ENDPROC(error_entry)
22399
22400
22401 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22402 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22403 DISABLE_INTERRUPTS(CLBR_NONE)
22404 TRACE_IRQS_OFF
22405 GET_THREAD_INFO(%rcx)
22406 - testl %eax,%eax
22407 + testl $1,%eax
22408 jne retint_kernel
22409 LOCKDEP_SYS_EXIT_IRQ
22410 movl TI_flags(%rcx),%edx
22411 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22412 jnz retint_careful
22413 jmp retint_swapgs
22414 CFI_ENDPROC
22415 -END(error_exit)
22416 +ENDPROC(error_exit)
22417
22418 /*
22419 * Test if a given stack is an NMI stack or not.
22420 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22421 * If %cs was not the kernel segment, then the NMI triggered in user
22422 * space, which means it is definitely not nested.
22423 */
22424 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22425 + je 1f
22426 cmpl $__KERNEL_CS, 16(%rsp)
22427 jne first_nmi
22428 -
22429 +1:
22430 /*
22431 * Check the special variable on the stack to see if NMIs are
22432 * executing.
22433 @@ -1736,8 +2284,7 @@ nested_nmi:
22434
22435 1:
22436 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22437 - leaq -1*8(%rsp), %rdx
22438 - movq %rdx, %rsp
22439 + subq $8, %rsp
22440 CFI_ADJUST_CFA_OFFSET 1*8
22441 leaq -10*8(%rsp), %rdx
22442 pushq_cfi $__KERNEL_DS
22443 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22444 CFI_RESTORE rdx
22445
22446 /* No need to check faults here */
22447 +# pax_force_retaddr_bts
22448 INTERRUPT_RETURN
22449
22450 CFI_RESTORE_STATE
22451 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22452 */
22453 movq %cr2, %r12
22454
22455 + pax_enter_kernel_nmi
22456 +
22457 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22458 movq %rsp,%rdi
22459 movq $-1,%rsi
22460 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22461 movq %r12, %cr2
22462 1:
22463
22464 - testl %ebx,%ebx /* swapgs needed? */
22465 + testl $1,%ebx /* swapgs needed? */
22466 jnz nmi_restore
22467 nmi_swapgs:
22468 SWAPGS_UNSAFE_STACK
22469 nmi_restore:
22470 + pax_exit_kernel_nmi
22471 /* Pop the extra iret frame at once */
22472 RESTORE_ALL 6*8
22473 + testb $3, 8(%rsp)
22474 + jnz 1f
22475 + pax_force_retaddr_bts
22476 +1:
22477
22478 /* Clear the NMI executing stack variable */
22479 movq $0, 5*8(%rsp)
22480 jmp irq_return
22481 CFI_ENDPROC
22482 -END(nmi)
22483 +ENDPROC(nmi)
22484
22485 ENTRY(ignore_sysret)
22486 CFI_STARTPROC
22487 mov $-ENOSYS,%eax
22488 sysret
22489 CFI_ENDPROC
22490 -END(ignore_sysret)
22491 +ENDPROC(ignore_sysret)
22492
22493 /*
22494 * End of kprobes section
22495 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22496 index 42a392a..fbbd930 100644
22497 --- a/arch/x86/kernel/ftrace.c
22498 +++ b/arch/x86/kernel/ftrace.c
22499 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22500 {
22501 unsigned char replaced[MCOUNT_INSN_SIZE];
22502
22503 + ip = ktla_ktva(ip);
22504 +
22505 /*
22506 * Note: Due to modules and __init, code can
22507 * disappear and change, we need to protect against faulting
22508 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22509 unsigned char old[MCOUNT_INSN_SIZE], *new;
22510 int ret;
22511
22512 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22513 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22514 new = ftrace_call_replace(ip, (unsigned long)func);
22515
22516 /* See comment above by declaration of modifying_ftrace_code */
22517 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22518 /* Also update the regs callback function */
22519 if (!ret) {
22520 ip = (unsigned long)(&ftrace_regs_call);
22521 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22522 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22523 new = ftrace_call_replace(ip, (unsigned long)func);
22524 ret = ftrace_modify_code(ip, old, new);
22525 }
22526 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22527 * kernel identity mapping to modify code.
22528 */
22529 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22530 - ip = (unsigned long)__va(__pa_symbol(ip));
22531 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22532
22533 return probe_kernel_write((void *)ip, val, size);
22534 }
22535 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22536 unsigned char replaced[MCOUNT_INSN_SIZE];
22537 unsigned char brk = BREAKPOINT_INSTRUCTION;
22538
22539 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22540 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22541 return -EFAULT;
22542
22543 /* Make sure it is what we expect it to be */
22544 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22545 return ret;
22546
22547 fail_update:
22548 - probe_kernel_write((void *)ip, &old_code[0], 1);
22549 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22550 goto out;
22551 }
22552
22553 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22554 {
22555 unsigned char code[MCOUNT_INSN_SIZE];
22556
22557 + ip = ktla_ktva(ip);
22558 +
22559 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22560 return -EFAULT;
22561
22562 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22563 index 55b6761..a6456fc 100644
22564 --- a/arch/x86/kernel/head64.c
22565 +++ b/arch/x86/kernel/head64.c
22566 @@ -67,12 +67,12 @@ again:
22567 pgd = *pgd_p;
22568
22569 /*
22570 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22571 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22572 + * The use of __early_va rather than __va here is critical:
22573 + * __va would point us back into the dynamic
22574 * range and we might end up looping forever...
22575 */
22576 if (pgd)
22577 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22578 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22579 else {
22580 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22581 reset_early_page_tables();
22582 @@ -82,13 +82,13 @@ again:
22583 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22584 for (i = 0; i < PTRS_PER_PUD; i++)
22585 pud_p[i] = 0;
22586 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22587 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22588 }
22589 pud_p += pud_index(address);
22590 pud = *pud_p;
22591
22592 if (pud)
22593 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22594 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22595 else {
22596 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22597 reset_early_page_tables();
22598 @@ -98,7 +98,7 @@ again:
22599 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22600 for (i = 0; i < PTRS_PER_PMD; i++)
22601 pmd_p[i] = 0;
22602 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22603 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22604 }
22605 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22606 pmd_p[pmd_index(address)] = pmd;
22607 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22608 if (console_loglevel == 10)
22609 early_printk("Kernel alive\n");
22610
22611 - clear_page(init_level4_pgt);
22612 /* set init_level4_pgt kernel high mapping*/
22613 init_level4_pgt[511] = early_level4_pgt[511];
22614
22615 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22616 index 5dd87a8..d68b3f4 100644
22617 --- a/arch/x86/kernel/head_32.S
22618 +++ b/arch/x86/kernel/head_32.S
22619 @@ -26,6 +26,12 @@
22620 /* Physical address */
22621 #define pa(X) ((X) - __PAGE_OFFSET)
22622
22623 +#ifdef CONFIG_PAX_KERNEXEC
22624 +#define ta(X) (X)
22625 +#else
22626 +#define ta(X) ((X) - __PAGE_OFFSET)
22627 +#endif
22628 +
22629 /*
22630 * References to members of the new_cpu_data structure.
22631 */
22632 @@ -55,11 +61,7 @@
22633 * and small than max_low_pfn, otherwise will waste some page table entries
22634 */
22635
22636 -#if PTRS_PER_PMD > 1
22637 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22638 -#else
22639 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22640 -#endif
22641 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22642
22643 /* Number of possible pages in the lowmem region */
22644 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22645 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22646 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22647
22648 /*
22649 + * Real beginning of normal "text" segment
22650 + */
22651 +ENTRY(stext)
22652 +ENTRY(_stext)
22653 +
22654 +/*
22655 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22656 * %esi points to the real-mode code as a 32-bit pointer.
22657 * CS and DS must be 4 GB flat segments, but we don't depend on
22658 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22659 * can.
22660 */
22661 __HEAD
22662 +
22663 +#ifdef CONFIG_PAX_KERNEXEC
22664 + jmp startup_32
22665 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22666 +.fill PAGE_SIZE-5,1,0xcc
22667 +#endif
22668 +
22669 ENTRY(startup_32)
22670 movl pa(stack_start),%ecx
22671
22672 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22673 2:
22674 leal -__PAGE_OFFSET(%ecx),%esp
22675
22676 +#ifdef CONFIG_SMP
22677 + movl $pa(cpu_gdt_table),%edi
22678 + movl $__per_cpu_load,%eax
22679 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22680 + rorl $16,%eax
22681 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22682 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22683 + movl $__per_cpu_end - 1,%eax
22684 + subl $__per_cpu_start,%eax
22685 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22686 +#endif
22687 +
22688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22689 + movl $NR_CPUS,%ecx
22690 + movl $pa(cpu_gdt_table),%edi
22691 +1:
22692 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22693 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22694 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22695 + addl $PAGE_SIZE_asm,%edi
22696 + loop 1b
22697 +#endif
22698 +
22699 +#ifdef CONFIG_PAX_KERNEXEC
22700 + movl $pa(boot_gdt),%edi
22701 + movl $__LOAD_PHYSICAL_ADDR,%eax
22702 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22703 + rorl $16,%eax
22704 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22705 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22706 + rorl $16,%eax
22707 +
22708 + ljmp $(__BOOT_CS),$1f
22709 +1:
22710 +
22711 + movl $NR_CPUS,%ecx
22712 + movl $pa(cpu_gdt_table),%edi
22713 + addl $__PAGE_OFFSET,%eax
22714 +1:
22715 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22716 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22717 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22718 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22719 + rorl $16,%eax
22720 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22721 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22722 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22723 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22724 + rorl $16,%eax
22725 + addl $PAGE_SIZE_asm,%edi
22726 + loop 1b
22727 +#endif
22728 +
22729 /*
22730 * Clear BSS first so that there are no surprises...
22731 */
22732 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22733 movl %eax, pa(max_pfn_mapped)
22734
22735 /* Do early initialization of the fixmap area */
22736 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22737 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22738 +#ifdef CONFIG_COMPAT_VDSO
22739 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22740 +#else
22741 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22742 +#endif
22743 #else /* Not PAE */
22744
22745 page_pde_offset = (__PAGE_OFFSET >> 20);
22746 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22747 movl %eax, pa(max_pfn_mapped)
22748
22749 /* Do early initialization of the fixmap area */
22750 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22751 - movl %eax,pa(initial_page_table+0xffc)
22752 +#ifdef CONFIG_COMPAT_VDSO
22753 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22754 +#else
22755 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22756 +#endif
22757 #endif
22758
22759 #ifdef CONFIG_PARAVIRT
22760 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22761 cmpl $num_subarch_entries, %eax
22762 jae bad_subarch
22763
22764 - movl pa(subarch_entries)(,%eax,4), %eax
22765 - subl $__PAGE_OFFSET, %eax
22766 - jmp *%eax
22767 + jmp *pa(subarch_entries)(,%eax,4)
22768
22769 bad_subarch:
22770 WEAK(lguest_entry)
22771 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22772 __INITDATA
22773
22774 subarch_entries:
22775 - .long default_entry /* normal x86/PC */
22776 - .long lguest_entry /* lguest hypervisor */
22777 - .long xen_entry /* Xen hypervisor */
22778 - .long default_entry /* Moorestown MID */
22779 + .long ta(default_entry) /* normal x86/PC */
22780 + .long ta(lguest_entry) /* lguest hypervisor */
22781 + .long ta(xen_entry) /* Xen hypervisor */
22782 + .long ta(default_entry) /* Moorestown MID */
22783 num_subarch_entries = (. - subarch_entries) / 4
22784 .previous
22785 #else
22786 @@ -354,6 +426,7 @@ default_entry:
22787 movl pa(mmu_cr4_features),%eax
22788 movl %eax,%cr4
22789
22790 +#ifdef CONFIG_X86_PAE
22791 testb $X86_CR4_PAE, %al # check if PAE is enabled
22792 jz enable_paging
22793
22794 @@ -382,6 +455,9 @@ default_entry:
22795 /* Make changes effective */
22796 wrmsr
22797
22798 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22799 +#endif
22800 +
22801 enable_paging:
22802
22803 /*
22804 @@ -449,14 +525,20 @@ is486:
22805 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22806 movl %eax,%ss # after changing gdt.
22807
22808 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22809 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22810 movl %eax,%ds
22811 movl %eax,%es
22812
22813 movl $(__KERNEL_PERCPU), %eax
22814 movl %eax,%fs # set this cpu's percpu
22815
22816 +#ifdef CONFIG_CC_STACKPROTECTOR
22817 movl $(__KERNEL_STACK_CANARY),%eax
22818 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22819 + movl $(__USER_DS),%eax
22820 +#else
22821 + xorl %eax,%eax
22822 +#endif
22823 movl %eax,%gs
22824
22825 xorl %eax,%eax # Clear LDT
22826 @@ -512,8 +594,11 @@ setup_once:
22827 * relocation. Manually set base address in stack canary
22828 * segment descriptor.
22829 */
22830 - movl $gdt_page,%eax
22831 + movl $cpu_gdt_table,%eax
22832 movl $stack_canary,%ecx
22833 +#ifdef CONFIG_SMP
22834 + addl $__per_cpu_load,%ecx
22835 +#endif
22836 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22837 shrl $16, %ecx
22838 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22839 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22840 /* This is global to keep gas from relaxing the jumps */
22841 ENTRY(early_idt_handler)
22842 cld
22843 - cmpl $2,%ss:early_recursion_flag
22844 + cmpl $1,%ss:early_recursion_flag
22845 je hlt_loop
22846 incl %ss:early_recursion_flag
22847
22848 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22849 pushl (20+6*4)(%esp) /* trapno */
22850 pushl $fault_msg
22851 call printk
22852 -#endif
22853 call dump_stack
22854 +#endif
22855 hlt_loop:
22856 hlt
22857 jmp hlt_loop
22858 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22859 /* This is the default interrupt "handler" :-) */
22860 ALIGN
22861 ignore_int:
22862 - cld
22863 #ifdef CONFIG_PRINTK
22864 + cmpl $2,%ss:early_recursion_flag
22865 + je hlt_loop
22866 + incl %ss:early_recursion_flag
22867 + cld
22868 pushl %eax
22869 pushl %ecx
22870 pushl %edx
22871 @@ -612,9 +700,6 @@ ignore_int:
22872 movl $(__KERNEL_DS),%eax
22873 movl %eax,%ds
22874 movl %eax,%es
22875 - cmpl $2,early_recursion_flag
22876 - je hlt_loop
22877 - incl early_recursion_flag
22878 pushl 16(%esp)
22879 pushl 24(%esp)
22880 pushl 32(%esp)
22881 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22882 /*
22883 * BSS section
22884 */
22885 -__PAGE_ALIGNED_BSS
22886 - .align PAGE_SIZE
22887 #ifdef CONFIG_X86_PAE
22888 +.section .initial_pg_pmd,"a",@progbits
22889 initial_pg_pmd:
22890 .fill 1024*KPMDS,4,0
22891 #else
22892 +.section .initial_page_table,"a",@progbits
22893 ENTRY(initial_page_table)
22894 .fill 1024,4,0
22895 #endif
22896 +.section .initial_pg_fixmap,"a",@progbits
22897 initial_pg_fixmap:
22898 .fill 1024,4,0
22899 +.section .empty_zero_page,"a",@progbits
22900 ENTRY(empty_zero_page)
22901 .fill 4096,1,0
22902 +.section .swapper_pg_dir,"a",@progbits
22903 ENTRY(swapper_pg_dir)
22904 +#ifdef CONFIG_X86_PAE
22905 + .fill 4,8,0
22906 +#else
22907 .fill 1024,4,0
22908 +#endif
22909
22910 /*
22911 * This starts the data section.
22912 */
22913 #ifdef CONFIG_X86_PAE
22914 -__PAGE_ALIGNED_DATA
22915 - /* Page-aligned for the benefit of paravirt? */
22916 - .align PAGE_SIZE
22917 +.section .initial_page_table,"a",@progbits
22918 ENTRY(initial_page_table)
22919 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22920 # if KPMDS == 3
22921 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22922 # error "Kernel PMDs should be 1, 2 or 3"
22923 # endif
22924 .align PAGE_SIZE /* needs to be page-sized too */
22925 +
22926 +#ifdef CONFIG_PAX_PER_CPU_PGD
22927 +ENTRY(cpu_pgd)
22928 + .rept 2*NR_CPUS
22929 + .fill 4,8,0
22930 + .endr
22931 +#endif
22932 +
22933 #endif
22934
22935 .data
22936 .balign 4
22937 ENTRY(stack_start)
22938 - .long init_thread_union+THREAD_SIZE
22939 + .long init_thread_union+THREAD_SIZE-8
22940
22941 __INITRODATA
22942 int_msg:
22943 @@ -722,7 +820,7 @@ fault_msg:
22944 * segment size, and 32-bit linear address value:
22945 */
22946
22947 - .data
22948 +.section .rodata,"a",@progbits
22949 .globl boot_gdt_descr
22950 .globl idt_descr
22951
22952 @@ -731,7 +829,7 @@ fault_msg:
22953 .word 0 # 32 bit align gdt_desc.address
22954 boot_gdt_descr:
22955 .word __BOOT_DS+7
22956 - .long boot_gdt - __PAGE_OFFSET
22957 + .long pa(boot_gdt)
22958
22959 .word 0 # 32-bit align idt_desc.address
22960 idt_descr:
22961 @@ -742,7 +840,7 @@ idt_descr:
22962 .word 0 # 32 bit align gdt_desc.address
22963 ENTRY(early_gdt_descr)
22964 .word GDT_ENTRIES*8-1
22965 - .long gdt_page /* Overwritten for secondary CPUs */
22966 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22967
22968 /*
22969 * The boot_gdt must mirror the equivalent in setup.S and is
22970 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22971 .align L1_CACHE_BYTES
22972 ENTRY(boot_gdt)
22973 .fill GDT_ENTRY_BOOT_CS,8,0
22974 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22975 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22976 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22977 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22978 +
22979 + .align PAGE_SIZE_asm
22980 +ENTRY(cpu_gdt_table)
22981 + .rept NR_CPUS
22982 + .quad 0x0000000000000000 /* NULL descriptor */
22983 + .quad 0x0000000000000000 /* 0x0b reserved */
22984 + .quad 0x0000000000000000 /* 0x13 reserved */
22985 + .quad 0x0000000000000000 /* 0x1b reserved */
22986 +
22987 +#ifdef CONFIG_PAX_KERNEXEC
22988 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22989 +#else
22990 + .quad 0x0000000000000000 /* 0x20 unused */
22991 +#endif
22992 +
22993 + .quad 0x0000000000000000 /* 0x28 unused */
22994 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22995 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22996 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22997 + .quad 0x0000000000000000 /* 0x4b reserved */
22998 + .quad 0x0000000000000000 /* 0x53 reserved */
22999 + .quad 0x0000000000000000 /* 0x5b reserved */
23000 +
23001 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23002 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23003 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23004 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23005 +
23006 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23007 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23008 +
23009 + /*
23010 + * Segments used for calling PnP BIOS have byte granularity.
23011 + * The code segments and data segments have fixed 64k limits,
23012 + * the transfer segment sizes are set at run time.
23013 + */
23014 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23015 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23016 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23017 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23018 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23019 +
23020 + /*
23021 + * The APM segments have byte granularity and their bases
23022 + * are set at run time. All have 64k limits.
23023 + */
23024 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23025 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23026 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23027 +
23028 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23029 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23030 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23031 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23032 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23033 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23034 +
23035 + /* Be sure this is zeroed to avoid false validations in Xen */
23036 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23037 + .endr
23038 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23039 index e1aabdb..73dcad8 100644
23040 --- a/arch/x86/kernel/head_64.S
23041 +++ b/arch/x86/kernel/head_64.S
23042 @@ -20,6 +20,8 @@
23043 #include <asm/processor-flags.h>
23044 #include <asm/percpu.h>
23045 #include <asm/nops.h>
23046 +#include <asm/cpufeature.h>
23047 +#include <asm/alternative-asm.h>
23048
23049 #ifdef CONFIG_PARAVIRT
23050 #include <asm/asm-offsets.h>
23051 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23052 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23053 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23054 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23055 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23056 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23057 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23058 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23059 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23060 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23061
23062 .text
23063 __HEAD
23064 @@ -89,11 +97,23 @@ startup_64:
23065 * Fixup the physical addresses in the page table
23066 */
23067 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23068 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23069 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23070 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23071 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23072 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23073
23074 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23075 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23076 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23077 +#ifndef CONFIG_XEN
23078 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23079 +#endif
23080
23081 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23082 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23083 +
23084 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23085 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23086 +
23087 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23088
23089 /*
23090 * Set up the identity mapping for the switchover. These
23091 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23092 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23093 1:
23094
23095 - /* Enable PAE mode and PGE */
23096 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23097 + /* Enable PAE mode and PSE/PGE */
23098 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23099 movq %rcx, %cr4
23100
23101 /* Setup early boot stage 4 level pagetables. */
23102 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23103 movl $MSR_EFER, %ecx
23104 rdmsr
23105 btsl $_EFER_SCE, %eax /* Enable System Call */
23106 - btl $20,%edi /* No Execute supported? */
23107 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23108 jnc 1f
23109 btsl $_EFER_NX, %eax
23110 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23111 + leaq init_level4_pgt(%rip), %rdi
23112 +#ifndef CONFIG_EFI
23113 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23114 +#endif
23115 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23116 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23117 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23118 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23119 1: wrmsr /* Make changes effective */
23120
23121 /* Setup cr0 */
23122 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23123 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23124 * address given in m16:64.
23125 */
23126 + pax_set_fptr_mask
23127 movq initial_code(%rip),%rax
23128 pushq $0 # fake return address to stop unwinder
23129 pushq $__KERNEL_CS # set correct cs
23130 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23131 call dump_stack
23132 #ifdef CONFIG_KALLSYMS
23133 leaq early_idt_ripmsg(%rip),%rdi
23134 - movq 40(%rsp),%rsi # %rip again
23135 + movq 88(%rsp),%rsi # %rip again
23136 call __print_symbol
23137 #endif
23138 #endif /* EARLY_PRINTK */
23139 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23140 early_recursion_flag:
23141 .long 0
23142
23143 + .section .rodata,"a",@progbits
23144 #ifdef CONFIG_EARLY_PRINTK
23145 early_idt_msg:
23146 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23147 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23148 NEXT_PAGE(early_dynamic_pgts)
23149 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23150
23151 - .data
23152 + .section .rodata,"a",@progbits
23153
23154 -#ifndef CONFIG_XEN
23155 NEXT_PAGE(init_level4_pgt)
23156 - .fill 512,8,0
23157 -#else
23158 -NEXT_PAGE(init_level4_pgt)
23159 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23160 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23161 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23162 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23163 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23164 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23165 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23166 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23167 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23168 .org init_level4_pgt + L4_START_KERNEL*8, 0
23169 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23170 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23171
23172 +#ifdef CONFIG_PAX_PER_CPU_PGD
23173 +NEXT_PAGE(cpu_pgd)
23174 + .rept 2*NR_CPUS
23175 + .fill 512,8,0
23176 + .endr
23177 +#endif
23178 +
23179 NEXT_PAGE(level3_ident_pgt)
23180 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23181 +#ifdef CONFIG_XEN
23182 .fill 511, 8, 0
23183 +#else
23184 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23185 + .fill 510,8,0
23186 +#endif
23187 +
23188 +NEXT_PAGE(level3_vmalloc_start_pgt)
23189 + .fill 512,8,0
23190 +
23191 +NEXT_PAGE(level3_vmalloc_end_pgt)
23192 + .fill 512,8,0
23193 +
23194 +NEXT_PAGE(level3_vmemmap_pgt)
23195 + .fill L3_VMEMMAP_START,8,0
23196 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23197 +
23198 NEXT_PAGE(level2_ident_pgt)
23199 - /* Since I easily can, map the first 1G.
23200 + /* Since I easily can, map the first 2G.
23201 * Don't set NX because code runs from these pages.
23202 */
23203 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23204 -#endif
23205 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23206
23207 NEXT_PAGE(level3_kernel_pgt)
23208 .fill L3_START_KERNEL,8,0
23209 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23210 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23211 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23212
23213 +NEXT_PAGE(level2_vmemmap_pgt)
23214 + .fill 512,8,0
23215 +
23216 NEXT_PAGE(level2_kernel_pgt)
23217 /*
23218 * 512 MB kernel mapping. We spend a full page on this pagetable
23219 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23220 KERNEL_IMAGE_SIZE/PMD_SIZE)
23221
23222 NEXT_PAGE(level2_fixmap_pgt)
23223 - .fill 506,8,0
23224 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23225 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23226 - .fill 5,8,0
23227 + .fill 507,8,0
23228 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23229 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23230 + .fill 4,8,0
23231
23232 -NEXT_PAGE(level1_fixmap_pgt)
23233 +NEXT_PAGE(level1_vsyscall_pgt)
23234 .fill 512,8,0
23235
23236 #undef PMDS
23237
23238 - .data
23239 + .align PAGE_SIZE
23240 +ENTRY(cpu_gdt_table)
23241 + .rept NR_CPUS
23242 + .quad 0x0000000000000000 /* NULL descriptor */
23243 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23244 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23245 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23246 + .quad 0x00cffb000000ffff /* __USER32_CS */
23247 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23248 + .quad 0x00affb000000ffff /* __USER_CS */
23249 +
23250 +#ifdef CONFIG_PAX_KERNEXEC
23251 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23252 +#else
23253 + .quad 0x0 /* unused */
23254 +#endif
23255 +
23256 + .quad 0,0 /* TSS */
23257 + .quad 0,0 /* LDT */
23258 + .quad 0,0,0 /* three TLS descriptors */
23259 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23260 + /* asm/segment.h:GDT_ENTRIES must match this */
23261 +
23262 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23263 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23264 +#else
23265 + .quad 0x0 /* unused */
23266 +#endif
23267 +
23268 + /* zero the remaining page */
23269 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23270 + .endr
23271 +
23272 .align 16
23273 .globl early_gdt_descr
23274 early_gdt_descr:
23275 .word GDT_ENTRIES*8-1
23276 early_gdt_descr_base:
23277 - .quad INIT_PER_CPU_VAR(gdt_page)
23278 + .quad cpu_gdt_table
23279
23280 ENTRY(phys_base)
23281 /* This must match the first entry in level2_kernel_pgt */
23282 .quad 0x0000000000000000
23283
23284 #include "../../x86/xen/xen-head.S"
23285 -
23286 - __PAGE_ALIGNED_BSS
23287 +
23288 + .section .rodata,"a",@progbits
23289 NEXT_PAGE(empty_zero_page)
23290 .skip PAGE_SIZE
23291 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23292 index 0fa6912..b37438b 100644
23293 --- a/arch/x86/kernel/i386_ksyms_32.c
23294 +++ b/arch/x86/kernel/i386_ksyms_32.c
23295 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23296 EXPORT_SYMBOL(cmpxchg8b_emu);
23297 #endif
23298
23299 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23300 +
23301 /* Networking helper routines. */
23302 EXPORT_SYMBOL(csum_partial_copy_generic);
23303 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23304 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23305
23306 EXPORT_SYMBOL(__get_user_1);
23307 EXPORT_SYMBOL(__get_user_2);
23308 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23309
23310 EXPORT_SYMBOL(csum_partial);
23311 EXPORT_SYMBOL(empty_zero_page);
23312 +
23313 +#ifdef CONFIG_PAX_KERNEXEC
23314 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23315 +#endif
23316 +
23317 +#ifdef CONFIG_PAX_PER_CPU_PGD
23318 +EXPORT_SYMBOL(cpu_pgd);
23319 +#endif
23320 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23321 index 5d576ab..1403a03 100644
23322 --- a/arch/x86/kernel/i387.c
23323 +++ b/arch/x86/kernel/i387.c
23324 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23325 static inline bool interrupted_user_mode(void)
23326 {
23327 struct pt_regs *regs = get_irq_regs();
23328 - return regs && user_mode_vm(regs);
23329 + return regs && user_mode(regs);
23330 }
23331
23332 /*
23333 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23334 index 9a5c460..84868423 100644
23335 --- a/arch/x86/kernel/i8259.c
23336 +++ b/arch/x86/kernel/i8259.c
23337 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23338 static void make_8259A_irq(unsigned int irq)
23339 {
23340 disable_irq_nosync(irq);
23341 - io_apic_irqs &= ~(1<<irq);
23342 + io_apic_irqs &= ~(1UL<<irq);
23343 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23344 i8259A_chip.name);
23345 enable_irq(irq);
23346 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23347 "spurious 8259A interrupt: IRQ%d.\n", irq);
23348 spurious_irq_mask |= irqmask;
23349 }
23350 - atomic_inc(&irq_err_count);
23351 + atomic_inc_unchecked(&irq_err_count);
23352 /*
23353 * Theoretically we do not have to handle this IRQ,
23354 * but in Linux this does not cause problems and is
23355 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23356 /* (slave's support for AEOI in flat mode is to be investigated) */
23357 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23358
23359 + pax_open_kernel();
23360 if (auto_eoi)
23361 /*
23362 * In AEOI mode we just have to mask the interrupt
23363 * when acking.
23364 */
23365 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23366 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23367 else
23368 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23369 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23370 + pax_close_kernel();
23371
23372 udelay(100); /* wait for 8259A to initialize */
23373
23374 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23375 index a979b5b..1d6db75 100644
23376 --- a/arch/x86/kernel/io_delay.c
23377 +++ b/arch/x86/kernel/io_delay.c
23378 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23379 * Quirk table for systems that misbehave (lock up, etc.) if port
23380 * 0x80 is used:
23381 */
23382 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23383 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23384 {
23385 .callback = dmi_io_delay_0xed_port,
23386 .ident = "Compaq Presario V6000",
23387 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23388 index 4ddaf66..6292f4e 100644
23389 --- a/arch/x86/kernel/ioport.c
23390 +++ b/arch/x86/kernel/ioport.c
23391 @@ -6,6 +6,7 @@
23392 #include <linux/sched.h>
23393 #include <linux/kernel.h>
23394 #include <linux/capability.h>
23395 +#include <linux/security.h>
23396 #include <linux/errno.h>
23397 #include <linux/types.h>
23398 #include <linux/ioport.h>
23399 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23400
23401 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23402 return -EINVAL;
23403 +#ifdef CONFIG_GRKERNSEC_IO
23404 + if (turn_on && grsec_disable_privio) {
23405 + gr_handle_ioperm();
23406 + return -EPERM;
23407 + }
23408 +#endif
23409 if (turn_on && !capable(CAP_SYS_RAWIO))
23410 return -EPERM;
23411
23412 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23413 * because the ->io_bitmap_max value must match the bitmap
23414 * contents:
23415 */
23416 - tss = &per_cpu(init_tss, get_cpu());
23417 + tss = init_tss + get_cpu();
23418
23419 if (turn_on)
23420 bitmap_clear(t->io_bitmap_ptr, from, num);
23421 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23422 return -EINVAL;
23423 /* Trying to gain more privileges? */
23424 if (level > old) {
23425 +#ifdef CONFIG_GRKERNSEC_IO
23426 + if (grsec_disable_privio) {
23427 + gr_handle_iopl();
23428 + return -EPERM;
23429 + }
23430 +#endif
23431 if (!capable(CAP_SYS_RAWIO))
23432 return -EPERM;
23433 }
23434 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23435 index 3a8185c..3c042ee 100644
23436 --- a/arch/x86/kernel/irq.c
23437 +++ b/arch/x86/kernel/irq.c
23438 @@ -21,7 +21,7 @@
23439 #define CREATE_TRACE_POINTS
23440 #include <asm/trace/irq_vectors.h>
23441
23442 -atomic_t irq_err_count;
23443 +atomic_unchecked_t irq_err_count;
23444
23445 /* Function pointer for generic interrupt vector handling */
23446 void (*x86_platform_ipi_callback)(void) = NULL;
23447 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23448 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23449 seq_printf(p, " Machine check polls\n");
23450 #endif
23451 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23452 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23453 #if defined(CONFIG_X86_IO_APIC)
23454 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23455 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23456 #endif
23457 return 0;
23458 }
23459 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23460
23461 u64 arch_irq_stat(void)
23462 {
23463 - u64 sum = atomic_read(&irq_err_count);
23464 + u64 sum = atomic_read_unchecked(&irq_err_count);
23465 return sum;
23466 }
23467
23468 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23469 index 4186755..784efa0 100644
23470 --- a/arch/x86/kernel/irq_32.c
23471 +++ b/arch/x86/kernel/irq_32.c
23472 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23473 __asm__ __volatile__("andl %%esp,%0" :
23474 "=r" (sp) : "0" (THREAD_SIZE - 1));
23475
23476 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23477 + return sp < STACK_WARN;
23478 }
23479
23480 static void print_stack_overflow(void)
23481 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23482 * per-CPU IRQ handling contexts (thread information and stack)
23483 */
23484 union irq_ctx {
23485 - struct thread_info tinfo;
23486 - u32 stack[THREAD_SIZE/sizeof(u32)];
23487 + unsigned long previous_esp;
23488 + u32 stack[THREAD_SIZE/sizeof(u32)];
23489 } __attribute__((aligned(THREAD_SIZE)));
23490
23491 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23492 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23493 static inline int
23494 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23495 {
23496 - union irq_ctx *curctx, *irqctx;
23497 + union irq_ctx *irqctx;
23498 u32 *isp, arg1, arg2;
23499
23500 - curctx = (union irq_ctx *) current_thread_info();
23501 irqctx = __this_cpu_read(hardirq_ctx);
23502
23503 /*
23504 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23505 * handler) we can't do that and just have to keep using the
23506 * current stack (which is the irq stack already after all)
23507 */
23508 - if (unlikely(curctx == irqctx))
23509 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23510 return 0;
23511
23512 /* build the stack frame on the IRQ stack */
23513 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23514 - irqctx->tinfo.task = curctx->tinfo.task;
23515 - irqctx->tinfo.previous_esp = current_stack_pointer;
23516 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23517 + irqctx->previous_esp = current_stack_pointer;
23518
23519 - /* Copy the preempt_count so that the [soft]irq checks work. */
23520 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23522 + __set_fs(MAKE_MM_SEG(0));
23523 +#endif
23524
23525 if (unlikely(overflow))
23526 call_on_stack(print_stack_overflow, isp);
23527 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23528 : "0" (irq), "1" (desc), "2" (isp),
23529 "D" (desc->handle_irq)
23530 : "memory", "cc", "ecx");
23531 +
23532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23533 + __set_fs(current_thread_info()->addr_limit);
23534 +#endif
23535 +
23536 return 1;
23537 }
23538
23539 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23540 */
23541 void irq_ctx_init(int cpu)
23542 {
23543 - union irq_ctx *irqctx;
23544 -
23545 if (per_cpu(hardirq_ctx, cpu))
23546 return;
23547
23548 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23549 - THREADINFO_GFP,
23550 - THREAD_SIZE_ORDER));
23551 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23552 - irqctx->tinfo.cpu = cpu;
23553 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23554 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23555 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23556 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23557
23558 - per_cpu(hardirq_ctx, cpu) = irqctx;
23559 -
23560 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23561 - THREADINFO_GFP,
23562 - THREAD_SIZE_ORDER));
23563 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23564 - irqctx->tinfo.cpu = cpu;
23565 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23566 -
23567 - per_cpu(softirq_ctx, cpu) = irqctx;
23568 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23569 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23570
23571 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23572 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23573 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23574 asmlinkage void do_softirq(void)
23575 {
23576 unsigned long flags;
23577 - struct thread_info *curctx;
23578 union irq_ctx *irqctx;
23579 u32 *isp;
23580
23581 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23582 local_irq_save(flags);
23583
23584 if (local_softirq_pending()) {
23585 - curctx = current_thread_info();
23586 irqctx = __this_cpu_read(softirq_ctx);
23587 - irqctx->tinfo.task = curctx->task;
23588 - irqctx->tinfo.previous_esp = current_stack_pointer;
23589 + irqctx->previous_esp = current_stack_pointer;
23590
23591 /* build the stack frame on the softirq stack */
23592 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23593 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23594 +
23595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23596 + __set_fs(MAKE_MM_SEG(0));
23597 +#endif
23598
23599 call_on_stack(__do_softirq, isp);
23600 +
23601 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23602 + __set_fs(current_thread_info()->addr_limit);
23603 +#endif
23604 +
23605 /*
23606 * Shouldn't happen, we returned above if in_interrupt():
23607 */
23608 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23609 if (unlikely(!desc))
23610 return false;
23611
23612 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23613 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23614 if (unlikely(overflow))
23615 print_stack_overflow();
23616 desc->handle_irq(irq, desc);
23617 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23618 index d04d3ec..ea4b374 100644
23619 --- a/arch/x86/kernel/irq_64.c
23620 +++ b/arch/x86/kernel/irq_64.c
23621 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23622 u64 estack_top, estack_bottom;
23623 u64 curbase = (u64)task_stack_page(current);
23624
23625 - if (user_mode_vm(regs))
23626 + if (user_mode(regs))
23627 return;
23628
23629 if (regs->sp >= curbase + sizeof(struct thread_info) +
23630 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23631 index dc1404b..bbc43e7 100644
23632 --- a/arch/x86/kernel/kdebugfs.c
23633 +++ b/arch/x86/kernel/kdebugfs.c
23634 @@ -27,7 +27,7 @@ struct setup_data_node {
23635 u32 len;
23636 };
23637
23638 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23639 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23640 size_t count, loff_t *ppos)
23641 {
23642 struct setup_data_node *node = file->private_data;
23643 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23644 index 836f832..a8bda67 100644
23645 --- a/arch/x86/kernel/kgdb.c
23646 +++ b/arch/x86/kernel/kgdb.c
23647 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23648 #ifdef CONFIG_X86_32
23649 switch (regno) {
23650 case GDB_SS:
23651 - if (!user_mode_vm(regs))
23652 + if (!user_mode(regs))
23653 *(unsigned long *)mem = __KERNEL_DS;
23654 break;
23655 case GDB_SP:
23656 - if (!user_mode_vm(regs))
23657 + if (!user_mode(regs))
23658 *(unsigned long *)mem = kernel_stack_pointer(regs);
23659 break;
23660 case GDB_GS:
23661 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23662 bp->attr.bp_addr = breakinfo[breakno].addr;
23663 bp->attr.bp_len = breakinfo[breakno].len;
23664 bp->attr.bp_type = breakinfo[breakno].type;
23665 - info->address = breakinfo[breakno].addr;
23666 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23667 + info->address = ktla_ktva(breakinfo[breakno].addr);
23668 + else
23669 + info->address = breakinfo[breakno].addr;
23670 info->len = breakinfo[breakno].len;
23671 info->type = breakinfo[breakno].type;
23672 val = arch_install_hw_breakpoint(bp);
23673 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23674 case 'k':
23675 /* clear the trace bit */
23676 linux_regs->flags &= ~X86_EFLAGS_TF;
23677 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23678 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23679
23680 /* set the trace bit if we're stepping */
23681 if (remcomInBuffer[0] == 's') {
23682 linux_regs->flags |= X86_EFLAGS_TF;
23683 - atomic_set(&kgdb_cpu_doing_single_step,
23684 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23685 raw_smp_processor_id());
23686 }
23687
23688 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23689
23690 switch (cmd) {
23691 case DIE_DEBUG:
23692 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23693 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23694 if (user_mode(regs))
23695 return single_step_cont(regs, args);
23696 break;
23697 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23698 #endif /* CONFIG_DEBUG_RODATA */
23699
23700 bpt->type = BP_BREAKPOINT;
23701 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23702 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23703 BREAK_INSTR_SIZE);
23704 if (err)
23705 return err;
23706 - err = probe_kernel_write((char *)bpt->bpt_addr,
23707 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23708 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23709 #ifdef CONFIG_DEBUG_RODATA
23710 if (!err)
23711 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23712 return -EBUSY;
23713 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23714 BREAK_INSTR_SIZE);
23715 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23716 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23717 if (err)
23718 return err;
23719 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23720 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23721 if (mutex_is_locked(&text_mutex))
23722 goto knl_write;
23723 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23724 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23725 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23726 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23727 goto knl_write;
23728 return err;
23729 knl_write:
23730 #endif /* CONFIG_DEBUG_RODATA */
23731 - return probe_kernel_write((char *)bpt->bpt_addr,
23732 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23733 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23734 }
23735
23736 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23737 index 211bce4..6e2580a 100644
23738 --- a/arch/x86/kernel/kprobes/core.c
23739 +++ b/arch/x86/kernel/kprobes/core.c
23740 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23741 s32 raddr;
23742 } __packed *insn;
23743
23744 - insn = (struct __arch_relative_insn *)from;
23745 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23746 +
23747 + pax_open_kernel();
23748 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23749 insn->op = op;
23750 + pax_close_kernel();
23751 }
23752
23753 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23754 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23755 kprobe_opcode_t opcode;
23756 kprobe_opcode_t *orig_opcodes = opcodes;
23757
23758 - if (search_exception_tables((unsigned long)opcodes))
23759 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23760 return 0; /* Page fault may occur on this address. */
23761
23762 retry:
23763 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23764 * for the first byte, we can recover the original instruction
23765 * from it and kp->opcode.
23766 */
23767 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23768 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23769 buf[0] = kp->opcode;
23770 - return (unsigned long)buf;
23771 + return ktva_ktla((unsigned long)buf);
23772 }
23773
23774 /*
23775 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23776 /* Another subsystem puts a breakpoint, failed to recover */
23777 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23778 return 0;
23779 + pax_open_kernel();
23780 memcpy(dest, insn.kaddr, insn.length);
23781 + pax_close_kernel();
23782
23783 #ifdef CONFIG_X86_64
23784 if (insn_rip_relative(&insn)) {
23785 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23786 return 0;
23787 }
23788 disp = (u8 *) dest + insn_offset_displacement(&insn);
23789 + pax_open_kernel();
23790 *(s32 *) disp = (s32) newdisp;
23791 + pax_close_kernel();
23792 }
23793 #endif
23794 return insn.length;
23795 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23796 * nor set current_kprobe, because it doesn't use single
23797 * stepping.
23798 */
23799 - regs->ip = (unsigned long)p->ainsn.insn;
23800 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23801 preempt_enable_no_resched();
23802 return;
23803 }
23804 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23805 regs->flags &= ~X86_EFLAGS_IF;
23806 /* single step inline if the instruction is an int3 */
23807 if (p->opcode == BREAKPOINT_INSTRUCTION)
23808 - regs->ip = (unsigned long)p->addr;
23809 + regs->ip = ktla_ktva((unsigned long)p->addr);
23810 else
23811 - regs->ip = (unsigned long)p->ainsn.insn;
23812 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23813 }
23814
23815 /*
23816 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23817 setup_singlestep(p, regs, kcb, 0);
23818 return 1;
23819 }
23820 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23821 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23822 /*
23823 * The breakpoint instruction was removed right
23824 * after we hit it. Another cpu has removed
23825 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23826 " movq %rax, 152(%rsp)\n"
23827 RESTORE_REGS_STRING
23828 " popfq\n"
23829 +#ifdef KERNEXEC_PLUGIN
23830 + " btsq $63,(%rsp)\n"
23831 +#endif
23832 #else
23833 " pushf\n"
23834 SAVE_REGS_STRING
23835 @@ -779,7 +789,7 @@ static void __kprobes
23836 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23837 {
23838 unsigned long *tos = stack_addr(regs);
23839 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23840 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23841 unsigned long orig_ip = (unsigned long)p->addr;
23842 kprobe_opcode_t *insn = p->ainsn.insn;
23843
23844 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23845 struct die_args *args = data;
23846 int ret = NOTIFY_DONE;
23847
23848 - if (args->regs && user_mode_vm(args->regs))
23849 + if (args->regs && user_mode(args->regs))
23850 return ret;
23851
23852 switch (val) {
23853 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23854 index 76dc6f0..66bdfc3 100644
23855 --- a/arch/x86/kernel/kprobes/opt.c
23856 +++ b/arch/x86/kernel/kprobes/opt.c
23857 @@ -79,6 +79,7 @@ found:
23858 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23859 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23860 {
23861 + pax_open_kernel();
23862 #ifdef CONFIG_X86_64
23863 *addr++ = 0x48;
23864 *addr++ = 0xbf;
23865 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23866 *addr++ = 0xb8;
23867 #endif
23868 *(unsigned long *)addr = val;
23869 + pax_close_kernel();
23870 }
23871
23872 static void __used __kprobes kprobes_optinsn_template_holder(void)
23873 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23874 * Verify if the address gap is in 2GB range, because this uses
23875 * a relative jump.
23876 */
23877 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23878 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23879 if (abs(rel) > 0x7fffffff)
23880 return -ERANGE;
23881
23882 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23883 op->optinsn.size = ret;
23884
23885 /* Copy arch-dep-instance from template */
23886 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23887 + pax_open_kernel();
23888 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23889 + pax_close_kernel();
23890
23891 /* Set probe information */
23892 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23893
23894 /* Set probe function call */
23895 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23896 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23897
23898 /* Set returning jmp instruction at the tail of out-of-line buffer */
23899 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23900 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23901 (u8 *)op->kp.addr + op->optinsn.size);
23902
23903 flush_icache_range((unsigned long) buf,
23904 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23905 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23906
23907 /* Backup instructions which will be replaced by jump address */
23908 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23909 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23910 RELATIVE_ADDR_SIZE);
23911
23912 insn_buf[0] = RELATIVEJUMP_OPCODE;
23913 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23914 /* This kprobe is really able to run optimized path. */
23915 op = container_of(p, struct optimized_kprobe, kp);
23916 /* Detour through copied instructions */
23917 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23918 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23919 if (!reenter)
23920 reset_current_kprobe();
23921 preempt_enable_no_resched();
23922 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23923 index ebc9873..1b9724b 100644
23924 --- a/arch/x86/kernel/ldt.c
23925 +++ b/arch/x86/kernel/ldt.c
23926 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23927 if (reload) {
23928 #ifdef CONFIG_SMP
23929 preempt_disable();
23930 - load_LDT(pc);
23931 + load_LDT_nolock(pc);
23932 if (!cpumask_equal(mm_cpumask(current->mm),
23933 cpumask_of(smp_processor_id())))
23934 smp_call_function(flush_ldt, current->mm, 1);
23935 preempt_enable();
23936 #else
23937 - load_LDT(pc);
23938 + load_LDT_nolock(pc);
23939 #endif
23940 }
23941 if (oldsize) {
23942 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23943 return err;
23944
23945 for (i = 0; i < old->size; i++)
23946 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23947 + write_ldt_entry(new->ldt, i, old->ldt + i);
23948 return 0;
23949 }
23950
23951 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23952 retval = copy_ldt(&mm->context, &old_mm->context);
23953 mutex_unlock(&old_mm->context.lock);
23954 }
23955 +
23956 + if (tsk == current) {
23957 + mm->context.vdso = 0;
23958 +
23959 +#ifdef CONFIG_X86_32
23960 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23961 + mm->context.user_cs_base = 0UL;
23962 + mm->context.user_cs_limit = ~0UL;
23963 +
23964 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23965 + cpus_clear(mm->context.cpu_user_cs_mask);
23966 +#endif
23967 +
23968 +#endif
23969 +#endif
23970 +
23971 + }
23972 +
23973 return retval;
23974 }
23975
23976 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23977 }
23978 }
23979
23980 +#ifdef CONFIG_PAX_SEGMEXEC
23981 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23982 + error = -EINVAL;
23983 + goto out_unlock;
23984 + }
23985 +#endif
23986 +
23987 fill_ldt(&ldt, &ldt_info);
23988 if (oldmode)
23989 ldt.avl = 0;
23990 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23991 index 5b19e4d..6476a76 100644
23992 --- a/arch/x86/kernel/machine_kexec_32.c
23993 +++ b/arch/x86/kernel/machine_kexec_32.c
23994 @@ -26,7 +26,7 @@
23995 #include <asm/cacheflush.h>
23996 #include <asm/debugreg.h>
23997
23998 -static void set_idt(void *newidt, __u16 limit)
23999 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24000 {
24001 struct desc_ptr curidt;
24002
24003 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24004 }
24005
24006
24007 -static void set_gdt(void *newgdt, __u16 limit)
24008 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24009 {
24010 struct desc_ptr curgdt;
24011
24012 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24013 }
24014
24015 control_page = page_address(image->control_code_page);
24016 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24017 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24018
24019 relocate_kernel_ptr = control_page;
24020 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24021 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24022 index 15c9876..0a43909 100644
24023 --- a/arch/x86/kernel/microcode_core.c
24024 +++ b/arch/x86/kernel/microcode_core.c
24025 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24026 return NOTIFY_OK;
24027 }
24028
24029 -static struct notifier_block __refdata mc_cpu_notifier = {
24030 +static struct notifier_block mc_cpu_notifier = {
24031 .notifier_call = mc_cpu_callback,
24032 };
24033
24034 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24035 index 5fb2ceb..3ae90bb 100644
24036 --- a/arch/x86/kernel/microcode_intel.c
24037 +++ b/arch/x86/kernel/microcode_intel.c
24038 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24039
24040 static int get_ucode_user(void *to, const void *from, size_t n)
24041 {
24042 - return copy_from_user(to, from, n);
24043 + return copy_from_user(to, (const void __force_user *)from, n);
24044 }
24045
24046 static enum ucode_state
24047 request_microcode_user(int cpu, const void __user *buf, size_t size)
24048 {
24049 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24050 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24051 }
24052
24053 static void microcode_fini_cpu(int cpu)
24054 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24055 index 216a4d7..228255a 100644
24056 --- a/arch/x86/kernel/module.c
24057 +++ b/arch/x86/kernel/module.c
24058 @@ -43,15 +43,60 @@ do { \
24059 } while (0)
24060 #endif
24061
24062 -void *module_alloc(unsigned long size)
24063 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24064 {
24065 - if (PAGE_ALIGN(size) > MODULES_LEN)
24066 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24067 return NULL;
24068 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24069 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24070 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24071 -1, __builtin_return_address(0));
24072 }
24073
24074 +void *module_alloc(unsigned long size)
24075 +{
24076 +
24077 +#ifdef CONFIG_PAX_KERNEXEC
24078 + return __module_alloc(size, PAGE_KERNEL);
24079 +#else
24080 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24081 +#endif
24082 +
24083 +}
24084 +
24085 +#ifdef CONFIG_PAX_KERNEXEC
24086 +#ifdef CONFIG_X86_32
24087 +void *module_alloc_exec(unsigned long size)
24088 +{
24089 + struct vm_struct *area;
24090 +
24091 + if (size == 0)
24092 + return NULL;
24093 +
24094 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24095 + return area ? area->addr : NULL;
24096 +}
24097 +EXPORT_SYMBOL(module_alloc_exec);
24098 +
24099 +void module_free_exec(struct module *mod, void *module_region)
24100 +{
24101 + vunmap(module_region);
24102 +}
24103 +EXPORT_SYMBOL(module_free_exec);
24104 +#else
24105 +void module_free_exec(struct module *mod, void *module_region)
24106 +{
24107 + module_free(mod, module_region);
24108 +}
24109 +EXPORT_SYMBOL(module_free_exec);
24110 +
24111 +void *module_alloc_exec(unsigned long size)
24112 +{
24113 + return __module_alloc(size, PAGE_KERNEL_RX);
24114 +}
24115 +EXPORT_SYMBOL(module_alloc_exec);
24116 +#endif
24117 +#endif
24118 +
24119 #ifdef CONFIG_X86_32
24120 int apply_relocate(Elf32_Shdr *sechdrs,
24121 const char *strtab,
24122 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24123 unsigned int i;
24124 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24125 Elf32_Sym *sym;
24126 - uint32_t *location;
24127 + uint32_t *plocation, location;
24128
24129 DEBUGP("Applying relocate section %u to %u\n",
24130 relsec, sechdrs[relsec].sh_info);
24131 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24132 /* This is where to make the change */
24133 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24134 - + rel[i].r_offset;
24135 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24136 + location = (uint32_t)plocation;
24137 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24138 + plocation = ktla_ktva((void *)plocation);
24139 /* This is the symbol it is referring to. Note that all
24140 undefined symbols have been resolved. */
24141 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24142 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24143 switch (ELF32_R_TYPE(rel[i].r_info)) {
24144 case R_386_32:
24145 /* We add the value into the location given */
24146 - *location += sym->st_value;
24147 + pax_open_kernel();
24148 + *plocation += sym->st_value;
24149 + pax_close_kernel();
24150 break;
24151 case R_386_PC32:
24152 /* Add the value, subtract its position */
24153 - *location += sym->st_value - (uint32_t)location;
24154 + pax_open_kernel();
24155 + *plocation += sym->st_value - location;
24156 + pax_close_kernel();
24157 break;
24158 default:
24159 pr_err("%s: Unknown relocation: %u\n",
24160 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24161 case R_X86_64_NONE:
24162 break;
24163 case R_X86_64_64:
24164 + pax_open_kernel();
24165 *(u64 *)loc = val;
24166 + pax_close_kernel();
24167 break;
24168 case R_X86_64_32:
24169 + pax_open_kernel();
24170 *(u32 *)loc = val;
24171 + pax_close_kernel();
24172 if (val != *(u32 *)loc)
24173 goto overflow;
24174 break;
24175 case R_X86_64_32S:
24176 + pax_open_kernel();
24177 *(s32 *)loc = val;
24178 + pax_close_kernel();
24179 if ((s64)val != *(s32 *)loc)
24180 goto overflow;
24181 break;
24182 case R_X86_64_PC32:
24183 val -= (u64)loc;
24184 + pax_open_kernel();
24185 *(u32 *)loc = val;
24186 + pax_close_kernel();
24187 +
24188 #if 0
24189 if ((s64)val != *(s32 *)loc)
24190 goto overflow;
24191 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24192 index 88458fa..349f7a4 100644
24193 --- a/arch/x86/kernel/msr.c
24194 +++ b/arch/x86/kernel/msr.c
24195 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24196 return notifier_from_errno(err);
24197 }
24198
24199 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24200 +static struct notifier_block msr_class_cpu_notifier = {
24201 .notifier_call = msr_class_cpu_callback,
24202 };
24203
24204 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24205 index ba77ebc..65da999 100644
24206 --- a/arch/x86/kernel/nmi.c
24207 +++ b/arch/x86/kernel/nmi.c
24208 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24209 return handled;
24210 }
24211
24212 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24213 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24214 {
24215 struct nmi_desc *desc = nmi_to_desc(type);
24216 unsigned long flags;
24217 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24218 * event confuses some handlers (kdump uses this flag)
24219 */
24220 if (action->flags & NMI_FLAG_FIRST)
24221 - list_add_rcu(&action->list, &desc->head);
24222 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24223 else
24224 - list_add_tail_rcu(&action->list, &desc->head);
24225 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24226
24227 spin_unlock_irqrestore(&desc->lock, flags);
24228 return 0;
24229 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24230 if (!strcmp(n->name, name)) {
24231 WARN(in_nmi(),
24232 "Trying to free NMI (%s) from NMI context!\n", n->name);
24233 - list_del_rcu(&n->list);
24234 + pax_list_del_rcu((struct list_head *)&n->list);
24235 break;
24236 }
24237 }
24238 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24239 dotraplinkage notrace __kprobes void
24240 do_nmi(struct pt_regs *regs, long error_code)
24241 {
24242 +
24243 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24244 + if (!user_mode(regs)) {
24245 + unsigned long cs = regs->cs & 0xFFFF;
24246 + unsigned long ip = ktva_ktla(regs->ip);
24247 +
24248 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24249 + regs->ip = ip;
24250 + }
24251 +#endif
24252 +
24253 nmi_nesting_preprocess(regs);
24254
24255 nmi_enter();
24256 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24257 index 6d9582e..f746287 100644
24258 --- a/arch/x86/kernel/nmi_selftest.c
24259 +++ b/arch/x86/kernel/nmi_selftest.c
24260 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24261 {
24262 /* trap all the unknown NMIs we may generate */
24263 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24264 - __initdata);
24265 + __initconst);
24266 }
24267
24268 static void __init cleanup_nmi_testsuite(void)
24269 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24270 unsigned long timeout;
24271
24272 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24273 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24274 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24275 nmi_fail = FAILURE;
24276 return;
24277 }
24278 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24279 index 676b8c7..870ba04 100644
24280 --- a/arch/x86/kernel/paravirt-spinlocks.c
24281 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24282 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24283 arch_spin_lock(lock);
24284 }
24285
24286 -struct pv_lock_ops pv_lock_ops = {
24287 +struct pv_lock_ops pv_lock_ops __read_only = {
24288 #ifdef CONFIG_SMP
24289 .spin_is_locked = __ticket_spin_is_locked,
24290 .spin_is_contended = __ticket_spin_is_contended,
24291 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24292 index cd6de64..27c6af0 100644
24293 --- a/arch/x86/kernel/paravirt.c
24294 +++ b/arch/x86/kernel/paravirt.c
24295 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24296 {
24297 return x;
24298 }
24299 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24300 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24301 +#endif
24302
24303 void __init default_banner(void)
24304 {
24305 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24306 if (opfunc == NULL)
24307 /* If there's no function, patch it with a ud2a (BUG) */
24308 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24309 - else if (opfunc == _paravirt_nop)
24310 + else if (opfunc == (void *)_paravirt_nop)
24311 /* If the operation is a nop, then nop the callsite */
24312 ret = paravirt_patch_nop();
24313
24314 /* identity functions just return their single argument */
24315 - else if (opfunc == _paravirt_ident_32)
24316 + else if (opfunc == (void *)_paravirt_ident_32)
24317 ret = paravirt_patch_ident_32(insnbuf, len);
24318 - else if (opfunc == _paravirt_ident_64)
24319 + else if (opfunc == (void *)_paravirt_ident_64)
24320 ret = paravirt_patch_ident_64(insnbuf, len);
24321 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24322 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24323 + ret = paravirt_patch_ident_64(insnbuf, len);
24324 +#endif
24325
24326 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24327 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24328 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24329 if (insn_len > len || start == NULL)
24330 insn_len = len;
24331 else
24332 - memcpy(insnbuf, start, insn_len);
24333 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24334
24335 return insn_len;
24336 }
24337 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24338 return this_cpu_read(paravirt_lazy_mode);
24339 }
24340
24341 -struct pv_info pv_info = {
24342 +struct pv_info pv_info __read_only = {
24343 .name = "bare hardware",
24344 .paravirt_enabled = 0,
24345 .kernel_rpl = 0,
24346 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24347 #endif
24348 };
24349
24350 -struct pv_init_ops pv_init_ops = {
24351 +struct pv_init_ops pv_init_ops __read_only = {
24352 .patch = native_patch,
24353 };
24354
24355 -struct pv_time_ops pv_time_ops = {
24356 +struct pv_time_ops pv_time_ops __read_only = {
24357 .sched_clock = native_sched_clock,
24358 .steal_clock = native_steal_clock,
24359 };
24360
24361 -struct pv_irq_ops pv_irq_ops = {
24362 +struct pv_irq_ops pv_irq_ops __read_only = {
24363 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24364 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24365 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24366 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24367 #endif
24368 };
24369
24370 -struct pv_cpu_ops pv_cpu_ops = {
24371 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24372 .cpuid = native_cpuid,
24373 .get_debugreg = native_get_debugreg,
24374 .set_debugreg = native_set_debugreg,
24375 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24376 .end_context_switch = paravirt_nop,
24377 };
24378
24379 -struct pv_apic_ops pv_apic_ops = {
24380 +struct pv_apic_ops pv_apic_ops __read_only= {
24381 #ifdef CONFIG_X86_LOCAL_APIC
24382 .startup_ipi_hook = paravirt_nop,
24383 #endif
24384 };
24385
24386 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24387 +#ifdef CONFIG_X86_32
24388 +#ifdef CONFIG_X86_PAE
24389 +/* 64-bit pagetable entries */
24390 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24391 +#else
24392 /* 32-bit pagetable entries */
24393 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24394 +#endif
24395 #else
24396 /* 64-bit pagetable entries */
24397 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24398 #endif
24399
24400 -struct pv_mmu_ops pv_mmu_ops = {
24401 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24402
24403 .read_cr2 = native_read_cr2,
24404 .write_cr2 = native_write_cr2,
24405 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24406 .make_pud = PTE_IDENT,
24407
24408 .set_pgd = native_set_pgd,
24409 + .set_pgd_batched = native_set_pgd_batched,
24410 #endif
24411 #endif /* PAGETABLE_LEVELS >= 3 */
24412
24413 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24414 },
24415
24416 .set_fixmap = native_set_fixmap,
24417 +
24418 +#ifdef CONFIG_PAX_KERNEXEC
24419 + .pax_open_kernel = native_pax_open_kernel,
24420 + .pax_close_kernel = native_pax_close_kernel,
24421 +#endif
24422 +
24423 };
24424
24425 EXPORT_SYMBOL_GPL(pv_time_ops);
24426 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24427 index 299d493..2ccb0ee 100644
24428 --- a/arch/x86/kernel/pci-calgary_64.c
24429 +++ b/arch/x86/kernel/pci-calgary_64.c
24430 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24431 tce_space = be64_to_cpu(readq(target));
24432 tce_space = tce_space & TAR_SW_BITS;
24433
24434 - tce_space = tce_space & (~specified_table_size);
24435 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24436 info->tce_space = (u64 *)__va(tce_space);
24437 }
24438 }
24439 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24440 index 35ccf75..7a15747 100644
24441 --- a/arch/x86/kernel/pci-iommu_table.c
24442 +++ b/arch/x86/kernel/pci-iommu_table.c
24443 @@ -2,7 +2,7 @@
24444 #include <asm/iommu_table.h>
24445 #include <linux/string.h>
24446 #include <linux/kallsyms.h>
24447 -
24448 +#include <linux/sched.h>
24449
24450 #define DEBUG 1
24451
24452 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24453 index 6c483ba..d10ce2f 100644
24454 --- a/arch/x86/kernel/pci-swiotlb.c
24455 +++ b/arch/x86/kernel/pci-swiotlb.c
24456 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24457 void *vaddr, dma_addr_t dma_addr,
24458 struct dma_attrs *attrs)
24459 {
24460 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24461 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24462 }
24463
24464 static struct dma_map_ops swiotlb_dma_ops = {
24465 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24466 index 83369e5..52b93f0 100644
24467 --- a/arch/x86/kernel/process.c
24468 +++ b/arch/x86/kernel/process.c
24469 @@ -36,7 +36,8 @@
24470 * section. Since TSS's are completely CPU-local, we want them
24471 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24472 */
24473 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24474 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24475 +EXPORT_SYMBOL(init_tss);
24476
24477 #ifdef CONFIG_X86_64
24478 static DEFINE_PER_CPU(unsigned char, is_idle);
24479 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24480 task_xstate_cachep =
24481 kmem_cache_create("task_xstate", xstate_size,
24482 __alignof__(union thread_xstate),
24483 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24484 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24485 }
24486
24487 /*
24488 @@ -105,7 +106,7 @@ void exit_thread(void)
24489 unsigned long *bp = t->io_bitmap_ptr;
24490
24491 if (bp) {
24492 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24493 + struct tss_struct *tss = init_tss + get_cpu();
24494
24495 t->io_bitmap_ptr = NULL;
24496 clear_thread_flag(TIF_IO_BITMAP);
24497 @@ -125,6 +126,9 @@ void flush_thread(void)
24498 {
24499 struct task_struct *tsk = current;
24500
24501 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24502 + loadsegment(gs, 0);
24503 +#endif
24504 flush_ptrace_hw_breakpoint(tsk);
24505 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24506 drop_init_fpu(tsk);
24507 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24508 void exit_idle(void)
24509 {
24510 /* idle loop has pid 0 */
24511 - if (current->pid)
24512 + if (task_pid_nr(current))
24513 return;
24514 __exit_idle();
24515 }
24516 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24517 return ret;
24518 }
24519 #endif
24520 -void stop_this_cpu(void *dummy)
24521 +__noreturn void stop_this_cpu(void *dummy)
24522 {
24523 local_irq_disable();
24524 /*
24525 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24526 }
24527 early_param("idle", idle_setup);
24528
24529 -unsigned long arch_align_stack(unsigned long sp)
24530 +#ifdef CONFIG_PAX_RANDKSTACK
24531 +void pax_randomize_kstack(struct pt_regs *regs)
24532 {
24533 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24534 - sp -= get_random_int() % 8192;
24535 - return sp & ~0xf;
24536 -}
24537 + struct thread_struct *thread = &current->thread;
24538 + unsigned long time;
24539
24540 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24541 -{
24542 - unsigned long range_end = mm->brk + 0x02000000;
24543 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24544 -}
24545 + if (!randomize_va_space)
24546 + return;
24547 +
24548 + if (v8086_mode(regs))
24549 + return;
24550
24551 + rdtscl(time);
24552 +
24553 + /* P4 seems to return a 0 LSB, ignore it */
24554 +#ifdef CONFIG_MPENTIUM4
24555 + time &= 0x3EUL;
24556 + time <<= 2;
24557 +#elif defined(CONFIG_X86_64)
24558 + time &= 0xFUL;
24559 + time <<= 4;
24560 +#else
24561 + time &= 0x1FUL;
24562 + time <<= 3;
24563 +#endif
24564 +
24565 + thread->sp0 ^= time;
24566 + load_sp0(init_tss + smp_processor_id(), thread);
24567 +
24568 +#ifdef CONFIG_X86_64
24569 + this_cpu_write(kernel_stack, thread->sp0);
24570 +#endif
24571 +}
24572 +#endif
24573 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24574 index f8adefc..4bce3d6 100644
24575 --- a/arch/x86/kernel/process_32.c
24576 +++ b/arch/x86/kernel/process_32.c
24577 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24578 unsigned long thread_saved_pc(struct task_struct *tsk)
24579 {
24580 return ((unsigned long *)tsk->thread.sp)[3];
24581 +//XXX return tsk->thread.eip;
24582 }
24583
24584 void __show_regs(struct pt_regs *regs, int all)
24585 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24586 unsigned long sp;
24587 unsigned short ss, gs;
24588
24589 - if (user_mode_vm(regs)) {
24590 + if (user_mode(regs)) {
24591 sp = regs->sp;
24592 ss = regs->ss & 0xffff;
24593 - gs = get_user_gs(regs);
24594 } else {
24595 sp = kernel_stack_pointer(regs);
24596 savesegment(ss, ss);
24597 - savesegment(gs, gs);
24598 }
24599 + gs = get_user_gs(regs);
24600
24601 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24602 (u16)regs->cs, regs->ip, regs->flags,
24603 - smp_processor_id());
24604 + raw_smp_processor_id());
24605 print_symbol("EIP is at %s\n", regs->ip);
24606
24607 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24608 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24609 int copy_thread(unsigned long clone_flags, unsigned long sp,
24610 unsigned long arg, struct task_struct *p)
24611 {
24612 - struct pt_regs *childregs = task_pt_regs(p);
24613 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24614 struct task_struct *tsk;
24615 int err;
24616
24617 p->thread.sp = (unsigned long) childregs;
24618 p->thread.sp0 = (unsigned long) (childregs+1);
24619 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24620
24621 if (unlikely(p->flags & PF_KTHREAD)) {
24622 /* kernel thread */
24623 memset(childregs, 0, sizeof(struct pt_regs));
24624 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24625 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24626 - childregs->ds = __USER_DS;
24627 - childregs->es = __USER_DS;
24628 + savesegment(gs, childregs->gs);
24629 + childregs->ds = __KERNEL_DS;
24630 + childregs->es = __KERNEL_DS;
24631 childregs->fs = __KERNEL_PERCPU;
24632 childregs->bx = sp; /* function */
24633 childregs->bp = arg;
24634 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24635 struct thread_struct *prev = &prev_p->thread,
24636 *next = &next_p->thread;
24637 int cpu = smp_processor_id();
24638 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24639 + struct tss_struct *tss = init_tss + cpu;
24640 fpu_switch_t fpu;
24641
24642 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24643 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24644 */
24645 lazy_save_gs(prev->gs);
24646
24647 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24648 + __set_fs(task_thread_info(next_p)->addr_limit);
24649 +#endif
24650 +
24651 /*
24652 * Load the per-thread Thread-Local Storage descriptor.
24653 */
24654 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24655 */
24656 arch_end_context_switch(next_p);
24657
24658 + this_cpu_write(current_task, next_p);
24659 + this_cpu_write(current_tinfo, &next_p->tinfo);
24660 +
24661 /*
24662 * Restore %gs if needed (which is common)
24663 */
24664 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24665
24666 switch_fpu_finish(next_p, fpu);
24667
24668 - this_cpu_write(current_task, next_p);
24669 -
24670 return prev_p;
24671 }
24672
24673 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24674 } while (count++ < 16);
24675 return 0;
24676 }
24677 -
24678 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24679 index 05646ba..0c2906d 100644
24680 --- a/arch/x86/kernel/process_64.c
24681 +++ b/arch/x86/kernel/process_64.c
24682 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24683 struct pt_regs *childregs;
24684 struct task_struct *me = current;
24685
24686 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24687 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24688 childregs = task_pt_regs(p);
24689 p->thread.sp = (unsigned long) childregs;
24690 p->thread.usersp = me->thread.usersp;
24691 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24692 set_tsk_thread_flag(p, TIF_FORK);
24693 p->fpu_counter = 0;
24694 p->thread.io_bitmap_ptr = NULL;
24695 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24696 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24697 savesegment(es, p->thread.es);
24698 savesegment(ds, p->thread.ds);
24699 + savesegment(ss, p->thread.ss);
24700 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24701 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24702
24703 if (unlikely(p->flags & PF_KTHREAD)) {
24704 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24705 struct thread_struct *prev = &prev_p->thread;
24706 struct thread_struct *next = &next_p->thread;
24707 int cpu = smp_processor_id();
24708 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24709 + struct tss_struct *tss = init_tss + cpu;
24710 unsigned fsindex, gsindex;
24711 fpu_switch_t fpu;
24712
24713 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24714 if (unlikely(next->ds | prev->ds))
24715 loadsegment(ds, next->ds);
24716
24717 + savesegment(ss, prev->ss);
24718 + if (unlikely(next->ss != prev->ss))
24719 + loadsegment(ss, next->ss);
24720
24721 /* We must save %fs and %gs before load_TLS() because
24722 * %fs and %gs may be cleared by load_TLS().
24723 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24724 prev->usersp = this_cpu_read(old_rsp);
24725 this_cpu_write(old_rsp, next->usersp);
24726 this_cpu_write(current_task, next_p);
24727 + this_cpu_write(current_tinfo, &next_p->tinfo);
24728
24729 - this_cpu_write(kernel_stack,
24730 - (unsigned long)task_stack_page(next_p) +
24731 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24732 + this_cpu_write(kernel_stack, next->sp0);
24733
24734 /*
24735 * Now maybe reload the debug registers and handle I/O bitmaps
24736 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24737 if (!p || p == current || p->state == TASK_RUNNING)
24738 return 0;
24739 stack = (unsigned long)task_stack_page(p);
24740 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24741 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24742 return 0;
24743 fp = *(u64 *)(p->thread.sp);
24744 do {
24745 - if (fp < (unsigned long)stack ||
24746 - fp >= (unsigned long)stack+THREAD_SIZE)
24747 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24748 return 0;
24749 ip = *(u64 *)(fp+8);
24750 if (!in_sched_functions(ip))
24751 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24752 index 7461f50..1334029 100644
24753 --- a/arch/x86/kernel/ptrace.c
24754 +++ b/arch/x86/kernel/ptrace.c
24755 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24756 {
24757 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24758 unsigned long sp = (unsigned long)&regs->sp;
24759 - struct thread_info *tinfo;
24760
24761 - if (context == (sp & ~(THREAD_SIZE - 1)))
24762 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24763 return sp;
24764
24765 - tinfo = (struct thread_info *)context;
24766 - if (tinfo->previous_esp)
24767 - return tinfo->previous_esp;
24768 + sp = *(unsigned long *)context;
24769 + if (sp)
24770 + return sp;
24771
24772 return (unsigned long)regs;
24773 }
24774 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24775 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24776 {
24777 int i;
24778 - int dr7 = 0;
24779 + unsigned long dr7 = 0;
24780 struct arch_hw_breakpoint *info;
24781
24782 for (i = 0; i < HBP_NUM; i++) {
24783 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24784 unsigned long addr, unsigned long data)
24785 {
24786 int ret;
24787 - unsigned long __user *datap = (unsigned long __user *)data;
24788 + unsigned long __user *datap = (__force unsigned long __user *)data;
24789
24790 switch (request) {
24791 /* read the word at location addr in the USER area. */
24792 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24793 if ((int) addr < 0)
24794 return -EIO;
24795 ret = do_get_thread_area(child, addr,
24796 - (struct user_desc __user *)data);
24797 + (__force struct user_desc __user *) data);
24798 break;
24799
24800 case PTRACE_SET_THREAD_AREA:
24801 if ((int) addr < 0)
24802 return -EIO;
24803 ret = do_set_thread_area(child, addr,
24804 - (struct user_desc __user *)data, 0);
24805 + (__force struct user_desc __user *) data, 0);
24806 break;
24807 #endif
24808
24809 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24810
24811 #ifdef CONFIG_X86_64
24812
24813 -static struct user_regset x86_64_regsets[] __read_mostly = {
24814 +static user_regset_no_const x86_64_regsets[] __read_only = {
24815 [REGSET_GENERAL] = {
24816 .core_note_type = NT_PRSTATUS,
24817 .n = sizeof(struct user_regs_struct) / sizeof(long),
24818 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24819 #endif /* CONFIG_X86_64 */
24820
24821 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24822 -static struct user_regset x86_32_regsets[] __read_mostly = {
24823 +static user_regset_no_const x86_32_regsets[] __read_only = {
24824 [REGSET_GENERAL] = {
24825 .core_note_type = NT_PRSTATUS,
24826 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24827 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24828 */
24829 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24830
24831 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24832 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24833 {
24834 #ifdef CONFIG_X86_64
24835 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24836 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24837 memset(info, 0, sizeof(*info));
24838 info->si_signo = SIGTRAP;
24839 info->si_code = si_code;
24840 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24841 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24842 }
24843
24844 void user_single_step_siginfo(struct task_struct *tsk,
24845 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24846 # define IS_IA32 0
24847 #endif
24848
24849 +#ifdef CONFIG_GRKERNSEC_SETXID
24850 +extern void gr_delayed_cred_worker(void);
24851 +#endif
24852 +
24853 /*
24854 * We must return the syscall number to actually look up in the table.
24855 * This can be -1L to skip running any syscall at all.
24856 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24857
24858 user_exit();
24859
24860 +#ifdef CONFIG_GRKERNSEC_SETXID
24861 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24862 + gr_delayed_cred_worker();
24863 +#endif
24864 +
24865 /*
24866 * If we stepped into a sysenter/syscall insn, it trapped in
24867 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24868 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24869 */
24870 user_exit();
24871
24872 +#ifdef CONFIG_GRKERNSEC_SETXID
24873 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24874 + gr_delayed_cred_worker();
24875 +#endif
24876 +
24877 audit_syscall_exit(regs);
24878
24879 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24880 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24881 index 2cb9470..ff1fd80 100644
24882 --- a/arch/x86/kernel/pvclock.c
24883 +++ b/arch/x86/kernel/pvclock.c
24884 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24885 return pv_tsc_khz;
24886 }
24887
24888 -static atomic64_t last_value = ATOMIC64_INIT(0);
24889 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24890
24891 void pvclock_resume(void)
24892 {
24893 - atomic64_set(&last_value, 0);
24894 + atomic64_set_unchecked(&last_value, 0);
24895 }
24896
24897 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24898 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24899 * updating at the same time, and one of them could be slightly behind,
24900 * making the assumption that last_value always go forward fail to hold.
24901 */
24902 - last = atomic64_read(&last_value);
24903 + last = atomic64_read_unchecked(&last_value);
24904 do {
24905 if (ret < last)
24906 return last;
24907 - last = atomic64_cmpxchg(&last_value, last, ret);
24908 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24909 } while (unlikely(last != ret));
24910
24911 return ret;
24912 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24913 index 5f4ad27..9d96c99 100644
24914 --- a/arch/x86/kernel/reboot.c
24915 +++ b/arch/x86/kernel/reboot.c
24916 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24917
24918 void __noreturn machine_real_restart(unsigned int type)
24919 {
24920 +
24921 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24922 + struct desc_struct *gdt;
24923 +#endif
24924 +
24925 local_irq_disable();
24926
24927 /*
24928 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24929
24930 /* Jump to the identity-mapped low memory code */
24931 #ifdef CONFIG_X86_32
24932 - asm volatile("jmpl *%0" : :
24933 +
24934 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24935 + gdt = get_cpu_gdt_table(smp_processor_id());
24936 + pax_open_kernel();
24937 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24938 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24939 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24940 + loadsegment(ds, __KERNEL_DS);
24941 + loadsegment(es, __KERNEL_DS);
24942 + loadsegment(ss, __KERNEL_DS);
24943 +#endif
24944 +#ifdef CONFIG_PAX_KERNEXEC
24945 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24946 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24947 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24948 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24949 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24950 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24951 +#endif
24952 + pax_close_kernel();
24953 +#endif
24954 +
24955 + asm volatile("ljmpl *%0" : :
24956 "rm" (real_mode_header->machine_real_restart_asm),
24957 "a" (type));
24958 #else
24959 @@ -458,7 +485,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24960 * try to force a triple fault and then cycle between hitting the keyboard
24961 * controller and doing that
24962 */
24963 -static void native_machine_emergency_restart(void)
24964 +static void __noreturn native_machine_emergency_restart(void)
24965 {
24966 int i;
24967 int attempt = 0;
24968 @@ -567,13 +594,13 @@ void native_machine_shutdown(void)
24969 #endif
24970 }
24971
24972 -static void __machine_emergency_restart(int emergency)
24973 +static void __noreturn __machine_emergency_restart(int emergency)
24974 {
24975 reboot_emergency = emergency;
24976 machine_ops.emergency_restart();
24977 }
24978
24979 -static void native_machine_restart(char *__unused)
24980 +static void __noreturn native_machine_restart(char *__unused)
24981 {
24982 pr_notice("machine restart\n");
24983
24984 @@ -582,7 +609,7 @@ static void native_machine_restart(char *__unused)
24985 __machine_emergency_restart(0);
24986 }
24987
24988 -static void native_machine_halt(void)
24989 +static void __noreturn native_machine_halt(void)
24990 {
24991 /* Stop other cpus and apics */
24992 machine_shutdown();
24993 @@ -592,7 +619,7 @@ static void native_machine_halt(void)
24994 stop_this_cpu(NULL);
24995 }
24996
24997 -static void native_machine_power_off(void)
24998 +static void __noreturn native_machine_power_off(void)
24999 {
25000 if (pm_power_off) {
25001 if (!reboot_force)
25002 @@ -601,9 +628,10 @@ static void native_machine_power_off(void)
25003 }
25004 /* A fallback in case there is no PM info available */
25005 tboot_shutdown(TB_SHUTDOWN_HALT);
25006 + unreachable();
25007 }
25008
25009 -struct machine_ops machine_ops = {
25010 +struct machine_ops machine_ops __read_only = {
25011 .power_off = native_machine_power_off,
25012 .shutdown = native_machine_shutdown,
25013 .emergency_restart = native_machine_emergency_restart,
25014 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25015 index c8e41e9..64049ef 100644
25016 --- a/arch/x86/kernel/reboot_fixups_32.c
25017 +++ b/arch/x86/kernel/reboot_fixups_32.c
25018 @@ -57,7 +57,7 @@ struct device_fixup {
25019 unsigned int vendor;
25020 unsigned int device;
25021 void (*reboot_fixup)(struct pci_dev *);
25022 -};
25023 +} __do_const;
25024
25025 /*
25026 * PCI ids solely used for fixups_table go here
25027 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25028 index 3fd2c69..16ef367 100644
25029 --- a/arch/x86/kernel/relocate_kernel_64.S
25030 +++ b/arch/x86/kernel/relocate_kernel_64.S
25031 @@ -11,6 +11,7 @@
25032 #include <asm/kexec.h>
25033 #include <asm/processor-flags.h>
25034 #include <asm/pgtable_types.h>
25035 +#include <asm/alternative-asm.h>
25036
25037 /*
25038 * Must be relocatable PIC code callable as a C function
25039 @@ -96,8 +97,7 @@ relocate_kernel:
25040
25041 /* jump to identity mapped page */
25042 addq $(identity_mapped - relocate_kernel), %r8
25043 - pushq %r8
25044 - ret
25045 + jmp *%r8
25046
25047 identity_mapped:
25048 /* set return address to 0 if not preserving context */
25049 @@ -167,6 +167,7 @@ identity_mapped:
25050 xorl %r14d, %r14d
25051 xorl %r15d, %r15d
25052
25053 + pax_force_retaddr 0, 1
25054 ret
25055
25056 1:
25057 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25058 index 234e1e3..01cd64d 100644
25059 --- a/arch/x86/kernel/setup.c
25060 +++ b/arch/x86/kernel/setup.c
25061 @@ -110,6 +110,7 @@
25062 #include <asm/mce.h>
25063 #include <asm/alternative.h>
25064 #include <asm/prom.h>
25065 +#include <asm/boot.h>
25066
25067 /*
25068 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25069 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25070 #endif
25071
25072
25073 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25074 -unsigned long mmu_cr4_features;
25075 +#ifdef CONFIG_X86_64
25076 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25077 +#elif defined(CONFIG_X86_PAE)
25078 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25079 #else
25080 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25081 +unsigned long mmu_cr4_features __read_only;
25082 #endif
25083
25084 +void set_in_cr4(unsigned long mask)
25085 +{
25086 + unsigned long cr4 = read_cr4();
25087 +
25088 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25089 + return;
25090 +
25091 + pax_open_kernel();
25092 + mmu_cr4_features |= mask;
25093 + pax_close_kernel();
25094 +
25095 + if (trampoline_cr4_features)
25096 + *trampoline_cr4_features = mmu_cr4_features;
25097 + cr4 |= mask;
25098 + write_cr4(cr4);
25099 +}
25100 +EXPORT_SYMBOL(set_in_cr4);
25101 +
25102 +void clear_in_cr4(unsigned long mask)
25103 +{
25104 + unsigned long cr4 = read_cr4();
25105 +
25106 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25107 + return;
25108 +
25109 + pax_open_kernel();
25110 + mmu_cr4_features &= ~mask;
25111 + pax_close_kernel();
25112 +
25113 + if (trampoline_cr4_features)
25114 + *trampoline_cr4_features = mmu_cr4_features;
25115 + cr4 &= ~mask;
25116 + write_cr4(cr4);
25117 +}
25118 +EXPORT_SYMBOL(clear_in_cr4);
25119 +
25120 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25121 int bootloader_type, bootloader_version;
25122
25123 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25124 * area (640->1Mb) as ram even though it is not.
25125 * take them out.
25126 */
25127 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25128 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25129
25130 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25131 }
25132 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25133 /* called before trim_bios_range() to spare extra sanitize */
25134 static void __init e820_add_kernel_range(void)
25135 {
25136 - u64 start = __pa_symbol(_text);
25137 + u64 start = __pa_symbol(ktla_ktva(_text));
25138 u64 size = __pa_symbol(_end) - start;
25139
25140 /*
25141 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25142
25143 void __init setup_arch(char **cmdline_p)
25144 {
25145 +#ifdef CONFIG_X86_32
25146 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25147 +#else
25148 memblock_reserve(__pa_symbol(_text),
25149 (unsigned long)__bss_stop - (unsigned long)_text);
25150 +#endif
25151
25152 early_reserve_initrd();
25153
25154 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25155
25156 if (!boot_params.hdr.root_flags)
25157 root_mountflags &= ~MS_RDONLY;
25158 - init_mm.start_code = (unsigned long) _text;
25159 - init_mm.end_code = (unsigned long) _etext;
25160 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25161 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25162 init_mm.end_data = (unsigned long) _edata;
25163 init_mm.brk = _brk_end;
25164
25165 - code_resource.start = __pa_symbol(_text);
25166 - code_resource.end = __pa_symbol(_etext)-1;
25167 - data_resource.start = __pa_symbol(_etext);
25168 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25169 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25170 + data_resource.start = __pa_symbol(_sdata);
25171 data_resource.end = __pa_symbol(_edata)-1;
25172 bss_resource.start = __pa_symbol(__bss_start);
25173 bss_resource.end = __pa_symbol(__bss_stop)-1;
25174 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25175 index 5cdff03..80fa283 100644
25176 --- a/arch/x86/kernel/setup_percpu.c
25177 +++ b/arch/x86/kernel/setup_percpu.c
25178 @@ -21,19 +21,17 @@
25179 #include <asm/cpu.h>
25180 #include <asm/stackprotector.h>
25181
25182 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25183 +#ifdef CONFIG_SMP
25184 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25185 EXPORT_PER_CPU_SYMBOL(cpu_number);
25186 +#endif
25187
25188 -#ifdef CONFIG_X86_64
25189 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25190 -#else
25191 -#define BOOT_PERCPU_OFFSET 0
25192 -#endif
25193
25194 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25195 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25196
25197 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25198 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25199 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25200 };
25201 EXPORT_SYMBOL(__per_cpu_offset);
25202 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25203 {
25204 #ifdef CONFIG_NEED_MULTIPLE_NODES
25205 pg_data_t *last = NULL;
25206 - unsigned int cpu;
25207 + int cpu;
25208
25209 for_each_possible_cpu(cpu) {
25210 int node = early_cpu_to_node(cpu);
25211 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25212 {
25213 #ifdef CONFIG_X86_32
25214 struct desc_struct gdt;
25215 + unsigned long base = per_cpu_offset(cpu);
25216
25217 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25218 - 0x2 | DESCTYPE_S, 0x8);
25219 - gdt.s = 1;
25220 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25221 + 0x83 | DESCTYPE_S, 0xC);
25222 write_gdt_entry(get_cpu_gdt_table(cpu),
25223 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25224 #endif
25225 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25226 /* alrighty, percpu areas up and running */
25227 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25228 for_each_possible_cpu(cpu) {
25229 +#ifdef CONFIG_CC_STACKPROTECTOR
25230 +#ifdef CONFIG_X86_32
25231 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25232 +#endif
25233 +#endif
25234 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25235 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25236 per_cpu(cpu_number, cpu) = cpu;
25237 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25238 */
25239 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25240 #endif
25241 +#ifdef CONFIG_CC_STACKPROTECTOR
25242 +#ifdef CONFIG_X86_32
25243 + if (!cpu)
25244 + per_cpu(stack_canary.canary, cpu) = canary;
25245 +#endif
25246 +#endif
25247 /*
25248 * Up to this point, the boot CPU has been using .init.data
25249 * area. Reload any changed state for the boot CPU.
25250 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25251 index d859eea..44e17c4 100644
25252 --- a/arch/x86/kernel/signal.c
25253 +++ b/arch/x86/kernel/signal.c
25254 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25255 * Align the stack pointer according to the i386 ABI,
25256 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25257 */
25258 - sp = ((sp + 4) & -16ul) - 4;
25259 + sp = ((sp - 12) & -16ul) - 4;
25260 #else /* !CONFIG_X86_32 */
25261 sp = round_down(sp, 16) - 8;
25262 #endif
25263 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25264 }
25265
25266 if (current->mm->context.vdso)
25267 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25268 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25269 else
25270 - restorer = &frame->retcode;
25271 + restorer = (void __user *)&frame->retcode;
25272 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25273 restorer = ksig->ka.sa.sa_restorer;
25274
25275 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25276 * reasons and because gdb uses it as a signature to notice
25277 * signal handler stack frames.
25278 */
25279 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25280 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25281
25282 if (err)
25283 return -EFAULT;
25284 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25285 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25286
25287 /* Set up to return from userspace. */
25288 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25289 + if (current->mm->context.vdso)
25290 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25291 + else
25292 + restorer = (void __user *)&frame->retcode;
25293 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25294 restorer = ksig->ka.sa.sa_restorer;
25295 put_user_ex(restorer, &frame->pretcode);
25296 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25297 * reasons and because gdb uses it as a signature to notice
25298 * signal handler stack frames.
25299 */
25300 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25301 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25302 } put_user_catch(err);
25303
25304 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25305 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25306 {
25307 int usig = signr_convert(ksig->sig);
25308 sigset_t *set = sigmask_to_save();
25309 - compat_sigset_t *cset = (compat_sigset_t *) set;
25310 + sigset_t sigcopy;
25311 + compat_sigset_t *cset;
25312 +
25313 + sigcopy = *set;
25314 +
25315 + cset = (compat_sigset_t *) &sigcopy;
25316
25317 /* Set up the stack frame */
25318 if (is_ia32_frame()) {
25319 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25320 } else if (is_x32_frame()) {
25321 return x32_setup_rt_frame(ksig, cset, regs);
25322 } else {
25323 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25324 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25325 }
25326 }
25327
25328 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25329 index cdaa347..f5af55d 100644
25330 --- a/arch/x86/kernel/smp.c
25331 +++ b/arch/x86/kernel/smp.c
25332 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25333
25334 __setup("nonmi_ipi", nonmi_ipi_setup);
25335
25336 -struct smp_ops smp_ops = {
25337 +struct smp_ops smp_ops __read_only = {
25338 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25339 .smp_prepare_cpus = native_smp_prepare_cpus,
25340 .smp_cpus_done = native_smp_cpus_done,
25341 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25342 index aecc98a..0244a53 100644
25343 --- a/arch/x86/kernel/smpboot.c
25344 +++ b/arch/x86/kernel/smpboot.c
25345 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25346
25347 enable_start_cpu0 = 0;
25348
25349 -#ifdef CONFIG_X86_32
25350 - /* switch away from the initial page table */
25351 - load_cr3(swapper_pg_dir);
25352 - __flush_tlb_all();
25353 -#endif
25354 -
25355 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25356 barrier();
25357 +
25358 + /* switch away from the initial page table */
25359 +#ifdef CONFIG_PAX_PER_CPU_PGD
25360 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25361 + __flush_tlb_all();
25362 +#elif defined(CONFIG_X86_32)
25363 + load_cr3(swapper_pg_dir);
25364 + __flush_tlb_all();
25365 +#endif
25366 +
25367 /*
25368 * Check TSC synchronization with the BP:
25369 */
25370 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25371 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25372 (THREAD_SIZE + task_stack_page(idle))) - 1);
25373 per_cpu(current_task, cpu) = idle;
25374 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25375
25376 #ifdef CONFIG_X86_32
25377 /* Stack for startup_32 can be just as for start_secondary onwards */
25378 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25379 #else
25380 clear_tsk_thread_flag(idle, TIF_FORK);
25381 initial_gs = per_cpu_offset(cpu);
25382 - per_cpu(kernel_stack, cpu) =
25383 - (unsigned long)task_stack_page(idle) -
25384 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25385 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25386 #endif
25387 +
25388 + pax_open_kernel();
25389 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25390 + pax_close_kernel();
25391 +
25392 initial_code = (unsigned long)start_secondary;
25393 stack_start = idle->thread.sp;
25394
25395 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25396 /* the FPU context is blank, nobody can own it */
25397 __cpu_disable_lazy_restore(cpu);
25398
25399 +#ifdef CONFIG_PAX_PER_CPU_PGD
25400 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25401 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25402 + KERNEL_PGD_PTRS);
25403 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25404 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25405 + KERNEL_PGD_PTRS);
25406 +#endif
25407 +
25408 err = do_boot_cpu(apicid, cpu, tidle);
25409 if (err) {
25410 pr_debug("do_boot_cpu failed %d\n", err);
25411 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25412 index 9b4d51d..5d28b58 100644
25413 --- a/arch/x86/kernel/step.c
25414 +++ b/arch/x86/kernel/step.c
25415 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25416 struct desc_struct *desc;
25417 unsigned long base;
25418
25419 - seg &= ~7UL;
25420 + seg >>= 3;
25421
25422 mutex_lock(&child->mm->context.lock);
25423 - if (unlikely((seg >> 3) >= child->mm->context.size))
25424 + if (unlikely(seg >= child->mm->context.size))
25425 addr = -1L; /* bogus selector, access would fault */
25426 else {
25427 desc = child->mm->context.ldt + seg;
25428 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25429 addr += base;
25430 }
25431 mutex_unlock(&child->mm->context.lock);
25432 - }
25433 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25434 + addr = ktla_ktva(addr);
25435
25436 return addr;
25437 }
25438 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25439 unsigned char opcode[15];
25440 unsigned long addr = convert_ip_to_linear(child, regs);
25441
25442 + if (addr == -EINVAL)
25443 + return 0;
25444 +
25445 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25446 for (i = 0; i < copied; i++) {
25447 switch (opcode[i]) {
25448 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25449 new file mode 100644
25450 index 0000000..5877189
25451 --- /dev/null
25452 +++ b/arch/x86/kernel/sys_i386_32.c
25453 @@ -0,0 +1,189 @@
25454 +/*
25455 + * This file contains various random system calls that
25456 + * have a non-standard calling sequence on the Linux/i386
25457 + * platform.
25458 + */
25459 +
25460 +#include <linux/errno.h>
25461 +#include <linux/sched.h>
25462 +#include <linux/mm.h>
25463 +#include <linux/fs.h>
25464 +#include <linux/smp.h>
25465 +#include <linux/sem.h>
25466 +#include <linux/msg.h>
25467 +#include <linux/shm.h>
25468 +#include <linux/stat.h>
25469 +#include <linux/syscalls.h>
25470 +#include <linux/mman.h>
25471 +#include <linux/file.h>
25472 +#include <linux/utsname.h>
25473 +#include <linux/ipc.h>
25474 +#include <linux/elf.h>
25475 +
25476 +#include <linux/uaccess.h>
25477 +#include <linux/unistd.h>
25478 +
25479 +#include <asm/syscalls.h>
25480 +
25481 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25482 +{
25483 + unsigned long pax_task_size = TASK_SIZE;
25484 +
25485 +#ifdef CONFIG_PAX_SEGMEXEC
25486 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25487 + pax_task_size = SEGMEXEC_TASK_SIZE;
25488 +#endif
25489 +
25490 + if (flags & MAP_FIXED)
25491 + if (len > pax_task_size || addr > pax_task_size - len)
25492 + return -EINVAL;
25493 +
25494 + return 0;
25495 +}
25496 +
25497 +/*
25498 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25499 + */
25500 +static unsigned long get_align_mask(void)
25501 +{
25502 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25503 + return 0;
25504 +
25505 + if (!(current->flags & PF_RANDOMIZE))
25506 + return 0;
25507 +
25508 + return va_align.mask;
25509 +}
25510 +
25511 +unsigned long
25512 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25513 + unsigned long len, unsigned long pgoff, unsigned long flags)
25514 +{
25515 + struct mm_struct *mm = current->mm;
25516 + struct vm_area_struct *vma;
25517 + unsigned long pax_task_size = TASK_SIZE;
25518 + struct vm_unmapped_area_info info;
25519 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25520 +
25521 +#ifdef CONFIG_PAX_SEGMEXEC
25522 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25523 + pax_task_size = SEGMEXEC_TASK_SIZE;
25524 +#endif
25525 +
25526 + pax_task_size -= PAGE_SIZE;
25527 +
25528 + if (len > pax_task_size)
25529 + return -ENOMEM;
25530 +
25531 + if (flags & MAP_FIXED)
25532 + return addr;
25533 +
25534 +#ifdef CONFIG_PAX_RANDMMAP
25535 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25536 +#endif
25537 +
25538 + if (addr) {
25539 + addr = PAGE_ALIGN(addr);
25540 + if (pax_task_size - len >= addr) {
25541 + vma = find_vma(mm, addr);
25542 + if (check_heap_stack_gap(vma, addr, len, offset))
25543 + return addr;
25544 + }
25545 + }
25546 +
25547 + info.flags = 0;
25548 + info.length = len;
25549 + info.align_mask = filp ? get_align_mask() : 0;
25550 + info.align_offset = pgoff << PAGE_SHIFT;
25551 + info.threadstack_offset = offset;
25552 +
25553 +#ifdef CONFIG_PAX_PAGEEXEC
25554 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25555 + info.low_limit = 0x00110000UL;
25556 + info.high_limit = mm->start_code;
25557 +
25558 +#ifdef CONFIG_PAX_RANDMMAP
25559 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25560 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25561 +#endif
25562 +
25563 + if (info.low_limit < info.high_limit) {
25564 + addr = vm_unmapped_area(&info);
25565 + if (!IS_ERR_VALUE(addr))
25566 + return addr;
25567 + }
25568 + } else
25569 +#endif
25570 +
25571 + info.low_limit = mm->mmap_base;
25572 + info.high_limit = pax_task_size;
25573 +
25574 + return vm_unmapped_area(&info);
25575 +}
25576 +
25577 +unsigned long
25578 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25579 + const unsigned long len, const unsigned long pgoff,
25580 + const unsigned long flags)
25581 +{
25582 + struct vm_area_struct *vma;
25583 + struct mm_struct *mm = current->mm;
25584 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25585 + struct vm_unmapped_area_info info;
25586 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25587 +
25588 +#ifdef CONFIG_PAX_SEGMEXEC
25589 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25590 + pax_task_size = SEGMEXEC_TASK_SIZE;
25591 +#endif
25592 +
25593 + pax_task_size -= PAGE_SIZE;
25594 +
25595 + /* requested length too big for entire address space */
25596 + if (len > pax_task_size)
25597 + return -ENOMEM;
25598 +
25599 + if (flags & MAP_FIXED)
25600 + return addr;
25601 +
25602 +#ifdef CONFIG_PAX_PAGEEXEC
25603 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25604 + goto bottomup;
25605 +#endif
25606 +
25607 +#ifdef CONFIG_PAX_RANDMMAP
25608 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25609 +#endif
25610 +
25611 + /* requesting a specific address */
25612 + if (addr) {
25613 + addr = PAGE_ALIGN(addr);
25614 + if (pax_task_size - len >= addr) {
25615 + vma = find_vma(mm, addr);
25616 + if (check_heap_stack_gap(vma, addr, len, offset))
25617 + return addr;
25618 + }
25619 + }
25620 +
25621 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25622 + info.length = len;
25623 + info.low_limit = PAGE_SIZE;
25624 + info.high_limit = mm->mmap_base;
25625 + info.align_mask = filp ? get_align_mask() : 0;
25626 + info.align_offset = pgoff << PAGE_SHIFT;
25627 + info.threadstack_offset = offset;
25628 +
25629 + addr = vm_unmapped_area(&info);
25630 + if (!(addr & ~PAGE_MASK))
25631 + return addr;
25632 + VM_BUG_ON(addr != -ENOMEM);
25633 +
25634 +bottomup:
25635 + /*
25636 + * A failed mmap() very likely causes application failure,
25637 + * so fall back to the bottom-up function here. This scenario
25638 + * can happen with large stack limits and large mmap()
25639 + * allocations.
25640 + */
25641 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25642 +}
25643 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25644 index 30277e2..5664a29 100644
25645 --- a/arch/x86/kernel/sys_x86_64.c
25646 +++ b/arch/x86/kernel/sys_x86_64.c
25647 @@ -81,8 +81,8 @@ out:
25648 return error;
25649 }
25650
25651 -static void find_start_end(unsigned long flags, unsigned long *begin,
25652 - unsigned long *end)
25653 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25654 + unsigned long *begin, unsigned long *end)
25655 {
25656 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25657 unsigned long new_begin;
25658 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25659 *begin = new_begin;
25660 }
25661 } else {
25662 - *begin = current->mm->mmap_legacy_base;
25663 + *begin = mm->mmap_legacy_base;
25664 *end = TASK_SIZE;
25665 }
25666 }
25667 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25668 struct vm_area_struct *vma;
25669 struct vm_unmapped_area_info info;
25670 unsigned long begin, end;
25671 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25672
25673 if (flags & MAP_FIXED)
25674 return addr;
25675
25676 - find_start_end(flags, &begin, &end);
25677 + find_start_end(mm, flags, &begin, &end);
25678
25679 if (len > end)
25680 return -ENOMEM;
25681
25682 +#ifdef CONFIG_PAX_RANDMMAP
25683 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25684 +#endif
25685 +
25686 if (addr) {
25687 addr = PAGE_ALIGN(addr);
25688 vma = find_vma(mm, addr);
25689 - if (end - len >= addr &&
25690 - (!vma || addr + len <= vma->vm_start))
25691 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25692 return addr;
25693 }
25694
25695 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25696 info.high_limit = end;
25697 info.align_mask = filp ? get_align_mask() : 0;
25698 info.align_offset = pgoff << PAGE_SHIFT;
25699 + info.threadstack_offset = offset;
25700 return vm_unmapped_area(&info);
25701 }
25702
25703 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25704 struct mm_struct *mm = current->mm;
25705 unsigned long addr = addr0;
25706 struct vm_unmapped_area_info info;
25707 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25708
25709 /* requested length too big for entire address space */
25710 if (len > TASK_SIZE)
25711 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25712 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25713 goto bottomup;
25714
25715 +#ifdef CONFIG_PAX_RANDMMAP
25716 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25717 +#endif
25718 +
25719 /* requesting a specific address */
25720 if (addr) {
25721 addr = PAGE_ALIGN(addr);
25722 vma = find_vma(mm, addr);
25723 - if (TASK_SIZE - len >= addr &&
25724 - (!vma || addr + len <= vma->vm_start))
25725 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25726 return addr;
25727 }
25728
25729 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25730 info.high_limit = mm->mmap_base;
25731 info.align_mask = filp ? get_align_mask() : 0;
25732 info.align_offset = pgoff << PAGE_SHIFT;
25733 + info.threadstack_offset = offset;
25734 addr = vm_unmapped_area(&info);
25735 if (!(addr & ~PAGE_MASK))
25736 return addr;
25737 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25738 index addf7b5..f960685 100644
25739 --- a/arch/x86/kernel/tboot.c
25740 +++ b/arch/x86/kernel/tboot.c
25741 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25742
25743 void tboot_shutdown(u32 shutdown_type)
25744 {
25745 - void (*shutdown)(void);
25746 + void (* __noreturn shutdown)(void);
25747
25748 if (!tboot_enabled())
25749 return;
25750 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25751
25752 switch_to_tboot_pt();
25753
25754 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25755 + shutdown = (void *)tboot->shutdown_entry;
25756 shutdown();
25757
25758 /* should not reach here */
25759 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25760 return 0;
25761 }
25762
25763 -static atomic_t ap_wfs_count;
25764 +static atomic_unchecked_t ap_wfs_count;
25765
25766 static int tboot_wait_for_aps(int num_aps)
25767 {
25768 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25769 {
25770 switch (action) {
25771 case CPU_DYING:
25772 - atomic_inc(&ap_wfs_count);
25773 + atomic_inc_unchecked(&ap_wfs_count);
25774 if (num_online_cpus() == 1)
25775 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25776 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25777 return NOTIFY_BAD;
25778 break;
25779 }
25780 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25781
25782 tboot_create_trampoline();
25783
25784 - atomic_set(&ap_wfs_count, 0);
25785 + atomic_set_unchecked(&ap_wfs_count, 0);
25786 register_hotcpu_notifier(&tboot_cpu_notifier);
25787
25788 #ifdef CONFIG_DEBUG_FS
25789 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25790 index 24d3c91..d06b473 100644
25791 --- a/arch/x86/kernel/time.c
25792 +++ b/arch/x86/kernel/time.c
25793 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25794 {
25795 unsigned long pc = instruction_pointer(regs);
25796
25797 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25798 + if (!user_mode(regs) && in_lock_functions(pc)) {
25799 #ifdef CONFIG_FRAME_POINTER
25800 - return *(unsigned long *)(regs->bp + sizeof(long));
25801 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25802 #else
25803 unsigned long *sp =
25804 (unsigned long *)kernel_stack_pointer(regs);
25805 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25806 * or above a saved flags. Eflags has bits 22-31 zero,
25807 * kernel addresses don't.
25808 */
25809 +
25810 +#ifdef CONFIG_PAX_KERNEXEC
25811 + return ktla_ktva(sp[0]);
25812 +#else
25813 if (sp[0] >> 22)
25814 return sp[0];
25815 if (sp[1] >> 22)
25816 return sp[1];
25817 #endif
25818 +
25819 +#endif
25820 }
25821 return pc;
25822 }
25823 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25824 index f7fec09..9991981 100644
25825 --- a/arch/x86/kernel/tls.c
25826 +++ b/arch/x86/kernel/tls.c
25827 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25828 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25829 return -EINVAL;
25830
25831 +#ifdef CONFIG_PAX_SEGMEXEC
25832 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25833 + return -EINVAL;
25834 +#endif
25835 +
25836 set_tls_desc(p, idx, &info, 1);
25837
25838 return 0;
25839 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25840
25841 if (kbuf)
25842 info = kbuf;
25843 - else if (__copy_from_user(infobuf, ubuf, count))
25844 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25845 return -EFAULT;
25846 else
25847 info = infobuf;
25848 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25849 index 1c113db..287b42e 100644
25850 --- a/arch/x86/kernel/tracepoint.c
25851 +++ b/arch/x86/kernel/tracepoint.c
25852 @@ -9,11 +9,11 @@
25853 #include <linux/atomic.h>
25854
25855 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25856 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25857 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25858 (unsigned long) trace_idt_table };
25859
25860 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25861 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25862 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25863
25864 static int trace_irq_vector_refcount;
25865 static DEFINE_MUTEX(irq_vector_mutex);
25866 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25867 index 1b23a1c..910de0d 100644
25868 --- a/arch/x86/kernel/traps.c
25869 +++ b/arch/x86/kernel/traps.c
25870 @@ -65,7 +65,7 @@
25871 #include <asm/proto.h>
25872
25873 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25874 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25875 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25876 #else
25877 #include <asm/processor-flags.h>
25878 #include <asm/setup.h>
25879 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25880 #endif
25881
25882 /* Must be page-aligned because the real IDT is used in a fixmap. */
25883 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25884 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25885
25886 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25887 EXPORT_SYMBOL_GPL(used_vectors);
25888 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25889 }
25890
25891 static int __kprobes
25892 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25893 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25894 struct pt_regs *regs, long error_code)
25895 {
25896 #ifdef CONFIG_X86_32
25897 - if (regs->flags & X86_VM_MASK) {
25898 + if (v8086_mode(regs)) {
25899 /*
25900 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25901 * On nmi (interrupt 2), do_trap should not be called.
25902 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25903 return -1;
25904 }
25905 #endif
25906 - if (!user_mode(regs)) {
25907 + if (!user_mode_novm(regs)) {
25908 if (!fixup_exception(regs)) {
25909 tsk->thread.error_code = error_code;
25910 tsk->thread.trap_nr = trapnr;
25911 +
25912 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25913 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25914 + str = "PAX: suspicious stack segment fault";
25915 +#endif
25916 +
25917 die(str, regs, error_code);
25918 }
25919 +
25920 +#ifdef CONFIG_PAX_REFCOUNT
25921 + if (trapnr == 4)
25922 + pax_report_refcount_overflow(regs);
25923 +#endif
25924 +
25925 return 0;
25926 }
25927
25928 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25929 }
25930
25931 static void __kprobes
25932 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25933 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25934 long error_code, siginfo_t *info)
25935 {
25936 struct task_struct *tsk = current;
25937 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25938 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25939 printk_ratelimit()) {
25940 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25941 - tsk->comm, tsk->pid, str,
25942 + tsk->comm, task_pid_nr(tsk), str,
25943 regs->ip, regs->sp, error_code);
25944 print_vma_addr(" in ", regs->ip);
25945 pr_cont("\n");
25946 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25947 conditional_sti(regs);
25948
25949 #ifdef CONFIG_X86_32
25950 - if (regs->flags & X86_VM_MASK) {
25951 + if (v8086_mode(regs)) {
25952 local_irq_enable();
25953 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25954 goto exit;
25955 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25956 #endif
25957
25958 tsk = current;
25959 - if (!user_mode(regs)) {
25960 + if (!user_mode_novm(regs)) {
25961 if (fixup_exception(regs))
25962 goto exit;
25963
25964 tsk->thread.error_code = error_code;
25965 tsk->thread.trap_nr = X86_TRAP_GP;
25966 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25967 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25968 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25969 +
25970 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25971 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25972 + die("PAX: suspicious general protection fault", regs, error_code);
25973 + else
25974 +#endif
25975 +
25976 die("general protection fault", regs, error_code);
25977 + }
25978 goto exit;
25979 }
25980
25981 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25982 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25983 + struct mm_struct *mm = tsk->mm;
25984 + unsigned long limit;
25985 +
25986 + down_write(&mm->mmap_sem);
25987 + limit = mm->context.user_cs_limit;
25988 + if (limit < TASK_SIZE) {
25989 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25990 + up_write(&mm->mmap_sem);
25991 + return;
25992 + }
25993 + up_write(&mm->mmap_sem);
25994 + }
25995 +#endif
25996 +
25997 tsk->thread.error_code = error_code;
25998 tsk->thread.trap_nr = X86_TRAP_GP;
25999
26000 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26001 /* It's safe to allow irq's after DR6 has been saved */
26002 preempt_conditional_sti(regs);
26003
26004 - if (regs->flags & X86_VM_MASK) {
26005 + if (v8086_mode(regs)) {
26006 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26007 X86_TRAP_DB);
26008 preempt_conditional_cli(regs);
26009 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26010 * We already checked v86 mode above, so we can check for kernel mode
26011 * by just checking the CPL of CS.
26012 */
26013 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26014 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26015 tsk->thread.debugreg6 &= ~DR_STEP;
26016 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26017 regs->flags &= ~X86_EFLAGS_TF;
26018 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26019 return;
26020 conditional_sti(regs);
26021
26022 - if (!user_mode_vm(regs))
26023 + if (!user_mode(regs))
26024 {
26025 if (!fixup_exception(regs)) {
26026 task->thread.error_code = error_code;
26027 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26028 index 2ed8459..7cf329f 100644
26029 --- a/arch/x86/kernel/uprobes.c
26030 +++ b/arch/x86/kernel/uprobes.c
26031 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26032 int ret = NOTIFY_DONE;
26033
26034 /* We are only interested in userspace traps */
26035 - if (regs && !user_mode_vm(regs))
26036 + if (regs && !user_mode(regs))
26037 return NOTIFY_DONE;
26038
26039 switch (val) {
26040 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26041
26042 if (ncopied != rasize) {
26043 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26044 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26045 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26046
26047 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26048 }
26049 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26050 index b9242ba..50c5edd 100644
26051 --- a/arch/x86/kernel/verify_cpu.S
26052 +++ b/arch/x86/kernel/verify_cpu.S
26053 @@ -20,6 +20,7 @@
26054 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26055 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26056 * arch/x86/kernel/head_32.S: processor startup
26057 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26058 *
26059 * verify_cpu, returns the status of longmode and SSE in register %eax.
26060 * 0: Success 1: Failure
26061 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26062 index e8edcf5..27f9344 100644
26063 --- a/arch/x86/kernel/vm86_32.c
26064 +++ b/arch/x86/kernel/vm86_32.c
26065 @@ -44,6 +44,7 @@
26066 #include <linux/ptrace.h>
26067 #include <linux/audit.h>
26068 #include <linux/stddef.h>
26069 +#include <linux/grsecurity.h>
26070
26071 #include <asm/uaccess.h>
26072 #include <asm/io.h>
26073 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26074 do_exit(SIGSEGV);
26075 }
26076
26077 - tss = &per_cpu(init_tss, get_cpu());
26078 + tss = init_tss + get_cpu();
26079 current->thread.sp0 = current->thread.saved_sp0;
26080 current->thread.sysenter_cs = __KERNEL_CS;
26081 load_sp0(tss, &current->thread);
26082 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26083
26084 if (tsk->thread.saved_sp0)
26085 return -EPERM;
26086 +
26087 +#ifdef CONFIG_GRKERNSEC_VM86
26088 + if (!capable(CAP_SYS_RAWIO)) {
26089 + gr_handle_vm86();
26090 + return -EPERM;
26091 + }
26092 +#endif
26093 +
26094 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26095 offsetof(struct kernel_vm86_struct, vm86plus) -
26096 sizeof(info.regs));
26097 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26098 int tmp;
26099 struct vm86plus_struct __user *v86;
26100
26101 +#ifdef CONFIG_GRKERNSEC_VM86
26102 + if (!capable(CAP_SYS_RAWIO)) {
26103 + gr_handle_vm86();
26104 + return -EPERM;
26105 + }
26106 +#endif
26107 +
26108 tsk = current;
26109 switch (cmd) {
26110 case VM86_REQUEST_IRQ:
26111 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26112 tsk->thread.saved_fs = info->regs32->fs;
26113 tsk->thread.saved_gs = get_user_gs(info->regs32);
26114
26115 - tss = &per_cpu(init_tss, get_cpu());
26116 + tss = init_tss + get_cpu();
26117 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26118 if (cpu_has_sep)
26119 tsk->thread.sysenter_cs = 0;
26120 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26121 goto cannot_handle;
26122 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26123 goto cannot_handle;
26124 - intr_ptr = (unsigned long __user *) (i << 2);
26125 + intr_ptr = (__force unsigned long __user *) (i << 2);
26126 if (get_user(segoffs, intr_ptr))
26127 goto cannot_handle;
26128 if ((segoffs >> 16) == BIOSSEG)
26129 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26130 index 10c4f30..65408b9 100644
26131 --- a/arch/x86/kernel/vmlinux.lds.S
26132 +++ b/arch/x86/kernel/vmlinux.lds.S
26133 @@ -26,6 +26,13 @@
26134 #include <asm/page_types.h>
26135 #include <asm/cache.h>
26136 #include <asm/boot.h>
26137 +#include <asm/segment.h>
26138 +
26139 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26140 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26141 +#else
26142 +#define __KERNEL_TEXT_OFFSET 0
26143 +#endif
26144
26145 #undef i386 /* in case the preprocessor is a 32bit one */
26146
26147 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26148
26149 PHDRS {
26150 text PT_LOAD FLAGS(5); /* R_E */
26151 +#ifdef CONFIG_X86_32
26152 + module PT_LOAD FLAGS(5); /* R_E */
26153 +#endif
26154 +#ifdef CONFIG_XEN
26155 + rodata PT_LOAD FLAGS(5); /* R_E */
26156 +#else
26157 + rodata PT_LOAD FLAGS(4); /* R__ */
26158 +#endif
26159 data PT_LOAD FLAGS(6); /* RW_ */
26160 -#ifdef CONFIG_X86_64
26161 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26162 #ifdef CONFIG_SMP
26163 percpu PT_LOAD FLAGS(6); /* RW_ */
26164 #endif
26165 + text.init PT_LOAD FLAGS(5); /* R_E */
26166 + text.exit PT_LOAD FLAGS(5); /* R_E */
26167 init PT_LOAD FLAGS(7); /* RWE */
26168 -#endif
26169 note PT_NOTE FLAGS(0); /* ___ */
26170 }
26171
26172 SECTIONS
26173 {
26174 #ifdef CONFIG_X86_32
26175 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26176 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26177 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26178 #else
26179 - . = __START_KERNEL;
26180 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26181 + . = __START_KERNEL;
26182 #endif
26183
26184 /* Text and read-only data */
26185 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26186 - _text = .;
26187 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26188 /* bootstrapping code */
26189 +#ifdef CONFIG_X86_32
26190 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26191 +#else
26192 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26193 +#endif
26194 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26195 + _text = .;
26196 HEAD_TEXT
26197 . = ALIGN(8);
26198 _stext = .;
26199 @@ -104,13 +124,47 @@ SECTIONS
26200 IRQENTRY_TEXT
26201 *(.fixup)
26202 *(.gnu.warning)
26203 - /* End of text section */
26204 - _etext = .;
26205 } :text = 0x9090
26206
26207 - NOTES :text :note
26208 + . += __KERNEL_TEXT_OFFSET;
26209
26210 - EXCEPTION_TABLE(16) :text = 0x9090
26211 +#ifdef CONFIG_X86_32
26212 + . = ALIGN(PAGE_SIZE);
26213 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26214 +
26215 +#ifdef CONFIG_PAX_KERNEXEC
26216 + MODULES_EXEC_VADDR = .;
26217 + BYTE(0)
26218 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26219 + . = ALIGN(HPAGE_SIZE) - 1;
26220 + MODULES_EXEC_END = .;
26221 +#endif
26222 +
26223 + } :module
26224 +#endif
26225 +
26226 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26227 + /* End of text section */
26228 + BYTE(0)
26229 + _etext = . - __KERNEL_TEXT_OFFSET;
26230 + }
26231 +
26232 +#ifdef CONFIG_X86_32
26233 + . = ALIGN(PAGE_SIZE);
26234 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26235 + . = ALIGN(PAGE_SIZE);
26236 + *(.empty_zero_page)
26237 + *(.initial_pg_fixmap)
26238 + *(.initial_pg_pmd)
26239 + *(.initial_page_table)
26240 + *(.swapper_pg_dir)
26241 + } :rodata
26242 +#endif
26243 +
26244 + . = ALIGN(PAGE_SIZE);
26245 + NOTES :rodata :note
26246 +
26247 + EXCEPTION_TABLE(16) :rodata
26248
26249 #if defined(CONFIG_DEBUG_RODATA)
26250 /* .text should occupy whole number of pages */
26251 @@ -122,16 +176,20 @@ SECTIONS
26252
26253 /* Data */
26254 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26255 +
26256 +#ifdef CONFIG_PAX_KERNEXEC
26257 + . = ALIGN(HPAGE_SIZE);
26258 +#else
26259 + . = ALIGN(PAGE_SIZE);
26260 +#endif
26261 +
26262 /* Start of data section */
26263 _sdata = .;
26264
26265 /* init_task */
26266 INIT_TASK_DATA(THREAD_SIZE)
26267
26268 -#ifdef CONFIG_X86_32
26269 - /* 32 bit has nosave before _edata */
26270 NOSAVE_DATA
26271 -#endif
26272
26273 PAGE_ALIGNED_DATA(PAGE_SIZE)
26274
26275 @@ -172,12 +230,19 @@ SECTIONS
26276 #endif /* CONFIG_X86_64 */
26277
26278 /* Init code and data - will be freed after init */
26279 - . = ALIGN(PAGE_SIZE);
26280 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26281 + BYTE(0)
26282 +
26283 +#ifdef CONFIG_PAX_KERNEXEC
26284 + . = ALIGN(HPAGE_SIZE);
26285 +#else
26286 + . = ALIGN(PAGE_SIZE);
26287 +#endif
26288 +
26289 __init_begin = .; /* paired with __init_end */
26290 - }
26291 + } :init.begin
26292
26293 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26294 +#ifdef CONFIG_SMP
26295 /*
26296 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26297 * output PHDR, so the next output section - .init.text - should
26298 @@ -186,12 +251,27 @@ SECTIONS
26299 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26300 #endif
26301
26302 - INIT_TEXT_SECTION(PAGE_SIZE)
26303 -#ifdef CONFIG_X86_64
26304 - :init
26305 -#endif
26306 + . = ALIGN(PAGE_SIZE);
26307 + init_begin = .;
26308 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26309 + VMLINUX_SYMBOL(_sinittext) = .;
26310 + INIT_TEXT
26311 + VMLINUX_SYMBOL(_einittext) = .;
26312 + . = ALIGN(PAGE_SIZE);
26313 + } :text.init
26314
26315 - INIT_DATA_SECTION(16)
26316 + /*
26317 + * .exit.text is discard at runtime, not link time, to deal with
26318 + * references from .altinstructions and .eh_frame
26319 + */
26320 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26321 + EXIT_TEXT
26322 + . = ALIGN(16);
26323 + } :text.exit
26324 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26325 +
26326 + . = ALIGN(PAGE_SIZE);
26327 + INIT_DATA_SECTION(16) :init
26328
26329 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26330 __x86_cpu_dev_start = .;
26331 @@ -253,19 +333,12 @@ SECTIONS
26332 }
26333
26334 . = ALIGN(8);
26335 - /*
26336 - * .exit.text is discard at runtime, not link time, to deal with
26337 - * references from .altinstructions and .eh_frame
26338 - */
26339 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26340 - EXIT_TEXT
26341 - }
26342
26343 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26344 EXIT_DATA
26345 }
26346
26347 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26348 +#ifndef CONFIG_SMP
26349 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26350 #endif
26351
26352 @@ -284,16 +357,10 @@ SECTIONS
26353 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26354 __smp_locks = .;
26355 *(.smp_locks)
26356 - . = ALIGN(PAGE_SIZE);
26357 __smp_locks_end = .;
26358 + . = ALIGN(PAGE_SIZE);
26359 }
26360
26361 -#ifdef CONFIG_X86_64
26362 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26363 - NOSAVE_DATA
26364 - }
26365 -#endif
26366 -
26367 /* BSS */
26368 . = ALIGN(PAGE_SIZE);
26369 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26370 @@ -309,6 +376,7 @@ SECTIONS
26371 __brk_base = .;
26372 . += 64 * 1024; /* 64k alignment slop space */
26373 *(.brk_reservation) /* areas brk users have reserved */
26374 + . = ALIGN(HPAGE_SIZE);
26375 __brk_limit = .;
26376 }
26377
26378 @@ -335,13 +403,12 @@ SECTIONS
26379 * for the boot processor.
26380 */
26381 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26382 -INIT_PER_CPU(gdt_page);
26383 INIT_PER_CPU(irq_stack_union);
26384
26385 /*
26386 * Build-time check on the image size:
26387 */
26388 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26389 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26390 "kernel image bigger than KERNEL_IMAGE_SIZE");
26391
26392 #ifdef CONFIG_SMP
26393 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26394 index 1f96f93..d5c8f7a 100644
26395 --- a/arch/x86/kernel/vsyscall_64.c
26396 +++ b/arch/x86/kernel/vsyscall_64.c
26397 @@ -56,15 +56,13 @@
26398 DEFINE_VVAR(int, vgetcpu_mode);
26399 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26400
26401 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26402 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26403
26404 static int __init vsyscall_setup(char *str)
26405 {
26406 if (str) {
26407 if (!strcmp("emulate", str))
26408 vsyscall_mode = EMULATE;
26409 - else if (!strcmp("native", str))
26410 - vsyscall_mode = NATIVE;
26411 else if (!strcmp("none", str))
26412 vsyscall_mode = NONE;
26413 else
26414 @@ -323,8 +321,7 @@ do_ret:
26415 return true;
26416
26417 sigsegv:
26418 - force_sig(SIGSEGV, current);
26419 - return true;
26420 + do_group_exit(SIGKILL);
26421 }
26422
26423 /*
26424 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26425 extern char __vvar_page;
26426 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26427
26428 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26429 - vsyscall_mode == NATIVE
26430 - ? PAGE_KERNEL_VSYSCALL
26431 - : PAGE_KERNEL_VVAR);
26432 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26433 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26434 (unsigned long)VSYSCALL_START);
26435
26436 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26437 index b014d94..e775258 100644
26438 --- a/arch/x86/kernel/x8664_ksyms_64.c
26439 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26440 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26441 EXPORT_SYMBOL(copy_user_generic_unrolled);
26442 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26443 EXPORT_SYMBOL(__copy_user_nocache);
26444 -EXPORT_SYMBOL(_copy_from_user);
26445 -EXPORT_SYMBOL(_copy_to_user);
26446
26447 EXPORT_SYMBOL(copy_page);
26448 EXPORT_SYMBOL(clear_page);
26449 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26450 #ifndef CONFIG_PARAVIRT
26451 EXPORT_SYMBOL(native_load_gs_index);
26452 #endif
26453 +
26454 +#ifdef CONFIG_PAX_PER_CPU_PGD
26455 +EXPORT_SYMBOL(cpu_pgd);
26456 +#endif
26457 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26458 index 5f24c71..1dadf09 100644
26459 --- a/arch/x86/kernel/x86_init.c
26460 +++ b/arch/x86/kernel/x86_init.c
26461 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26462 static void default_nmi_init(void) { };
26463 static int default_i8042_detect(void) { return 1; };
26464
26465 -struct x86_platform_ops x86_platform = {
26466 +struct x86_platform_ops x86_platform __read_only = {
26467 .calibrate_tsc = native_calibrate_tsc,
26468 .get_wallclock = mach_get_cmos_time,
26469 .set_wallclock = mach_set_rtc_mmss,
26470 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26471 };
26472
26473 EXPORT_SYMBOL_GPL(x86_platform);
26474 -struct x86_msi_ops x86_msi = {
26475 +struct x86_msi_ops x86_msi __read_only = {
26476 .setup_msi_irqs = native_setup_msi_irqs,
26477 .compose_msi_msg = native_compose_msi_msg,
26478 .teardown_msi_irq = native_teardown_msi_irq,
26479 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26480 .setup_hpet_msi = default_setup_hpet_msi,
26481 };
26482
26483 -struct x86_io_apic_ops x86_io_apic_ops = {
26484 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26485 .init = native_io_apic_init_mappings,
26486 .read = native_io_apic_read,
26487 .write = native_io_apic_write,
26488 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26489 index 422fd82..c3687ca 100644
26490 --- a/arch/x86/kernel/xsave.c
26491 +++ b/arch/x86/kernel/xsave.c
26492 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26493 {
26494 int err;
26495
26496 + buf = (struct xsave_struct __user *)____m(buf);
26497 if (use_xsave())
26498 err = xsave_user(buf);
26499 else if (use_fxsr())
26500 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26501 */
26502 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26503 {
26504 + buf = (void __user *)____m(buf);
26505 if (use_xsave()) {
26506 if ((unsigned long)buf % 64 || fx_only) {
26507 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26508 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26509 index a20ecb5..d0e2194 100644
26510 --- a/arch/x86/kvm/cpuid.c
26511 +++ b/arch/x86/kvm/cpuid.c
26512 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26513 struct kvm_cpuid2 *cpuid,
26514 struct kvm_cpuid_entry2 __user *entries)
26515 {
26516 - int r;
26517 + int r, i;
26518
26519 r = -E2BIG;
26520 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26521 goto out;
26522 r = -EFAULT;
26523 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26524 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26525 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26526 goto out;
26527 + for (i = 0; i < cpuid->nent; ++i) {
26528 + struct kvm_cpuid_entry2 cpuid_entry;
26529 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26530 + goto out;
26531 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26532 + }
26533 vcpu->arch.cpuid_nent = cpuid->nent;
26534 kvm_apic_set_version(vcpu);
26535 kvm_x86_ops->cpuid_update(vcpu);
26536 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26537 struct kvm_cpuid2 *cpuid,
26538 struct kvm_cpuid_entry2 __user *entries)
26539 {
26540 - int r;
26541 + int r, i;
26542
26543 r = -E2BIG;
26544 if (cpuid->nent < vcpu->arch.cpuid_nent)
26545 goto out;
26546 r = -EFAULT;
26547 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26548 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26549 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26550 goto out;
26551 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26552 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26553 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26554 + goto out;
26555 + }
26556 return 0;
26557
26558 out:
26559 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26560 index afc1124..3e431f2 100644
26561 --- a/arch/x86/kvm/lapic.c
26562 +++ b/arch/x86/kvm/lapic.c
26563 @@ -55,7 +55,7 @@
26564 #define APIC_BUS_CYCLE_NS 1
26565
26566 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26567 -#define apic_debug(fmt, arg...)
26568 +#define apic_debug(fmt, arg...) do {} while (0)
26569
26570 #define APIC_LVT_NUM 6
26571 /* 14 is the version for Xeon and Pentium 8.4.8*/
26572 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26573 index 7769699..c8aca4a7f 100644
26574 --- a/arch/x86/kvm/paging_tmpl.h
26575 +++ b/arch/x86/kvm/paging_tmpl.h
26576 @@ -208,7 +208,7 @@ retry_walk:
26577 if (unlikely(kvm_is_error_hva(host_addr)))
26578 goto error;
26579
26580 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26581 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26582 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26583 goto error;
26584 walker->ptep_user[walker->level - 1] = ptep_user;
26585 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26586 index c0bc803..6837a50 100644
26587 --- a/arch/x86/kvm/svm.c
26588 +++ b/arch/x86/kvm/svm.c
26589 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26590 int cpu = raw_smp_processor_id();
26591
26592 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26593 +
26594 + pax_open_kernel();
26595 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26596 + pax_close_kernel();
26597 +
26598 load_TR_desc();
26599 }
26600
26601 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26602 #endif
26603 #endif
26604
26605 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26606 + __set_fs(current_thread_info()->addr_limit);
26607 +#endif
26608 +
26609 reload_tss(vcpu);
26610
26611 local_irq_disable();
26612 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26613 index 064d0be..f5f758e 100644
26614 --- a/arch/x86/kvm/vmx.c
26615 +++ b/arch/x86/kvm/vmx.c
26616 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26617 #endif
26618 }
26619
26620 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26621 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26622 {
26623 vmcs_writel(field, vmcs_readl(field) & ~mask);
26624 }
26625
26626 -static void vmcs_set_bits(unsigned long field, u32 mask)
26627 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26628 {
26629 vmcs_writel(field, vmcs_readl(field) | mask);
26630 }
26631 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26632 struct desc_struct *descs;
26633
26634 descs = (void *)gdt->address;
26635 +
26636 + pax_open_kernel();
26637 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26638 + pax_close_kernel();
26639 +
26640 load_TR_desc();
26641 }
26642
26643 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26644 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26645 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26646
26647 +#ifdef CONFIG_PAX_PER_CPU_PGD
26648 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26649 +#endif
26650 +
26651 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26652 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26653 vmx->loaded_vmcs->cpu = cpu;
26654 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26655 if (!cpu_has_vmx_flexpriority())
26656 flexpriority_enabled = 0;
26657
26658 - if (!cpu_has_vmx_tpr_shadow())
26659 - kvm_x86_ops->update_cr8_intercept = NULL;
26660 + if (!cpu_has_vmx_tpr_shadow()) {
26661 + pax_open_kernel();
26662 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26663 + pax_close_kernel();
26664 + }
26665
26666 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26667 kvm_disable_largepages();
26668 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26669 if (!cpu_has_vmx_apicv())
26670 enable_apicv = 0;
26671
26672 + pax_open_kernel();
26673 if (enable_apicv)
26674 - kvm_x86_ops->update_cr8_intercept = NULL;
26675 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26676 else {
26677 - kvm_x86_ops->hwapic_irr_update = NULL;
26678 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26679 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26680 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26681 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26682 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26683 }
26684 + pax_close_kernel();
26685
26686 if (nested)
26687 nested_vmx_setup_ctls_msrs();
26688 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26689
26690 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26691 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26692 +
26693 +#ifndef CONFIG_PAX_PER_CPU_PGD
26694 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26695 +#endif
26696
26697 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26698 #ifdef CONFIG_X86_64
26699 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26700 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26701 vmx->host_idt_base = dt.address;
26702
26703 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26704 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26705
26706 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26707 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26708 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26709 "jmp 2f \n\t"
26710 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26711 "2: "
26712 +
26713 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26714 + "ljmp %[cs],$3f\n\t"
26715 + "3: "
26716 +#endif
26717 +
26718 /* Save guest registers, load host registers, keep flags */
26719 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26720 "pop %0 \n\t"
26721 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26722 #endif
26723 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26724 [wordsize]"i"(sizeof(ulong))
26725 +
26726 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26727 + ,[cs]"i"(__KERNEL_CS)
26728 +#endif
26729 +
26730 : "cc", "memory"
26731 #ifdef CONFIG_X86_64
26732 , "rax", "rbx", "rdi", "rsi"
26733 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26734 if (debugctlmsr)
26735 update_debugctlmsr(debugctlmsr);
26736
26737 -#ifndef CONFIG_X86_64
26738 +#ifdef CONFIG_X86_32
26739 /*
26740 * The sysexit path does not restore ds/es, so we must set them to
26741 * a reasonable value ourselves.
26742 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26743 * may be executed in interrupt context, which saves and restore segments
26744 * around it, nullifying its effect.
26745 */
26746 - loadsegment(ds, __USER_DS);
26747 - loadsegment(es, __USER_DS);
26748 + loadsegment(ds, __KERNEL_DS);
26749 + loadsegment(es, __KERNEL_DS);
26750 + loadsegment(ss, __KERNEL_DS);
26751 +
26752 +#ifdef CONFIG_PAX_KERNEXEC
26753 + loadsegment(fs, __KERNEL_PERCPU);
26754 +#endif
26755 +
26756 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26757 + __set_fs(current_thread_info()->addr_limit);
26758 +#endif
26759 +
26760 #endif
26761
26762 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26763 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26764 index d21bce5..fdae9f1 100644
26765 --- a/arch/x86/kvm/x86.c
26766 +++ b/arch/x86/kvm/x86.c
26767 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26768 {
26769 struct kvm *kvm = vcpu->kvm;
26770 int lm = is_long_mode(vcpu);
26771 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26772 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26773 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26774 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26775 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26776 : kvm->arch.xen_hvm_config.blob_size_32;
26777 u32 page_num = data & ~PAGE_MASK;
26778 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26779 if (n < msr_list.nmsrs)
26780 goto out;
26781 r = -EFAULT;
26782 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26783 + goto out;
26784 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26785 num_msrs_to_save * sizeof(u32)))
26786 goto out;
26787 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26788 };
26789 #endif
26790
26791 -int kvm_arch_init(void *opaque)
26792 +int kvm_arch_init(const void *opaque)
26793 {
26794 int r;
26795 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26796 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26797 index 6a22c19..1763f04 100644
26798 --- a/arch/x86/lguest/boot.c
26799 +++ b/arch/x86/lguest/boot.c
26800 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26801 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26802 * Launcher to reboot us.
26803 */
26804 -static void lguest_restart(char *reason)
26805 +static __noreturn void lguest_restart(char *reason)
26806 {
26807 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26808 + BUG();
26809 }
26810
26811 /*G:050
26812 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26813 index 00933d5..3a64af9 100644
26814 --- a/arch/x86/lib/atomic64_386_32.S
26815 +++ b/arch/x86/lib/atomic64_386_32.S
26816 @@ -48,6 +48,10 @@ BEGIN(read)
26817 movl (v), %eax
26818 movl 4(v), %edx
26819 RET_ENDP
26820 +BEGIN(read_unchecked)
26821 + movl (v), %eax
26822 + movl 4(v), %edx
26823 +RET_ENDP
26824 #undef v
26825
26826 #define v %esi
26827 @@ -55,6 +59,10 @@ BEGIN(set)
26828 movl %ebx, (v)
26829 movl %ecx, 4(v)
26830 RET_ENDP
26831 +BEGIN(set_unchecked)
26832 + movl %ebx, (v)
26833 + movl %ecx, 4(v)
26834 +RET_ENDP
26835 #undef v
26836
26837 #define v %esi
26838 @@ -70,6 +78,20 @@ RET_ENDP
26839 BEGIN(add)
26840 addl %eax, (v)
26841 adcl %edx, 4(v)
26842 +
26843 +#ifdef CONFIG_PAX_REFCOUNT
26844 + jno 0f
26845 + subl %eax, (v)
26846 + sbbl %edx, 4(v)
26847 + int $4
26848 +0:
26849 + _ASM_EXTABLE(0b, 0b)
26850 +#endif
26851 +
26852 +RET_ENDP
26853 +BEGIN(add_unchecked)
26854 + addl %eax, (v)
26855 + adcl %edx, 4(v)
26856 RET_ENDP
26857 #undef v
26858
26859 @@ -77,6 +99,24 @@ RET_ENDP
26860 BEGIN(add_return)
26861 addl (v), %eax
26862 adcl 4(v), %edx
26863 +
26864 +#ifdef CONFIG_PAX_REFCOUNT
26865 + into
26866 +1234:
26867 + _ASM_EXTABLE(1234b, 2f)
26868 +#endif
26869 +
26870 + movl %eax, (v)
26871 + movl %edx, 4(v)
26872 +
26873 +#ifdef CONFIG_PAX_REFCOUNT
26874 +2:
26875 +#endif
26876 +
26877 +RET_ENDP
26878 +BEGIN(add_return_unchecked)
26879 + addl (v), %eax
26880 + adcl 4(v), %edx
26881 movl %eax, (v)
26882 movl %edx, 4(v)
26883 RET_ENDP
26884 @@ -86,6 +126,20 @@ RET_ENDP
26885 BEGIN(sub)
26886 subl %eax, (v)
26887 sbbl %edx, 4(v)
26888 +
26889 +#ifdef CONFIG_PAX_REFCOUNT
26890 + jno 0f
26891 + addl %eax, (v)
26892 + adcl %edx, 4(v)
26893 + int $4
26894 +0:
26895 + _ASM_EXTABLE(0b, 0b)
26896 +#endif
26897 +
26898 +RET_ENDP
26899 +BEGIN(sub_unchecked)
26900 + subl %eax, (v)
26901 + sbbl %edx, 4(v)
26902 RET_ENDP
26903 #undef v
26904
26905 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26906 sbbl $0, %edx
26907 addl (v), %eax
26908 adcl 4(v), %edx
26909 +
26910 +#ifdef CONFIG_PAX_REFCOUNT
26911 + into
26912 +1234:
26913 + _ASM_EXTABLE(1234b, 2f)
26914 +#endif
26915 +
26916 + movl %eax, (v)
26917 + movl %edx, 4(v)
26918 +
26919 +#ifdef CONFIG_PAX_REFCOUNT
26920 +2:
26921 +#endif
26922 +
26923 +RET_ENDP
26924 +BEGIN(sub_return_unchecked)
26925 + negl %edx
26926 + negl %eax
26927 + sbbl $0, %edx
26928 + addl (v), %eax
26929 + adcl 4(v), %edx
26930 movl %eax, (v)
26931 movl %edx, 4(v)
26932 RET_ENDP
26933 @@ -105,6 +180,20 @@ RET_ENDP
26934 BEGIN(inc)
26935 addl $1, (v)
26936 adcl $0, 4(v)
26937 +
26938 +#ifdef CONFIG_PAX_REFCOUNT
26939 + jno 0f
26940 + subl $1, (v)
26941 + sbbl $0, 4(v)
26942 + int $4
26943 +0:
26944 + _ASM_EXTABLE(0b, 0b)
26945 +#endif
26946 +
26947 +RET_ENDP
26948 +BEGIN(inc_unchecked)
26949 + addl $1, (v)
26950 + adcl $0, 4(v)
26951 RET_ENDP
26952 #undef v
26953
26954 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26955 movl 4(v), %edx
26956 addl $1, %eax
26957 adcl $0, %edx
26958 +
26959 +#ifdef CONFIG_PAX_REFCOUNT
26960 + into
26961 +1234:
26962 + _ASM_EXTABLE(1234b, 2f)
26963 +#endif
26964 +
26965 + movl %eax, (v)
26966 + movl %edx, 4(v)
26967 +
26968 +#ifdef CONFIG_PAX_REFCOUNT
26969 +2:
26970 +#endif
26971 +
26972 +RET_ENDP
26973 +BEGIN(inc_return_unchecked)
26974 + movl (v), %eax
26975 + movl 4(v), %edx
26976 + addl $1, %eax
26977 + adcl $0, %edx
26978 movl %eax, (v)
26979 movl %edx, 4(v)
26980 RET_ENDP
26981 @@ -123,6 +232,20 @@ RET_ENDP
26982 BEGIN(dec)
26983 subl $1, (v)
26984 sbbl $0, 4(v)
26985 +
26986 +#ifdef CONFIG_PAX_REFCOUNT
26987 + jno 0f
26988 + addl $1, (v)
26989 + adcl $0, 4(v)
26990 + int $4
26991 +0:
26992 + _ASM_EXTABLE(0b, 0b)
26993 +#endif
26994 +
26995 +RET_ENDP
26996 +BEGIN(dec_unchecked)
26997 + subl $1, (v)
26998 + sbbl $0, 4(v)
26999 RET_ENDP
27000 #undef v
27001
27002 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27003 movl 4(v), %edx
27004 subl $1, %eax
27005 sbbl $0, %edx
27006 +
27007 +#ifdef CONFIG_PAX_REFCOUNT
27008 + into
27009 +1234:
27010 + _ASM_EXTABLE(1234b, 2f)
27011 +#endif
27012 +
27013 + movl %eax, (v)
27014 + movl %edx, 4(v)
27015 +
27016 +#ifdef CONFIG_PAX_REFCOUNT
27017 +2:
27018 +#endif
27019 +
27020 +RET_ENDP
27021 +BEGIN(dec_return_unchecked)
27022 + movl (v), %eax
27023 + movl 4(v), %edx
27024 + subl $1, %eax
27025 + sbbl $0, %edx
27026 movl %eax, (v)
27027 movl %edx, 4(v)
27028 RET_ENDP
27029 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27030 adcl %edx, %edi
27031 addl (v), %eax
27032 adcl 4(v), %edx
27033 +
27034 +#ifdef CONFIG_PAX_REFCOUNT
27035 + into
27036 +1234:
27037 + _ASM_EXTABLE(1234b, 2f)
27038 +#endif
27039 +
27040 cmpl %eax, %ecx
27041 je 3f
27042 1:
27043 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27044 1:
27045 addl $1, %eax
27046 adcl $0, %edx
27047 +
27048 +#ifdef CONFIG_PAX_REFCOUNT
27049 + into
27050 +1234:
27051 + _ASM_EXTABLE(1234b, 2f)
27052 +#endif
27053 +
27054 movl %eax, (v)
27055 movl %edx, 4(v)
27056 movl $1, %eax
27057 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27058 movl 4(v), %edx
27059 subl $1, %eax
27060 sbbl $0, %edx
27061 +
27062 +#ifdef CONFIG_PAX_REFCOUNT
27063 + into
27064 +1234:
27065 + _ASM_EXTABLE(1234b, 1f)
27066 +#endif
27067 +
27068 js 1f
27069 movl %eax, (v)
27070 movl %edx, 4(v)
27071 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27072 index f5cc9eb..51fa319 100644
27073 --- a/arch/x86/lib/atomic64_cx8_32.S
27074 +++ b/arch/x86/lib/atomic64_cx8_32.S
27075 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27076 CFI_STARTPROC
27077
27078 read64 %ecx
27079 + pax_force_retaddr
27080 ret
27081 CFI_ENDPROC
27082 ENDPROC(atomic64_read_cx8)
27083
27084 +ENTRY(atomic64_read_unchecked_cx8)
27085 + CFI_STARTPROC
27086 +
27087 + read64 %ecx
27088 + pax_force_retaddr
27089 + ret
27090 + CFI_ENDPROC
27091 +ENDPROC(atomic64_read_unchecked_cx8)
27092 +
27093 ENTRY(atomic64_set_cx8)
27094 CFI_STARTPROC
27095
27096 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27097 cmpxchg8b (%esi)
27098 jne 1b
27099
27100 + pax_force_retaddr
27101 ret
27102 CFI_ENDPROC
27103 ENDPROC(atomic64_set_cx8)
27104
27105 +ENTRY(atomic64_set_unchecked_cx8)
27106 + CFI_STARTPROC
27107 +
27108 +1:
27109 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27110 + * are atomic on 586 and newer */
27111 + cmpxchg8b (%esi)
27112 + jne 1b
27113 +
27114 + pax_force_retaddr
27115 + ret
27116 + CFI_ENDPROC
27117 +ENDPROC(atomic64_set_unchecked_cx8)
27118 +
27119 ENTRY(atomic64_xchg_cx8)
27120 CFI_STARTPROC
27121
27122 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27123 cmpxchg8b (%esi)
27124 jne 1b
27125
27126 + pax_force_retaddr
27127 ret
27128 CFI_ENDPROC
27129 ENDPROC(atomic64_xchg_cx8)
27130
27131 -.macro addsub_return func ins insc
27132 -ENTRY(atomic64_\func\()_return_cx8)
27133 +.macro addsub_return func ins insc unchecked=""
27134 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27135 CFI_STARTPROC
27136 SAVE ebp
27137 SAVE ebx
27138 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27139 movl %edx, %ecx
27140 \ins\()l %esi, %ebx
27141 \insc\()l %edi, %ecx
27142 +
27143 +.ifb \unchecked
27144 +#ifdef CONFIG_PAX_REFCOUNT
27145 + into
27146 +2:
27147 + _ASM_EXTABLE(2b, 3f)
27148 +#endif
27149 +.endif
27150 +
27151 LOCK_PREFIX
27152 cmpxchg8b (%ebp)
27153 jne 1b
27154 -
27155 -10:
27156 movl %ebx, %eax
27157 movl %ecx, %edx
27158 +
27159 +.ifb \unchecked
27160 +#ifdef CONFIG_PAX_REFCOUNT
27161 +3:
27162 +#endif
27163 +.endif
27164 +
27165 RESTORE edi
27166 RESTORE esi
27167 RESTORE ebx
27168 RESTORE ebp
27169 + pax_force_retaddr
27170 ret
27171 CFI_ENDPROC
27172 -ENDPROC(atomic64_\func\()_return_cx8)
27173 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27174 .endm
27175
27176 addsub_return add add adc
27177 addsub_return sub sub sbb
27178 +addsub_return add add adc _unchecked
27179 +addsub_return sub sub sbb _unchecked
27180
27181 -.macro incdec_return func ins insc
27182 -ENTRY(atomic64_\func\()_return_cx8)
27183 +.macro incdec_return func ins insc unchecked=""
27184 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27185 CFI_STARTPROC
27186 SAVE ebx
27187
27188 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27189 movl %edx, %ecx
27190 \ins\()l $1, %ebx
27191 \insc\()l $0, %ecx
27192 +
27193 +.ifb \unchecked
27194 +#ifdef CONFIG_PAX_REFCOUNT
27195 + into
27196 +2:
27197 + _ASM_EXTABLE(2b, 3f)
27198 +#endif
27199 +.endif
27200 +
27201 LOCK_PREFIX
27202 cmpxchg8b (%esi)
27203 jne 1b
27204
27205 -10:
27206 movl %ebx, %eax
27207 movl %ecx, %edx
27208 +
27209 +.ifb \unchecked
27210 +#ifdef CONFIG_PAX_REFCOUNT
27211 +3:
27212 +#endif
27213 +.endif
27214 +
27215 RESTORE ebx
27216 + pax_force_retaddr
27217 ret
27218 CFI_ENDPROC
27219 -ENDPROC(atomic64_\func\()_return_cx8)
27220 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27221 .endm
27222
27223 incdec_return inc add adc
27224 incdec_return dec sub sbb
27225 +incdec_return inc add adc _unchecked
27226 +incdec_return dec sub sbb _unchecked
27227
27228 ENTRY(atomic64_dec_if_positive_cx8)
27229 CFI_STARTPROC
27230 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27231 movl %edx, %ecx
27232 subl $1, %ebx
27233 sbb $0, %ecx
27234 +
27235 +#ifdef CONFIG_PAX_REFCOUNT
27236 + into
27237 +1234:
27238 + _ASM_EXTABLE(1234b, 2f)
27239 +#endif
27240 +
27241 js 2f
27242 LOCK_PREFIX
27243 cmpxchg8b (%esi)
27244 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27245 movl %ebx, %eax
27246 movl %ecx, %edx
27247 RESTORE ebx
27248 + pax_force_retaddr
27249 ret
27250 CFI_ENDPROC
27251 ENDPROC(atomic64_dec_if_positive_cx8)
27252 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27253 movl %edx, %ecx
27254 addl %ebp, %ebx
27255 adcl %edi, %ecx
27256 +
27257 +#ifdef CONFIG_PAX_REFCOUNT
27258 + into
27259 +1234:
27260 + _ASM_EXTABLE(1234b, 3f)
27261 +#endif
27262 +
27263 LOCK_PREFIX
27264 cmpxchg8b (%esi)
27265 jne 1b
27266 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27267 CFI_ADJUST_CFA_OFFSET -8
27268 RESTORE ebx
27269 RESTORE ebp
27270 + pax_force_retaddr
27271 ret
27272 4:
27273 cmpl %edx, 4(%esp)
27274 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27275 xorl %ecx, %ecx
27276 addl $1, %ebx
27277 adcl %edx, %ecx
27278 +
27279 +#ifdef CONFIG_PAX_REFCOUNT
27280 + into
27281 +1234:
27282 + _ASM_EXTABLE(1234b, 3f)
27283 +#endif
27284 +
27285 LOCK_PREFIX
27286 cmpxchg8b (%esi)
27287 jne 1b
27288 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27289 movl $1, %eax
27290 3:
27291 RESTORE ebx
27292 + pax_force_retaddr
27293 ret
27294 CFI_ENDPROC
27295 ENDPROC(atomic64_inc_not_zero_cx8)
27296 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27297 index e78b8ee..7e173a8 100644
27298 --- a/arch/x86/lib/checksum_32.S
27299 +++ b/arch/x86/lib/checksum_32.S
27300 @@ -29,7 +29,8 @@
27301 #include <asm/dwarf2.h>
27302 #include <asm/errno.h>
27303 #include <asm/asm.h>
27304 -
27305 +#include <asm/segment.h>
27306 +
27307 /*
27308 * computes a partial checksum, e.g. for TCP/UDP fragments
27309 */
27310 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27311
27312 #define ARGBASE 16
27313 #define FP 12
27314 -
27315 -ENTRY(csum_partial_copy_generic)
27316 +
27317 +ENTRY(csum_partial_copy_generic_to_user)
27318 CFI_STARTPROC
27319 +
27320 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27321 + pushl_cfi %gs
27322 + popl_cfi %es
27323 + jmp csum_partial_copy_generic
27324 +#endif
27325 +
27326 +ENTRY(csum_partial_copy_generic_from_user)
27327 +
27328 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27329 + pushl_cfi %gs
27330 + popl_cfi %ds
27331 +#endif
27332 +
27333 +ENTRY(csum_partial_copy_generic)
27334 subl $4,%esp
27335 CFI_ADJUST_CFA_OFFSET 4
27336 pushl_cfi %edi
27337 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27338 jmp 4f
27339 SRC(1: movw (%esi), %bx )
27340 addl $2, %esi
27341 -DST( movw %bx, (%edi) )
27342 +DST( movw %bx, %es:(%edi) )
27343 addl $2, %edi
27344 addw %bx, %ax
27345 adcl $0, %eax
27346 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27347 SRC(1: movl (%esi), %ebx )
27348 SRC( movl 4(%esi), %edx )
27349 adcl %ebx, %eax
27350 -DST( movl %ebx, (%edi) )
27351 +DST( movl %ebx, %es:(%edi) )
27352 adcl %edx, %eax
27353 -DST( movl %edx, 4(%edi) )
27354 +DST( movl %edx, %es:4(%edi) )
27355
27356 SRC( movl 8(%esi), %ebx )
27357 SRC( movl 12(%esi), %edx )
27358 adcl %ebx, %eax
27359 -DST( movl %ebx, 8(%edi) )
27360 +DST( movl %ebx, %es:8(%edi) )
27361 adcl %edx, %eax
27362 -DST( movl %edx, 12(%edi) )
27363 +DST( movl %edx, %es:12(%edi) )
27364
27365 SRC( movl 16(%esi), %ebx )
27366 SRC( movl 20(%esi), %edx )
27367 adcl %ebx, %eax
27368 -DST( movl %ebx, 16(%edi) )
27369 +DST( movl %ebx, %es:16(%edi) )
27370 adcl %edx, %eax
27371 -DST( movl %edx, 20(%edi) )
27372 +DST( movl %edx, %es:20(%edi) )
27373
27374 SRC( movl 24(%esi), %ebx )
27375 SRC( movl 28(%esi), %edx )
27376 adcl %ebx, %eax
27377 -DST( movl %ebx, 24(%edi) )
27378 +DST( movl %ebx, %es:24(%edi) )
27379 adcl %edx, %eax
27380 -DST( movl %edx, 28(%edi) )
27381 +DST( movl %edx, %es:28(%edi) )
27382
27383 lea 32(%esi), %esi
27384 lea 32(%edi), %edi
27385 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27386 shrl $2, %edx # This clears CF
27387 SRC(3: movl (%esi), %ebx )
27388 adcl %ebx, %eax
27389 -DST( movl %ebx, (%edi) )
27390 +DST( movl %ebx, %es:(%edi) )
27391 lea 4(%esi), %esi
27392 lea 4(%edi), %edi
27393 dec %edx
27394 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27395 jb 5f
27396 SRC( movw (%esi), %cx )
27397 leal 2(%esi), %esi
27398 -DST( movw %cx, (%edi) )
27399 +DST( movw %cx, %es:(%edi) )
27400 leal 2(%edi), %edi
27401 je 6f
27402 shll $16,%ecx
27403 SRC(5: movb (%esi), %cl )
27404 -DST( movb %cl, (%edi) )
27405 +DST( movb %cl, %es:(%edi) )
27406 6: addl %ecx, %eax
27407 adcl $0, %eax
27408 7:
27409 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27410
27411 6001:
27412 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27413 - movl $-EFAULT, (%ebx)
27414 + movl $-EFAULT, %ss:(%ebx)
27415
27416 # zero the complete destination - computing the rest
27417 # is too much work
27418 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27419
27420 6002:
27421 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27422 - movl $-EFAULT,(%ebx)
27423 + movl $-EFAULT,%ss:(%ebx)
27424 jmp 5000b
27425
27426 .previous
27427
27428 + pushl_cfi %ss
27429 + popl_cfi %ds
27430 + pushl_cfi %ss
27431 + popl_cfi %es
27432 popl_cfi %ebx
27433 CFI_RESTORE ebx
27434 popl_cfi %esi
27435 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27436 popl_cfi %ecx # equivalent to addl $4,%esp
27437 ret
27438 CFI_ENDPROC
27439 -ENDPROC(csum_partial_copy_generic)
27440 +ENDPROC(csum_partial_copy_generic_to_user)
27441
27442 #else
27443
27444 /* Version for PentiumII/PPro */
27445
27446 #define ROUND1(x) \
27447 + nop; nop; nop; \
27448 SRC(movl x(%esi), %ebx ) ; \
27449 addl %ebx, %eax ; \
27450 - DST(movl %ebx, x(%edi) ) ;
27451 + DST(movl %ebx, %es:x(%edi)) ;
27452
27453 #define ROUND(x) \
27454 + nop; nop; nop; \
27455 SRC(movl x(%esi), %ebx ) ; \
27456 adcl %ebx, %eax ; \
27457 - DST(movl %ebx, x(%edi) ) ;
27458 + DST(movl %ebx, %es:x(%edi)) ;
27459
27460 #define ARGBASE 12
27461 -
27462 -ENTRY(csum_partial_copy_generic)
27463 +
27464 +ENTRY(csum_partial_copy_generic_to_user)
27465 CFI_STARTPROC
27466 +
27467 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27468 + pushl_cfi %gs
27469 + popl_cfi %es
27470 + jmp csum_partial_copy_generic
27471 +#endif
27472 +
27473 +ENTRY(csum_partial_copy_generic_from_user)
27474 +
27475 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27476 + pushl_cfi %gs
27477 + popl_cfi %ds
27478 +#endif
27479 +
27480 +ENTRY(csum_partial_copy_generic)
27481 pushl_cfi %ebx
27482 CFI_REL_OFFSET ebx, 0
27483 pushl_cfi %edi
27484 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27485 subl %ebx, %edi
27486 lea -1(%esi),%edx
27487 andl $-32,%edx
27488 - lea 3f(%ebx,%ebx), %ebx
27489 + lea 3f(%ebx,%ebx,2), %ebx
27490 testl %esi, %esi
27491 jmp *%ebx
27492 1: addl $64,%esi
27493 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27494 jb 5f
27495 SRC( movw (%esi), %dx )
27496 leal 2(%esi), %esi
27497 -DST( movw %dx, (%edi) )
27498 +DST( movw %dx, %es:(%edi) )
27499 leal 2(%edi), %edi
27500 je 6f
27501 shll $16,%edx
27502 5:
27503 SRC( movb (%esi), %dl )
27504 -DST( movb %dl, (%edi) )
27505 +DST( movb %dl, %es:(%edi) )
27506 6: addl %edx, %eax
27507 adcl $0, %eax
27508 7:
27509 .section .fixup, "ax"
27510 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27511 - movl $-EFAULT, (%ebx)
27512 + movl $-EFAULT, %ss:(%ebx)
27513 # zero the complete destination (computing the rest is too much work)
27514 movl ARGBASE+8(%esp),%edi # dst
27515 movl ARGBASE+12(%esp),%ecx # len
27516 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27517 rep; stosb
27518 jmp 7b
27519 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27520 - movl $-EFAULT, (%ebx)
27521 + movl $-EFAULT, %ss:(%ebx)
27522 jmp 7b
27523 .previous
27524
27525 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27526 + pushl_cfi %ss
27527 + popl_cfi %ds
27528 + pushl_cfi %ss
27529 + popl_cfi %es
27530 +#endif
27531 +
27532 popl_cfi %esi
27533 CFI_RESTORE esi
27534 popl_cfi %edi
27535 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27536 CFI_RESTORE ebx
27537 ret
27538 CFI_ENDPROC
27539 -ENDPROC(csum_partial_copy_generic)
27540 +ENDPROC(csum_partial_copy_generic_to_user)
27541
27542 #undef ROUND
27543 #undef ROUND1
27544 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27545 index f2145cf..cea889d 100644
27546 --- a/arch/x86/lib/clear_page_64.S
27547 +++ b/arch/x86/lib/clear_page_64.S
27548 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27549 movl $4096/8,%ecx
27550 xorl %eax,%eax
27551 rep stosq
27552 + pax_force_retaddr
27553 ret
27554 CFI_ENDPROC
27555 ENDPROC(clear_page_c)
27556 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27557 movl $4096,%ecx
27558 xorl %eax,%eax
27559 rep stosb
27560 + pax_force_retaddr
27561 ret
27562 CFI_ENDPROC
27563 ENDPROC(clear_page_c_e)
27564 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27565 leaq 64(%rdi),%rdi
27566 jnz .Lloop
27567 nop
27568 + pax_force_retaddr
27569 ret
27570 CFI_ENDPROC
27571 .Lclear_page_end:
27572 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27573
27574 #include <asm/cpufeature.h>
27575
27576 - .section .altinstr_replacement,"ax"
27577 + .section .altinstr_replacement,"a"
27578 1: .byte 0xeb /* jmp <disp8> */
27579 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27580 2: .byte 0xeb /* jmp <disp8> */
27581 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27582 index 1e572c5..2a162cd 100644
27583 --- a/arch/x86/lib/cmpxchg16b_emu.S
27584 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27585 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27586
27587 popf
27588 mov $1, %al
27589 + pax_force_retaddr
27590 ret
27591
27592 not_same:
27593 popf
27594 xor %al,%al
27595 + pax_force_retaddr
27596 ret
27597
27598 CFI_ENDPROC
27599 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27600 index 176cca6..1166c50 100644
27601 --- a/arch/x86/lib/copy_page_64.S
27602 +++ b/arch/x86/lib/copy_page_64.S
27603 @@ -9,6 +9,7 @@ copy_page_rep:
27604 CFI_STARTPROC
27605 movl $4096/8, %ecx
27606 rep movsq
27607 + pax_force_retaddr
27608 ret
27609 CFI_ENDPROC
27610 ENDPROC(copy_page_rep)
27611 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27612
27613 ENTRY(copy_page)
27614 CFI_STARTPROC
27615 - subq $2*8, %rsp
27616 - CFI_ADJUST_CFA_OFFSET 2*8
27617 + subq $3*8, %rsp
27618 + CFI_ADJUST_CFA_OFFSET 3*8
27619 movq %rbx, (%rsp)
27620 CFI_REL_OFFSET rbx, 0
27621 movq %r12, 1*8(%rsp)
27622 CFI_REL_OFFSET r12, 1*8
27623 + movq %r13, 2*8(%rsp)
27624 + CFI_REL_OFFSET r13, 2*8
27625
27626 movl $(4096/64)-5, %ecx
27627 .p2align 4
27628 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27629 movq 0x8*2(%rsi), %rdx
27630 movq 0x8*3(%rsi), %r8
27631 movq 0x8*4(%rsi), %r9
27632 - movq 0x8*5(%rsi), %r10
27633 + movq 0x8*5(%rsi), %r13
27634 movq 0x8*6(%rsi), %r11
27635 movq 0x8*7(%rsi), %r12
27636
27637 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27638 movq %rdx, 0x8*2(%rdi)
27639 movq %r8, 0x8*3(%rdi)
27640 movq %r9, 0x8*4(%rdi)
27641 - movq %r10, 0x8*5(%rdi)
27642 + movq %r13, 0x8*5(%rdi)
27643 movq %r11, 0x8*6(%rdi)
27644 movq %r12, 0x8*7(%rdi)
27645
27646 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27647 movq 0x8*2(%rsi), %rdx
27648 movq 0x8*3(%rsi), %r8
27649 movq 0x8*4(%rsi), %r9
27650 - movq 0x8*5(%rsi), %r10
27651 + movq 0x8*5(%rsi), %r13
27652 movq 0x8*6(%rsi), %r11
27653 movq 0x8*7(%rsi), %r12
27654
27655 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27656 movq %rdx, 0x8*2(%rdi)
27657 movq %r8, 0x8*3(%rdi)
27658 movq %r9, 0x8*4(%rdi)
27659 - movq %r10, 0x8*5(%rdi)
27660 + movq %r13, 0x8*5(%rdi)
27661 movq %r11, 0x8*6(%rdi)
27662 movq %r12, 0x8*7(%rdi)
27663
27664 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27665 CFI_RESTORE rbx
27666 movq 1*8(%rsp), %r12
27667 CFI_RESTORE r12
27668 - addq $2*8, %rsp
27669 - CFI_ADJUST_CFA_OFFSET -2*8
27670 + movq 2*8(%rsp), %r13
27671 + CFI_RESTORE r13
27672 + addq $3*8, %rsp
27673 + CFI_ADJUST_CFA_OFFSET -3*8
27674 + pax_force_retaddr
27675 ret
27676 .Lcopy_page_end:
27677 CFI_ENDPROC
27678 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27679
27680 #include <asm/cpufeature.h>
27681
27682 - .section .altinstr_replacement,"ax"
27683 + .section .altinstr_replacement,"a"
27684 1: .byte 0xeb /* jmp <disp8> */
27685 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27686 2:
27687 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27688 index a30ca15..6b3f4e1 100644
27689 --- a/arch/x86/lib/copy_user_64.S
27690 +++ b/arch/x86/lib/copy_user_64.S
27691 @@ -18,31 +18,7 @@
27692 #include <asm/alternative-asm.h>
27693 #include <asm/asm.h>
27694 #include <asm/smap.h>
27695 -
27696 -/*
27697 - * By placing feature2 after feature1 in altinstructions section, we logically
27698 - * implement:
27699 - * If CPU has feature2, jmp to alt2 is used
27700 - * else if CPU has feature1, jmp to alt1 is used
27701 - * else jmp to orig is used.
27702 - */
27703 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27704 -0:
27705 - .byte 0xe9 /* 32bit jump */
27706 - .long \orig-1f /* by default jump to orig */
27707 -1:
27708 - .section .altinstr_replacement,"ax"
27709 -2: .byte 0xe9 /* near jump with 32bit immediate */
27710 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27711 -3: .byte 0xe9 /* near jump with 32bit immediate */
27712 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27713 - .previous
27714 -
27715 - .section .altinstructions,"a"
27716 - altinstruction_entry 0b,2b,\feature1,5,5
27717 - altinstruction_entry 0b,3b,\feature2,5,5
27718 - .previous
27719 - .endm
27720 +#include <asm/pgtable.h>
27721
27722 .macro ALIGN_DESTINATION
27723 #ifdef FIX_ALIGNMENT
27724 @@ -70,52 +46,6 @@
27725 #endif
27726 .endm
27727
27728 -/* Standard copy_to_user with segment limit checking */
27729 -ENTRY(_copy_to_user)
27730 - CFI_STARTPROC
27731 - GET_THREAD_INFO(%rax)
27732 - movq %rdi,%rcx
27733 - addq %rdx,%rcx
27734 - jc bad_to_user
27735 - cmpq TI_addr_limit(%rax),%rcx
27736 - ja bad_to_user
27737 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27738 - copy_user_generic_unrolled,copy_user_generic_string, \
27739 - copy_user_enhanced_fast_string
27740 - CFI_ENDPROC
27741 -ENDPROC(_copy_to_user)
27742 -
27743 -/* Standard copy_from_user with segment limit checking */
27744 -ENTRY(_copy_from_user)
27745 - CFI_STARTPROC
27746 - GET_THREAD_INFO(%rax)
27747 - movq %rsi,%rcx
27748 - addq %rdx,%rcx
27749 - jc bad_from_user
27750 - cmpq TI_addr_limit(%rax),%rcx
27751 - ja bad_from_user
27752 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27753 - copy_user_generic_unrolled,copy_user_generic_string, \
27754 - copy_user_enhanced_fast_string
27755 - CFI_ENDPROC
27756 -ENDPROC(_copy_from_user)
27757 -
27758 - .section .fixup,"ax"
27759 - /* must zero dest */
27760 -ENTRY(bad_from_user)
27761 -bad_from_user:
27762 - CFI_STARTPROC
27763 - movl %edx,%ecx
27764 - xorl %eax,%eax
27765 - rep
27766 - stosb
27767 -bad_to_user:
27768 - movl %edx,%eax
27769 - ret
27770 - CFI_ENDPROC
27771 -ENDPROC(bad_from_user)
27772 - .previous
27773 -
27774 /*
27775 * copy_user_generic_unrolled - memory copy with exception handling.
27776 * This version is for CPUs like P4 that don't have efficient micro
27777 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27778 */
27779 ENTRY(copy_user_generic_unrolled)
27780 CFI_STARTPROC
27781 + ASM_PAX_OPEN_USERLAND
27782 ASM_STAC
27783 cmpl $8,%edx
27784 jb 20f /* less then 8 bytes, go to byte copy loop */
27785 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27786 jz 17f
27787 1: movq (%rsi),%r8
27788 2: movq 1*8(%rsi),%r9
27789 -3: movq 2*8(%rsi),%r10
27790 +3: movq 2*8(%rsi),%rax
27791 4: movq 3*8(%rsi),%r11
27792 5: movq %r8,(%rdi)
27793 6: movq %r9,1*8(%rdi)
27794 -7: movq %r10,2*8(%rdi)
27795 +7: movq %rax,2*8(%rdi)
27796 8: movq %r11,3*8(%rdi)
27797 9: movq 4*8(%rsi),%r8
27798 10: movq 5*8(%rsi),%r9
27799 -11: movq 6*8(%rsi),%r10
27800 +11: movq 6*8(%rsi),%rax
27801 12: movq 7*8(%rsi),%r11
27802 13: movq %r8,4*8(%rdi)
27803 14: movq %r9,5*8(%rdi)
27804 -15: movq %r10,6*8(%rdi)
27805 +15: movq %rax,6*8(%rdi)
27806 16: movq %r11,7*8(%rdi)
27807 leaq 64(%rsi),%rsi
27808 leaq 64(%rdi),%rdi
27809 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27810 jnz 21b
27811 23: xor %eax,%eax
27812 ASM_CLAC
27813 + ASM_PAX_CLOSE_USERLAND
27814 + pax_force_retaddr
27815 ret
27816
27817 .section .fixup,"ax"
27818 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27819 */
27820 ENTRY(copy_user_generic_string)
27821 CFI_STARTPROC
27822 + ASM_PAX_OPEN_USERLAND
27823 ASM_STAC
27824 andl %edx,%edx
27825 jz 4f
27826 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27827 movsb
27828 4: xorl %eax,%eax
27829 ASM_CLAC
27830 + ASM_PAX_CLOSE_USERLAND
27831 + pax_force_retaddr
27832 ret
27833
27834 .section .fixup,"ax"
27835 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27836 */
27837 ENTRY(copy_user_enhanced_fast_string)
27838 CFI_STARTPROC
27839 + ASM_PAX_OPEN_USERLAND
27840 ASM_STAC
27841 andl %edx,%edx
27842 jz 2f
27843 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27844 movsb
27845 2: xorl %eax,%eax
27846 ASM_CLAC
27847 + ASM_PAX_CLOSE_USERLAND
27848 + pax_force_retaddr
27849 ret
27850
27851 .section .fixup,"ax"
27852 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27853 index 6a4f43c..55d26f2 100644
27854 --- a/arch/x86/lib/copy_user_nocache_64.S
27855 +++ b/arch/x86/lib/copy_user_nocache_64.S
27856 @@ -8,6 +8,7 @@
27857
27858 #include <linux/linkage.h>
27859 #include <asm/dwarf2.h>
27860 +#include <asm/alternative-asm.h>
27861
27862 #define FIX_ALIGNMENT 1
27863
27864 @@ -16,6 +17,7 @@
27865 #include <asm/thread_info.h>
27866 #include <asm/asm.h>
27867 #include <asm/smap.h>
27868 +#include <asm/pgtable.h>
27869
27870 .macro ALIGN_DESTINATION
27871 #ifdef FIX_ALIGNMENT
27872 @@ -49,6 +51,16 @@
27873 */
27874 ENTRY(__copy_user_nocache)
27875 CFI_STARTPROC
27876 +
27877 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27878 + mov pax_user_shadow_base,%rcx
27879 + cmp %rcx,%rsi
27880 + jae 1f
27881 + add %rcx,%rsi
27882 +1:
27883 +#endif
27884 +
27885 + ASM_PAX_OPEN_USERLAND
27886 ASM_STAC
27887 cmpl $8,%edx
27888 jb 20f /* less then 8 bytes, go to byte copy loop */
27889 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27890 jz 17f
27891 1: movq (%rsi),%r8
27892 2: movq 1*8(%rsi),%r9
27893 -3: movq 2*8(%rsi),%r10
27894 +3: movq 2*8(%rsi),%rax
27895 4: movq 3*8(%rsi),%r11
27896 5: movnti %r8,(%rdi)
27897 6: movnti %r9,1*8(%rdi)
27898 -7: movnti %r10,2*8(%rdi)
27899 +7: movnti %rax,2*8(%rdi)
27900 8: movnti %r11,3*8(%rdi)
27901 9: movq 4*8(%rsi),%r8
27902 10: movq 5*8(%rsi),%r9
27903 -11: movq 6*8(%rsi),%r10
27904 +11: movq 6*8(%rsi),%rax
27905 12: movq 7*8(%rsi),%r11
27906 13: movnti %r8,4*8(%rdi)
27907 14: movnti %r9,5*8(%rdi)
27908 -15: movnti %r10,6*8(%rdi)
27909 +15: movnti %rax,6*8(%rdi)
27910 16: movnti %r11,7*8(%rdi)
27911 leaq 64(%rsi),%rsi
27912 leaq 64(%rdi),%rdi
27913 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27914 jnz 21b
27915 23: xorl %eax,%eax
27916 ASM_CLAC
27917 + ASM_PAX_CLOSE_USERLAND
27918 sfence
27919 + pax_force_retaddr
27920 ret
27921
27922 .section .fixup,"ax"
27923 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27924 index 2419d5f..953ee51 100644
27925 --- a/arch/x86/lib/csum-copy_64.S
27926 +++ b/arch/x86/lib/csum-copy_64.S
27927 @@ -9,6 +9,7 @@
27928 #include <asm/dwarf2.h>
27929 #include <asm/errno.h>
27930 #include <asm/asm.h>
27931 +#include <asm/alternative-asm.h>
27932
27933 /*
27934 * Checksum copy with exception handling.
27935 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27936 CFI_RESTORE rbp
27937 addq $7*8, %rsp
27938 CFI_ADJUST_CFA_OFFSET -7*8
27939 + pax_force_retaddr 0, 1
27940 ret
27941 CFI_RESTORE_STATE
27942
27943 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27944 index 7609e0e..b449b98 100644
27945 --- a/arch/x86/lib/csum-wrappers_64.c
27946 +++ b/arch/x86/lib/csum-wrappers_64.c
27947 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27948 len -= 2;
27949 }
27950 }
27951 + pax_open_userland();
27952 stac();
27953 - isum = csum_partial_copy_generic((__force const void *)src,
27954 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27955 dst, len, isum, errp, NULL);
27956 clac();
27957 + pax_close_userland();
27958 if (unlikely(*errp))
27959 goto out_err;
27960
27961 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27962 }
27963
27964 *errp = 0;
27965 + pax_open_userland();
27966 stac();
27967 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27968 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27969 len, isum, NULL, errp);
27970 clac();
27971 + pax_close_userland();
27972 return ret;
27973 }
27974 EXPORT_SYMBOL(csum_partial_copy_to_user);
27975 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27976 index a451235..1daa956 100644
27977 --- a/arch/x86/lib/getuser.S
27978 +++ b/arch/x86/lib/getuser.S
27979 @@ -33,17 +33,40 @@
27980 #include <asm/thread_info.h>
27981 #include <asm/asm.h>
27982 #include <asm/smap.h>
27983 +#include <asm/segment.h>
27984 +#include <asm/pgtable.h>
27985 +#include <asm/alternative-asm.h>
27986 +
27987 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27988 +#define __copyuser_seg gs;
27989 +#else
27990 +#define __copyuser_seg
27991 +#endif
27992
27993 .text
27994 ENTRY(__get_user_1)
27995 CFI_STARTPROC
27996 +
27997 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27998 GET_THREAD_INFO(%_ASM_DX)
27999 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28000 jae bad_get_user
28001 ASM_STAC
28002 -1: movzbl (%_ASM_AX),%edx
28003 +
28004 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28005 + mov pax_user_shadow_base,%_ASM_DX
28006 + cmp %_ASM_DX,%_ASM_AX
28007 + jae 1234f
28008 + add %_ASM_DX,%_ASM_AX
28009 +1234:
28010 +#endif
28011 +
28012 +#endif
28013 +
28014 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28015 xor %eax,%eax
28016 ASM_CLAC
28017 + pax_force_retaddr
28018 ret
28019 CFI_ENDPROC
28020 ENDPROC(__get_user_1)
28021 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28022 ENTRY(__get_user_2)
28023 CFI_STARTPROC
28024 add $1,%_ASM_AX
28025 +
28026 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28027 jc bad_get_user
28028 GET_THREAD_INFO(%_ASM_DX)
28029 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28030 jae bad_get_user
28031 ASM_STAC
28032 -2: movzwl -1(%_ASM_AX),%edx
28033 +
28034 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28035 + mov pax_user_shadow_base,%_ASM_DX
28036 + cmp %_ASM_DX,%_ASM_AX
28037 + jae 1234f
28038 + add %_ASM_DX,%_ASM_AX
28039 +1234:
28040 +#endif
28041 +
28042 +#endif
28043 +
28044 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28045 xor %eax,%eax
28046 ASM_CLAC
28047 + pax_force_retaddr
28048 ret
28049 CFI_ENDPROC
28050 ENDPROC(__get_user_2)
28051 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28052 ENTRY(__get_user_4)
28053 CFI_STARTPROC
28054 add $3,%_ASM_AX
28055 +
28056 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28057 jc bad_get_user
28058 GET_THREAD_INFO(%_ASM_DX)
28059 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28060 jae bad_get_user
28061 ASM_STAC
28062 -3: movl -3(%_ASM_AX),%edx
28063 +
28064 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28065 + mov pax_user_shadow_base,%_ASM_DX
28066 + cmp %_ASM_DX,%_ASM_AX
28067 + jae 1234f
28068 + add %_ASM_DX,%_ASM_AX
28069 +1234:
28070 +#endif
28071 +
28072 +#endif
28073 +
28074 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28075 xor %eax,%eax
28076 ASM_CLAC
28077 + pax_force_retaddr
28078 ret
28079 CFI_ENDPROC
28080 ENDPROC(__get_user_4)
28081 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28082 GET_THREAD_INFO(%_ASM_DX)
28083 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28084 jae bad_get_user
28085 +
28086 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28087 + mov pax_user_shadow_base,%_ASM_DX
28088 + cmp %_ASM_DX,%_ASM_AX
28089 + jae 1234f
28090 + add %_ASM_DX,%_ASM_AX
28091 +1234:
28092 +#endif
28093 +
28094 ASM_STAC
28095 4: movq -7(%_ASM_AX),%rdx
28096 xor %eax,%eax
28097 ASM_CLAC
28098 + pax_force_retaddr
28099 ret
28100 #else
28101 add $7,%_ASM_AX
28102 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28103 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28104 jae bad_get_user_8
28105 ASM_STAC
28106 -4: movl -7(%_ASM_AX),%edx
28107 -5: movl -3(%_ASM_AX),%ecx
28108 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28109 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28110 xor %eax,%eax
28111 ASM_CLAC
28112 + pax_force_retaddr
28113 ret
28114 #endif
28115 CFI_ENDPROC
28116 @@ -113,6 +175,7 @@ bad_get_user:
28117 xor %edx,%edx
28118 mov $(-EFAULT),%_ASM_AX
28119 ASM_CLAC
28120 + pax_force_retaddr
28121 ret
28122 CFI_ENDPROC
28123 END(bad_get_user)
28124 @@ -124,6 +187,7 @@ bad_get_user_8:
28125 xor %ecx,%ecx
28126 mov $(-EFAULT),%_ASM_AX
28127 ASM_CLAC
28128 + pax_force_retaddr
28129 ret
28130 CFI_ENDPROC
28131 END(bad_get_user_8)
28132 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28133 index 54fcffe..7be149e 100644
28134 --- a/arch/x86/lib/insn.c
28135 +++ b/arch/x86/lib/insn.c
28136 @@ -20,8 +20,10 @@
28137
28138 #ifdef __KERNEL__
28139 #include <linux/string.h>
28140 +#include <asm/pgtable_types.h>
28141 #else
28142 #include <string.h>
28143 +#define ktla_ktva(addr) addr
28144 #endif
28145 #include <asm/inat.h>
28146 #include <asm/insn.h>
28147 @@ -53,8 +55,8 @@
28148 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28149 {
28150 memset(insn, 0, sizeof(*insn));
28151 - insn->kaddr = kaddr;
28152 - insn->next_byte = kaddr;
28153 + insn->kaddr = ktla_ktva(kaddr);
28154 + insn->next_byte = ktla_ktva(kaddr);
28155 insn->x86_64 = x86_64 ? 1 : 0;
28156 insn->opnd_bytes = 4;
28157 if (x86_64)
28158 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28159 index 05a95e7..326f2fa 100644
28160 --- a/arch/x86/lib/iomap_copy_64.S
28161 +++ b/arch/x86/lib/iomap_copy_64.S
28162 @@ -17,6 +17,7 @@
28163
28164 #include <linux/linkage.h>
28165 #include <asm/dwarf2.h>
28166 +#include <asm/alternative-asm.h>
28167
28168 /*
28169 * override generic version in lib/iomap_copy.c
28170 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28171 CFI_STARTPROC
28172 movl %edx,%ecx
28173 rep movsd
28174 + pax_force_retaddr
28175 ret
28176 CFI_ENDPROC
28177 ENDPROC(__iowrite32_copy)
28178 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28179 index 56313a3..9b59269 100644
28180 --- a/arch/x86/lib/memcpy_64.S
28181 +++ b/arch/x86/lib/memcpy_64.S
28182 @@ -24,7 +24,7 @@
28183 * This gets patched over the unrolled variant (below) via the
28184 * alternative instructions framework:
28185 */
28186 - .section .altinstr_replacement, "ax", @progbits
28187 + .section .altinstr_replacement, "a", @progbits
28188 .Lmemcpy_c:
28189 movq %rdi, %rax
28190 movq %rdx, %rcx
28191 @@ -33,6 +33,7 @@
28192 rep movsq
28193 movl %edx, %ecx
28194 rep movsb
28195 + pax_force_retaddr
28196 ret
28197 .Lmemcpy_e:
28198 .previous
28199 @@ -44,11 +45,12 @@
28200 * This gets patched over the unrolled variant (below) via the
28201 * alternative instructions framework:
28202 */
28203 - .section .altinstr_replacement, "ax", @progbits
28204 + .section .altinstr_replacement, "a", @progbits
28205 .Lmemcpy_c_e:
28206 movq %rdi, %rax
28207 movq %rdx, %rcx
28208 rep movsb
28209 + pax_force_retaddr
28210 ret
28211 .Lmemcpy_e_e:
28212 .previous
28213 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28214 */
28215 movq 0*8(%rsi), %r8
28216 movq 1*8(%rsi), %r9
28217 - movq 2*8(%rsi), %r10
28218 + movq 2*8(%rsi), %rcx
28219 movq 3*8(%rsi), %r11
28220 leaq 4*8(%rsi), %rsi
28221
28222 movq %r8, 0*8(%rdi)
28223 movq %r9, 1*8(%rdi)
28224 - movq %r10, 2*8(%rdi)
28225 + movq %rcx, 2*8(%rdi)
28226 movq %r11, 3*8(%rdi)
28227 leaq 4*8(%rdi), %rdi
28228 jae .Lcopy_forward_loop
28229 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28230 subq $0x20, %rdx
28231 movq -1*8(%rsi), %r8
28232 movq -2*8(%rsi), %r9
28233 - movq -3*8(%rsi), %r10
28234 + movq -3*8(%rsi), %rcx
28235 movq -4*8(%rsi), %r11
28236 leaq -4*8(%rsi), %rsi
28237 movq %r8, -1*8(%rdi)
28238 movq %r9, -2*8(%rdi)
28239 - movq %r10, -3*8(%rdi)
28240 + movq %rcx, -3*8(%rdi)
28241 movq %r11, -4*8(%rdi)
28242 leaq -4*8(%rdi), %rdi
28243 jae .Lcopy_backward_loop
28244 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28245 */
28246 movq 0*8(%rsi), %r8
28247 movq 1*8(%rsi), %r9
28248 - movq -2*8(%rsi, %rdx), %r10
28249 + movq -2*8(%rsi, %rdx), %rcx
28250 movq -1*8(%rsi, %rdx), %r11
28251 movq %r8, 0*8(%rdi)
28252 movq %r9, 1*8(%rdi)
28253 - movq %r10, -2*8(%rdi, %rdx)
28254 + movq %rcx, -2*8(%rdi, %rdx)
28255 movq %r11, -1*8(%rdi, %rdx)
28256 + pax_force_retaddr
28257 retq
28258 .p2align 4
28259 .Lless_16bytes:
28260 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28261 movq -1*8(%rsi, %rdx), %r9
28262 movq %r8, 0*8(%rdi)
28263 movq %r9, -1*8(%rdi, %rdx)
28264 + pax_force_retaddr
28265 retq
28266 .p2align 4
28267 .Lless_8bytes:
28268 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28269 movl -4(%rsi, %rdx), %r8d
28270 movl %ecx, (%rdi)
28271 movl %r8d, -4(%rdi, %rdx)
28272 + pax_force_retaddr
28273 retq
28274 .p2align 4
28275 .Lless_3bytes:
28276 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28277 movb %cl, (%rdi)
28278
28279 .Lend:
28280 + pax_force_retaddr
28281 retq
28282 CFI_ENDPROC
28283 ENDPROC(memcpy)
28284 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28285 index 65268a6..5aa7815 100644
28286 --- a/arch/x86/lib/memmove_64.S
28287 +++ b/arch/x86/lib/memmove_64.S
28288 @@ -61,13 +61,13 @@ ENTRY(memmove)
28289 5:
28290 sub $0x20, %rdx
28291 movq 0*8(%rsi), %r11
28292 - movq 1*8(%rsi), %r10
28293 + movq 1*8(%rsi), %rcx
28294 movq 2*8(%rsi), %r9
28295 movq 3*8(%rsi), %r8
28296 leaq 4*8(%rsi), %rsi
28297
28298 movq %r11, 0*8(%rdi)
28299 - movq %r10, 1*8(%rdi)
28300 + movq %rcx, 1*8(%rdi)
28301 movq %r9, 2*8(%rdi)
28302 movq %r8, 3*8(%rdi)
28303 leaq 4*8(%rdi), %rdi
28304 @@ -81,10 +81,10 @@ ENTRY(memmove)
28305 4:
28306 movq %rdx, %rcx
28307 movq -8(%rsi, %rdx), %r11
28308 - lea -8(%rdi, %rdx), %r10
28309 + lea -8(%rdi, %rdx), %r9
28310 shrq $3, %rcx
28311 rep movsq
28312 - movq %r11, (%r10)
28313 + movq %r11, (%r9)
28314 jmp 13f
28315 .Lmemmove_end_forward:
28316
28317 @@ -95,14 +95,14 @@ ENTRY(memmove)
28318 7:
28319 movq %rdx, %rcx
28320 movq (%rsi), %r11
28321 - movq %rdi, %r10
28322 + movq %rdi, %r9
28323 leaq -8(%rsi, %rdx), %rsi
28324 leaq -8(%rdi, %rdx), %rdi
28325 shrq $3, %rcx
28326 std
28327 rep movsq
28328 cld
28329 - movq %r11, (%r10)
28330 + movq %r11, (%r9)
28331 jmp 13f
28332
28333 /*
28334 @@ -127,13 +127,13 @@ ENTRY(memmove)
28335 8:
28336 subq $0x20, %rdx
28337 movq -1*8(%rsi), %r11
28338 - movq -2*8(%rsi), %r10
28339 + movq -2*8(%rsi), %rcx
28340 movq -3*8(%rsi), %r9
28341 movq -4*8(%rsi), %r8
28342 leaq -4*8(%rsi), %rsi
28343
28344 movq %r11, -1*8(%rdi)
28345 - movq %r10, -2*8(%rdi)
28346 + movq %rcx, -2*8(%rdi)
28347 movq %r9, -3*8(%rdi)
28348 movq %r8, -4*8(%rdi)
28349 leaq -4*8(%rdi), %rdi
28350 @@ -151,11 +151,11 @@ ENTRY(memmove)
28351 * Move data from 16 bytes to 31 bytes.
28352 */
28353 movq 0*8(%rsi), %r11
28354 - movq 1*8(%rsi), %r10
28355 + movq 1*8(%rsi), %rcx
28356 movq -2*8(%rsi, %rdx), %r9
28357 movq -1*8(%rsi, %rdx), %r8
28358 movq %r11, 0*8(%rdi)
28359 - movq %r10, 1*8(%rdi)
28360 + movq %rcx, 1*8(%rdi)
28361 movq %r9, -2*8(%rdi, %rdx)
28362 movq %r8, -1*8(%rdi, %rdx)
28363 jmp 13f
28364 @@ -167,9 +167,9 @@ ENTRY(memmove)
28365 * Move data from 8 bytes to 15 bytes.
28366 */
28367 movq 0*8(%rsi), %r11
28368 - movq -1*8(%rsi, %rdx), %r10
28369 + movq -1*8(%rsi, %rdx), %r9
28370 movq %r11, 0*8(%rdi)
28371 - movq %r10, -1*8(%rdi, %rdx)
28372 + movq %r9, -1*8(%rdi, %rdx)
28373 jmp 13f
28374 10:
28375 cmpq $4, %rdx
28376 @@ -178,9 +178,9 @@ ENTRY(memmove)
28377 * Move data from 4 bytes to 7 bytes.
28378 */
28379 movl (%rsi), %r11d
28380 - movl -4(%rsi, %rdx), %r10d
28381 + movl -4(%rsi, %rdx), %r9d
28382 movl %r11d, (%rdi)
28383 - movl %r10d, -4(%rdi, %rdx)
28384 + movl %r9d, -4(%rdi, %rdx)
28385 jmp 13f
28386 11:
28387 cmp $2, %rdx
28388 @@ -189,9 +189,9 @@ ENTRY(memmove)
28389 * Move data from 2 bytes to 3 bytes.
28390 */
28391 movw (%rsi), %r11w
28392 - movw -2(%rsi, %rdx), %r10w
28393 + movw -2(%rsi, %rdx), %r9w
28394 movw %r11w, (%rdi)
28395 - movw %r10w, -2(%rdi, %rdx)
28396 + movw %r9w, -2(%rdi, %rdx)
28397 jmp 13f
28398 12:
28399 cmp $1, %rdx
28400 @@ -202,14 +202,16 @@ ENTRY(memmove)
28401 movb (%rsi), %r11b
28402 movb %r11b, (%rdi)
28403 13:
28404 + pax_force_retaddr
28405 retq
28406 CFI_ENDPROC
28407
28408 - .section .altinstr_replacement,"ax"
28409 + .section .altinstr_replacement,"a"
28410 .Lmemmove_begin_forward_efs:
28411 /* Forward moving data. */
28412 movq %rdx, %rcx
28413 rep movsb
28414 + pax_force_retaddr
28415 retq
28416 .Lmemmove_end_forward_efs:
28417 .previous
28418 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28419 index 2dcb380..50a78bc 100644
28420 --- a/arch/x86/lib/memset_64.S
28421 +++ b/arch/x86/lib/memset_64.S
28422 @@ -16,7 +16,7 @@
28423 *
28424 * rax original destination
28425 */
28426 - .section .altinstr_replacement, "ax", @progbits
28427 + .section .altinstr_replacement, "a", @progbits
28428 .Lmemset_c:
28429 movq %rdi,%r9
28430 movq %rdx,%rcx
28431 @@ -30,6 +30,7 @@
28432 movl %edx,%ecx
28433 rep stosb
28434 movq %r9,%rax
28435 + pax_force_retaddr
28436 ret
28437 .Lmemset_e:
28438 .previous
28439 @@ -45,13 +46,14 @@
28440 *
28441 * rax original destination
28442 */
28443 - .section .altinstr_replacement, "ax", @progbits
28444 + .section .altinstr_replacement, "a", @progbits
28445 .Lmemset_c_e:
28446 movq %rdi,%r9
28447 movb %sil,%al
28448 movq %rdx,%rcx
28449 rep stosb
28450 movq %r9,%rax
28451 + pax_force_retaddr
28452 ret
28453 .Lmemset_e_e:
28454 .previous
28455 @@ -59,7 +61,7 @@
28456 ENTRY(memset)
28457 ENTRY(__memset)
28458 CFI_STARTPROC
28459 - movq %rdi,%r10
28460 + movq %rdi,%r11
28461
28462 /* expand byte value */
28463 movzbl %sil,%ecx
28464 @@ -117,7 +119,8 @@ ENTRY(__memset)
28465 jnz .Lloop_1
28466
28467 .Lende:
28468 - movq %r10,%rax
28469 + movq %r11,%rax
28470 + pax_force_retaddr
28471 ret
28472
28473 CFI_RESTORE_STATE
28474 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28475 index c9f2d9b..e7fd2c0 100644
28476 --- a/arch/x86/lib/mmx_32.c
28477 +++ b/arch/x86/lib/mmx_32.c
28478 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28479 {
28480 void *p;
28481 int i;
28482 + unsigned long cr0;
28483
28484 if (unlikely(in_interrupt()))
28485 return __memcpy(to, from, len);
28486 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28487 kernel_fpu_begin();
28488
28489 __asm__ __volatile__ (
28490 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28491 - " prefetch 64(%0)\n"
28492 - " prefetch 128(%0)\n"
28493 - " prefetch 192(%0)\n"
28494 - " prefetch 256(%0)\n"
28495 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28496 + " prefetch 64(%1)\n"
28497 + " prefetch 128(%1)\n"
28498 + " prefetch 192(%1)\n"
28499 + " prefetch 256(%1)\n"
28500 "2: \n"
28501 ".section .fixup, \"ax\"\n"
28502 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28503 + "3: \n"
28504 +
28505 +#ifdef CONFIG_PAX_KERNEXEC
28506 + " movl %%cr0, %0\n"
28507 + " movl %0, %%eax\n"
28508 + " andl $0xFFFEFFFF, %%eax\n"
28509 + " movl %%eax, %%cr0\n"
28510 +#endif
28511 +
28512 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28513 +
28514 +#ifdef CONFIG_PAX_KERNEXEC
28515 + " movl %0, %%cr0\n"
28516 +#endif
28517 +
28518 " jmp 2b\n"
28519 ".previous\n"
28520 _ASM_EXTABLE(1b, 3b)
28521 - : : "r" (from));
28522 + : "=&r" (cr0) : "r" (from) : "ax");
28523
28524 for ( ; i > 5; i--) {
28525 __asm__ __volatile__ (
28526 - "1: prefetch 320(%0)\n"
28527 - "2: movq (%0), %%mm0\n"
28528 - " movq 8(%0), %%mm1\n"
28529 - " movq 16(%0), %%mm2\n"
28530 - " movq 24(%0), %%mm3\n"
28531 - " movq %%mm0, (%1)\n"
28532 - " movq %%mm1, 8(%1)\n"
28533 - " movq %%mm2, 16(%1)\n"
28534 - " movq %%mm3, 24(%1)\n"
28535 - " movq 32(%0), %%mm0\n"
28536 - " movq 40(%0), %%mm1\n"
28537 - " movq 48(%0), %%mm2\n"
28538 - " movq 56(%0), %%mm3\n"
28539 - " movq %%mm0, 32(%1)\n"
28540 - " movq %%mm1, 40(%1)\n"
28541 - " movq %%mm2, 48(%1)\n"
28542 - " movq %%mm3, 56(%1)\n"
28543 + "1: prefetch 320(%1)\n"
28544 + "2: movq (%1), %%mm0\n"
28545 + " movq 8(%1), %%mm1\n"
28546 + " movq 16(%1), %%mm2\n"
28547 + " movq 24(%1), %%mm3\n"
28548 + " movq %%mm0, (%2)\n"
28549 + " movq %%mm1, 8(%2)\n"
28550 + " movq %%mm2, 16(%2)\n"
28551 + " movq %%mm3, 24(%2)\n"
28552 + " movq 32(%1), %%mm0\n"
28553 + " movq 40(%1), %%mm1\n"
28554 + " movq 48(%1), %%mm2\n"
28555 + " movq 56(%1), %%mm3\n"
28556 + " movq %%mm0, 32(%2)\n"
28557 + " movq %%mm1, 40(%2)\n"
28558 + " movq %%mm2, 48(%2)\n"
28559 + " movq %%mm3, 56(%2)\n"
28560 ".section .fixup, \"ax\"\n"
28561 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28562 + "3:\n"
28563 +
28564 +#ifdef CONFIG_PAX_KERNEXEC
28565 + " movl %%cr0, %0\n"
28566 + " movl %0, %%eax\n"
28567 + " andl $0xFFFEFFFF, %%eax\n"
28568 + " movl %%eax, %%cr0\n"
28569 +#endif
28570 +
28571 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28572 +
28573 +#ifdef CONFIG_PAX_KERNEXEC
28574 + " movl %0, %%cr0\n"
28575 +#endif
28576 +
28577 " jmp 2b\n"
28578 ".previous\n"
28579 _ASM_EXTABLE(1b, 3b)
28580 - : : "r" (from), "r" (to) : "memory");
28581 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28582
28583 from += 64;
28584 to += 64;
28585 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28586 static void fast_copy_page(void *to, void *from)
28587 {
28588 int i;
28589 + unsigned long cr0;
28590
28591 kernel_fpu_begin();
28592
28593 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28594 * but that is for later. -AV
28595 */
28596 __asm__ __volatile__(
28597 - "1: prefetch (%0)\n"
28598 - " prefetch 64(%0)\n"
28599 - " prefetch 128(%0)\n"
28600 - " prefetch 192(%0)\n"
28601 - " prefetch 256(%0)\n"
28602 + "1: prefetch (%1)\n"
28603 + " prefetch 64(%1)\n"
28604 + " prefetch 128(%1)\n"
28605 + " prefetch 192(%1)\n"
28606 + " prefetch 256(%1)\n"
28607 "2: \n"
28608 ".section .fixup, \"ax\"\n"
28609 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28610 + "3: \n"
28611 +
28612 +#ifdef CONFIG_PAX_KERNEXEC
28613 + " movl %%cr0, %0\n"
28614 + " movl %0, %%eax\n"
28615 + " andl $0xFFFEFFFF, %%eax\n"
28616 + " movl %%eax, %%cr0\n"
28617 +#endif
28618 +
28619 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28620 +
28621 +#ifdef CONFIG_PAX_KERNEXEC
28622 + " movl %0, %%cr0\n"
28623 +#endif
28624 +
28625 " jmp 2b\n"
28626 ".previous\n"
28627 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28628 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28629
28630 for (i = 0; i < (4096-320)/64; i++) {
28631 __asm__ __volatile__ (
28632 - "1: prefetch 320(%0)\n"
28633 - "2: movq (%0), %%mm0\n"
28634 - " movntq %%mm0, (%1)\n"
28635 - " movq 8(%0), %%mm1\n"
28636 - " movntq %%mm1, 8(%1)\n"
28637 - " movq 16(%0), %%mm2\n"
28638 - " movntq %%mm2, 16(%1)\n"
28639 - " movq 24(%0), %%mm3\n"
28640 - " movntq %%mm3, 24(%1)\n"
28641 - " movq 32(%0), %%mm4\n"
28642 - " movntq %%mm4, 32(%1)\n"
28643 - " movq 40(%0), %%mm5\n"
28644 - " movntq %%mm5, 40(%1)\n"
28645 - " movq 48(%0), %%mm6\n"
28646 - " movntq %%mm6, 48(%1)\n"
28647 - " movq 56(%0), %%mm7\n"
28648 - " movntq %%mm7, 56(%1)\n"
28649 + "1: prefetch 320(%1)\n"
28650 + "2: movq (%1), %%mm0\n"
28651 + " movntq %%mm0, (%2)\n"
28652 + " movq 8(%1), %%mm1\n"
28653 + " movntq %%mm1, 8(%2)\n"
28654 + " movq 16(%1), %%mm2\n"
28655 + " movntq %%mm2, 16(%2)\n"
28656 + " movq 24(%1), %%mm3\n"
28657 + " movntq %%mm3, 24(%2)\n"
28658 + " movq 32(%1), %%mm4\n"
28659 + " movntq %%mm4, 32(%2)\n"
28660 + " movq 40(%1), %%mm5\n"
28661 + " movntq %%mm5, 40(%2)\n"
28662 + " movq 48(%1), %%mm6\n"
28663 + " movntq %%mm6, 48(%2)\n"
28664 + " movq 56(%1), %%mm7\n"
28665 + " movntq %%mm7, 56(%2)\n"
28666 ".section .fixup, \"ax\"\n"
28667 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28668 + "3:\n"
28669 +
28670 +#ifdef CONFIG_PAX_KERNEXEC
28671 + " movl %%cr0, %0\n"
28672 + " movl %0, %%eax\n"
28673 + " andl $0xFFFEFFFF, %%eax\n"
28674 + " movl %%eax, %%cr0\n"
28675 +#endif
28676 +
28677 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28678 +
28679 +#ifdef CONFIG_PAX_KERNEXEC
28680 + " movl %0, %%cr0\n"
28681 +#endif
28682 +
28683 " jmp 2b\n"
28684 ".previous\n"
28685 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28686 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28687
28688 from += 64;
28689 to += 64;
28690 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28691 static void fast_copy_page(void *to, void *from)
28692 {
28693 int i;
28694 + unsigned long cr0;
28695
28696 kernel_fpu_begin();
28697
28698 __asm__ __volatile__ (
28699 - "1: prefetch (%0)\n"
28700 - " prefetch 64(%0)\n"
28701 - " prefetch 128(%0)\n"
28702 - " prefetch 192(%0)\n"
28703 - " prefetch 256(%0)\n"
28704 + "1: prefetch (%1)\n"
28705 + " prefetch 64(%1)\n"
28706 + " prefetch 128(%1)\n"
28707 + " prefetch 192(%1)\n"
28708 + " prefetch 256(%1)\n"
28709 "2: \n"
28710 ".section .fixup, \"ax\"\n"
28711 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28712 + "3: \n"
28713 +
28714 +#ifdef CONFIG_PAX_KERNEXEC
28715 + " movl %%cr0, %0\n"
28716 + " movl %0, %%eax\n"
28717 + " andl $0xFFFEFFFF, %%eax\n"
28718 + " movl %%eax, %%cr0\n"
28719 +#endif
28720 +
28721 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28722 +
28723 +#ifdef CONFIG_PAX_KERNEXEC
28724 + " movl %0, %%cr0\n"
28725 +#endif
28726 +
28727 " jmp 2b\n"
28728 ".previous\n"
28729 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28730 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28731
28732 for (i = 0; i < 4096/64; i++) {
28733 __asm__ __volatile__ (
28734 - "1: prefetch 320(%0)\n"
28735 - "2: movq (%0), %%mm0\n"
28736 - " movq 8(%0), %%mm1\n"
28737 - " movq 16(%0), %%mm2\n"
28738 - " movq 24(%0), %%mm3\n"
28739 - " movq %%mm0, (%1)\n"
28740 - " movq %%mm1, 8(%1)\n"
28741 - " movq %%mm2, 16(%1)\n"
28742 - " movq %%mm3, 24(%1)\n"
28743 - " movq 32(%0), %%mm0\n"
28744 - " movq 40(%0), %%mm1\n"
28745 - " movq 48(%0), %%mm2\n"
28746 - " movq 56(%0), %%mm3\n"
28747 - " movq %%mm0, 32(%1)\n"
28748 - " movq %%mm1, 40(%1)\n"
28749 - " movq %%mm2, 48(%1)\n"
28750 - " movq %%mm3, 56(%1)\n"
28751 + "1: prefetch 320(%1)\n"
28752 + "2: movq (%1), %%mm0\n"
28753 + " movq 8(%1), %%mm1\n"
28754 + " movq 16(%1), %%mm2\n"
28755 + " movq 24(%1), %%mm3\n"
28756 + " movq %%mm0, (%2)\n"
28757 + " movq %%mm1, 8(%2)\n"
28758 + " movq %%mm2, 16(%2)\n"
28759 + " movq %%mm3, 24(%2)\n"
28760 + " movq 32(%1), %%mm0\n"
28761 + " movq 40(%1), %%mm1\n"
28762 + " movq 48(%1), %%mm2\n"
28763 + " movq 56(%1), %%mm3\n"
28764 + " movq %%mm0, 32(%2)\n"
28765 + " movq %%mm1, 40(%2)\n"
28766 + " movq %%mm2, 48(%2)\n"
28767 + " movq %%mm3, 56(%2)\n"
28768 ".section .fixup, \"ax\"\n"
28769 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28770 + "3:\n"
28771 +
28772 +#ifdef CONFIG_PAX_KERNEXEC
28773 + " movl %%cr0, %0\n"
28774 + " movl %0, %%eax\n"
28775 + " andl $0xFFFEFFFF, %%eax\n"
28776 + " movl %%eax, %%cr0\n"
28777 +#endif
28778 +
28779 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28780 +
28781 +#ifdef CONFIG_PAX_KERNEXEC
28782 + " movl %0, %%cr0\n"
28783 +#endif
28784 +
28785 " jmp 2b\n"
28786 ".previous\n"
28787 _ASM_EXTABLE(1b, 3b)
28788 - : : "r" (from), "r" (to) : "memory");
28789 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28790
28791 from += 64;
28792 to += 64;
28793 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28794 index f6d13ee..aca5f0b 100644
28795 --- a/arch/x86/lib/msr-reg.S
28796 +++ b/arch/x86/lib/msr-reg.S
28797 @@ -3,6 +3,7 @@
28798 #include <asm/dwarf2.h>
28799 #include <asm/asm.h>
28800 #include <asm/msr.h>
28801 +#include <asm/alternative-asm.h>
28802
28803 #ifdef CONFIG_X86_64
28804 /*
28805 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28806 CFI_STARTPROC
28807 pushq_cfi %rbx
28808 pushq_cfi %rbp
28809 - movq %rdi, %r10 /* Save pointer */
28810 + movq %rdi, %r9 /* Save pointer */
28811 xorl %r11d, %r11d /* Return value */
28812 movl (%rdi), %eax
28813 movl 4(%rdi), %ecx
28814 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28815 movl 28(%rdi), %edi
28816 CFI_REMEMBER_STATE
28817 1: \op
28818 -2: movl %eax, (%r10)
28819 +2: movl %eax, (%r9)
28820 movl %r11d, %eax /* Return value */
28821 - movl %ecx, 4(%r10)
28822 - movl %edx, 8(%r10)
28823 - movl %ebx, 12(%r10)
28824 - movl %ebp, 20(%r10)
28825 - movl %esi, 24(%r10)
28826 - movl %edi, 28(%r10)
28827 + movl %ecx, 4(%r9)
28828 + movl %edx, 8(%r9)
28829 + movl %ebx, 12(%r9)
28830 + movl %ebp, 20(%r9)
28831 + movl %esi, 24(%r9)
28832 + movl %edi, 28(%r9)
28833 popq_cfi %rbp
28834 popq_cfi %rbx
28835 + pax_force_retaddr
28836 ret
28837 3:
28838 CFI_RESTORE_STATE
28839 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28840 index fc6ba17..d4d989d 100644
28841 --- a/arch/x86/lib/putuser.S
28842 +++ b/arch/x86/lib/putuser.S
28843 @@ -16,7 +16,9 @@
28844 #include <asm/errno.h>
28845 #include <asm/asm.h>
28846 #include <asm/smap.h>
28847 -
28848 +#include <asm/segment.h>
28849 +#include <asm/pgtable.h>
28850 +#include <asm/alternative-asm.h>
28851
28852 /*
28853 * __put_user_X
28854 @@ -30,57 +32,125 @@
28855 * as they get called from within inline assembly.
28856 */
28857
28858 -#define ENTER CFI_STARTPROC ; \
28859 - GET_THREAD_INFO(%_ASM_BX)
28860 -#define EXIT ASM_CLAC ; \
28861 - ret ; \
28862 +#define ENTER CFI_STARTPROC
28863 +#define EXIT ASM_CLAC ; \
28864 + pax_force_retaddr ; \
28865 + ret ; \
28866 CFI_ENDPROC
28867
28868 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28869 +#define _DEST %_ASM_CX,%_ASM_BX
28870 +#else
28871 +#define _DEST %_ASM_CX
28872 +#endif
28873 +
28874 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28875 +#define __copyuser_seg gs;
28876 +#else
28877 +#define __copyuser_seg
28878 +#endif
28879 +
28880 .text
28881 ENTRY(__put_user_1)
28882 ENTER
28883 +
28884 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28885 + GET_THREAD_INFO(%_ASM_BX)
28886 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28887 jae bad_put_user
28888 ASM_STAC
28889 -1: movb %al,(%_ASM_CX)
28890 +
28891 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28892 + mov pax_user_shadow_base,%_ASM_BX
28893 + cmp %_ASM_BX,%_ASM_CX
28894 + jb 1234f
28895 + xor %ebx,%ebx
28896 +1234:
28897 +#endif
28898 +
28899 +#endif
28900 +
28901 +1: __copyuser_seg movb %al,(_DEST)
28902 xor %eax,%eax
28903 EXIT
28904 ENDPROC(__put_user_1)
28905
28906 ENTRY(__put_user_2)
28907 ENTER
28908 +
28909 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28910 + GET_THREAD_INFO(%_ASM_BX)
28911 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28912 sub $1,%_ASM_BX
28913 cmp %_ASM_BX,%_ASM_CX
28914 jae bad_put_user
28915 ASM_STAC
28916 -2: movw %ax,(%_ASM_CX)
28917 +
28918 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28919 + mov pax_user_shadow_base,%_ASM_BX
28920 + cmp %_ASM_BX,%_ASM_CX
28921 + jb 1234f
28922 + xor %ebx,%ebx
28923 +1234:
28924 +#endif
28925 +
28926 +#endif
28927 +
28928 +2: __copyuser_seg movw %ax,(_DEST)
28929 xor %eax,%eax
28930 EXIT
28931 ENDPROC(__put_user_2)
28932
28933 ENTRY(__put_user_4)
28934 ENTER
28935 +
28936 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28937 + GET_THREAD_INFO(%_ASM_BX)
28938 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28939 sub $3,%_ASM_BX
28940 cmp %_ASM_BX,%_ASM_CX
28941 jae bad_put_user
28942 ASM_STAC
28943 -3: movl %eax,(%_ASM_CX)
28944 +
28945 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28946 + mov pax_user_shadow_base,%_ASM_BX
28947 + cmp %_ASM_BX,%_ASM_CX
28948 + jb 1234f
28949 + xor %ebx,%ebx
28950 +1234:
28951 +#endif
28952 +
28953 +#endif
28954 +
28955 +3: __copyuser_seg movl %eax,(_DEST)
28956 xor %eax,%eax
28957 EXIT
28958 ENDPROC(__put_user_4)
28959
28960 ENTRY(__put_user_8)
28961 ENTER
28962 +
28963 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28964 + GET_THREAD_INFO(%_ASM_BX)
28965 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28966 sub $7,%_ASM_BX
28967 cmp %_ASM_BX,%_ASM_CX
28968 jae bad_put_user
28969 ASM_STAC
28970 -4: mov %_ASM_AX,(%_ASM_CX)
28971 +
28972 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28973 + mov pax_user_shadow_base,%_ASM_BX
28974 + cmp %_ASM_BX,%_ASM_CX
28975 + jb 1234f
28976 + xor %ebx,%ebx
28977 +1234:
28978 +#endif
28979 +
28980 +#endif
28981 +
28982 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28983 #ifdef CONFIG_X86_32
28984 -5: movl %edx,4(%_ASM_CX)
28985 +5: __copyuser_seg movl %edx,4(_DEST)
28986 #endif
28987 xor %eax,%eax
28988 EXIT
28989 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28990 index 1cad221..de671ee 100644
28991 --- a/arch/x86/lib/rwlock.S
28992 +++ b/arch/x86/lib/rwlock.S
28993 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28994 FRAME
28995 0: LOCK_PREFIX
28996 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28997 +
28998 +#ifdef CONFIG_PAX_REFCOUNT
28999 + jno 1234f
29000 + LOCK_PREFIX
29001 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29002 + int $4
29003 +1234:
29004 + _ASM_EXTABLE(1234b, 1234b)
29005 +#endif
29006 +
29007 1: rep; nop
29008 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29009 jne 1b
29010 LOCK_PREFIX
29011 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29012 +
29013 +#ifdef CONFIG_PAX_REFCOUNT
29014 + jno 1234f
29015 + LOCK_PREFIX
29016 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29017 + int $4
29018 +1234:
29019 + _ASM_EXTABLE(1234b, 1234b)
29020 +#endif
29021 +
29022 jnz 0b
29023 ENDFRAME
29024 + pax_force_retaddr
29025 ret
29026 CFI_ENDPROC
29027 END(__write_lock_failed)
29028 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29029 FRAME
29030 0: LOCK_PREFIX
29031 READ_LOCK_SIZE(inc) (%__lock_ptr)
29032 +
29033 +#ifdef CONFIG_PAX_REFCOUNT
29034 + jno 1234f
29035 + LOCK_PREFIX
29036 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29037 + int $4
29038 +1234:
29039 + _ASM_EXTABLE(1234b, 1234b)
29040 +#endif
29041 +
29042 1: rep; nop
29043 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29044 js 1b
29045 LOCK_PREFIX
29046 READ_LOCK_SIZE(dec) (%__lock_ptr)
29047 +
29048 +#ifdef CONFIG_PAX_REFCOUNT
29049 + jno 1234f
29050 + LOCK_PREFIX
29051 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29052 + int $4
29053 +1234:
29054 + _ASM_EXTABLE(1234b, 1234b)
29055 +#endif
29056 +
29057 js 0b
29058 ENDFRAME
29059 + pax_force_retaddr
29060 ret
29061 CFI_ENDPROC
29062 END(__read_lock_failed)
29063 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29064 index 5dff5f0..cadebf4 100644
29065 --- a/arch/x86/lib/rwsem.S
29066 +++ b/arch/x86/lib/rwsem.S
29067 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29068 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29069 CFI_RESTORE __ASM_REG(dx)
29070 restore_common_regs
29071 + pax_force_retaddr
29072 ret
29073 CFI_ENDPROC
29074 ENDPROC(call_rwsem_down_read_failed)
29075 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29076 movq %rax,%rdi
29077 call rwsem_down_write_failed
29078 restore_common_regs
29079 + pax_force_retaddr
29080 ret
29081 CFI_ENDPROC
29082 ENDPROC(call_rwsem_down_write_failed)
29083 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29084 movq %rax,%rdi
29085 call rwsem_wake
29086 restore_common_regs
29087 -1: ret
29088 +1: pax_force_retaddr
29089 + ret
29090 CFI_ENDPROC
29091 ENDPROC(call_rwsem_wake)
29092
29093 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29094 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29095 CFI_RESTORE __ASM_REG(dx)
29096 restore_common_regs
29097 + pax_force_retaddr
29098 ret
29099 CFI_ENDPROC
29100 ENDPROC(call_rwsem_downgrade_wake)
29101 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29102 index a63efd6..ccecad8 100644
29103 --- a/arch/x86/lib/thunk_64.S
29104 +++ b/arch/x86/lib/thunk_64.S
29105 @@ -8,6 +8,7 @@
29106 #include <linux/linkage.h>
29107 #include <asm/dwarf2.h>
29108 #include <asm/calling.h>
29109 +#include <asm/alternative-asm.h>
29110
29111 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29112 .macro THUNK name, func, put_ret_addr_in_rdi=0
29113 @@ -41,5 +42,6 @@
29114 SAVE_ARGS
29115 restore:
29116 RESTORE_ARGS
29117 + pax_force_retaddr
29118 ret
29119 CFI_ENDPROC
29120 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29121 index 3eb18ac..6890bc3 100644
29122 --- a/arch/x86/lib/usercopy_32.c
29123 +++ b/arch/x86/lib/usercopy_32.c
29124 @@ -42,11 +42,13 @@ do { \
29125 int __d0; \
29126 might_fault(); \
29127 __asm__ __volatile__( \
29128 + __COPYUSER_SET_ES \
29129 ASM_STAC "\n" \
29130 "0: rep; stosl\n" \
29131 " movl %2,%0\n" \
29132 "1: rep; stosb\n" \
29133 "2: " ASM_CLAC "\n" \
29134 + __COPYUSER_RESTORE_ES \
29135 ".section .fixup,\"ax\"\n" \
29136 "3: lea 0(%2,%0,4),%0\n" \
29137 " jmp 2b\n" \
29138 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29139
29140 #ifdef CONFIG_X86_INTEL_USERCOPY
29141 static unsigned long
29142 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29143 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29144 {
29145 int d0, d1;
29146 __asm__ __volatile__(
29147 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29148 " .align 2,0x90\n"
29149 "3: movl 0(%4), %%eax\n"
29150 "4: movl 4(%4), %%edx\n"
29151 - "5: movl %%eax, 0(%3)\n"
29152 - "6: movl %%edx, 4(%3)\n"
29153 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29154 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29155 "7: movl 8(%4), %%eax\n"
29156 "8: movl 12(%4),%%edx\n"
29157 - "9: movl %%eax, 8(%3)\n"
29158 - "10: movl %%edx, 12(%3)\n"
29159 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29160 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29161 "11: movl 16(%4), %%eax\n"
29162 "12: movl 20(%4), %%edx\n"
29163 - "13: movl %%eax, 16(%3)\n"
29164 - "14: movl %%edx, 20(%3)\n"
29165 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29166 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29167 "15: movl 24(%4), %%eax\n"
29168 "16: movl 28(%4), %%edx\n"
29169 - "17: movl %%eax, 24(%3)\n"
29170 - "18: movl %%edx, 28(%3)\n"
29171 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29172 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29173 "19: movl 32(%4), %%eax\n"
29174 "20: movl 36(%4), %%edx\n"
29175 - "21: movl %%eax, 32(%3)\n"
29176 - "22: movl %%edx, 36(%3)\n"
29177 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29178 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29179 "23: movl 40(%4), %%eax\n"
29180 "24: movl 44(%4), %%edx\n"
29181 - "25: movl %%eax, 40(%3)\n"
29182 - "26: movl %%edx, 44(%3)\n"
29183 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29184 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29185 "27: movl 48(%4), %%eax\n"
29186 "28: movl 52(%4), %%edx\n"
29187 - "29: movl %%eax, 48(%3)\n"
29188 - "30: movl %%edx, 52(%3)\n"
29189 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29190 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29191 "31: movl 56(%4), %%eax\n"
29192 "32: movl 60(%4), %%edx\n"
29193 - "33: movl %%eax, 56(%3)\n"
29194 - "34: movl %%edx, 60(%3)\n"
29195 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29196 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29197 " addl $-64, %0\n"
29198 " addl $64, %4\n"
29199 " addl $64, %3\n"
29200 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29201 " shrl $2, %0\n"
29202 " andl $3, %%eax\n"
29203 " cld\n"
29204 + __COPYUSER_SET_ES
29205 "99: rep; movsl\n"
29206 "36: movl %%eax, %0\n"
29207 "37: rep; movsb\n"
29208 "100:\n"
29209 + __COPYUSER_RESTORE_ES
29210 ".section .fixup,\"ax\"\n"
29211 "101: lea 0(%%eax,%0,4),%0\n"
29212 " jmp 100b\n"
29213 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29214 }
29215
29216 static unsigned long
29217 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29218 +{
29219 + int d0, d1;
29220 + __asm__ __volatile__(
29221 + " .align 2,0x90\n"
29222 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29223 + " cmpl $67, %0\n"
29224 + " jbe 3f\n"
29225 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29226 + " .align 2,0x90\n"
29227 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29228 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29229 + "5: movl %%eax, 0(%3)\n"
29230 + "6: movl %%edx, 4(%3)\n"
29231 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29232 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29233 + "9: movl %%eax, 8(%3)\n"
29234 + "10: movl %%edx, 12(%3)\n"
29235 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29236 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29237 + "13: movl %%eax, 16(%3)\n"
29238 + "14: movl %%edx, 20(%3)\n"
29239 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29240 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29241 + "17: movl %%eax, 24(%3)\n"
29242 + "18: movl %%edx, 28(%3)\n"
29243 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29244 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29245 + "21: movl %%eax, 32(%3)\n"
29246 + "22: movl %%edx, 36(%3)\n"
29247 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29248 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29249 + "25: movl %%eax, 40(%3)\n"
29250 + "26: movl %%edx, 44(%3)\n"
29251 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29252 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29253 + "29: movl %%eax, 48(%3)\n"
29254 + "30: movl %%edx, 52(%3)\n"
29255 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29256 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29257 + "33: movl %%eax, 56(%3)\n"
29258 + "34: movl %%edx, 60(%3)\n"
29259 + " addl $-64, %0\n"
29260 + " addl $64, %4\n"
29261 + " addl $64, %3\n"
29262 + " cmpl $63, %0\n"
29263 + " ja 1b\n"
29264 + "35: movl %0, %%eax\n"
29265 + " shrl $2, %0\n"
29266 + " andl $3, %%eax\n"
29267 + " cld\n"
29268 + "99: rep; "__copyuser_seg" movsl\n"
29269 + "36: movl %%eax, %0\n"
29270 + "37: rep; "__copyuser_seg" movsb\n"
29271 + "100:\n"
29272 + ".section .fixup,\"ax\"\n"
29273 + "101: lea 0(%%eax,%0,4),%0\n"
29274 + " jmp 100b\n"
29275 + ".previous\n"
29276 + _ASM_EXTABLE(1b,100b)
29277 + _ASM_EXTABLE(2b,100b)
29278 + _ASM_EXTABLE(3b,100b)
29279 + _ASM_EXTABLE(4b,100b)
29280 + _ASM_EXTABLE(5b,100b)
29281 + _ASM_EXTABLE(6b,100b)
29282 + _ASM_EXTABLE(7b,100b)
29283 + _ASM_EXTABLE(8b,100b)
29284 + _ASM_EXTABLE(9b,100b)
29285 + _ASM_EXTABLE(10b,100b)
29286 + _ASM_EXTABLE(11b,100b)
29287 + _ASM_EXTABLE(12b,100b)
29288 + _ASM_EXTABLE(13b,100b)
29289 + _ASM_EXTABLE(14b,100b)
29290 + _ASM_EXTABLE(15b,100b)
29291 + _ASM_EXTABLE(16b,100b)
29292 + _ASM_EXTABLE(17b,100b)
29293 + _ASM_EXTABLE(18b,100b)
29294 + _ASM_EXTABLE(19b,100b)
29295 + _ASM_EXTABLE(20b,100b)
29296 + _ASM_EXTABLE(21b,100b)
29297 + _ASM_EXTABLE(22b,100b)
29298 + _ASM_EXTABLE(23b,100b)
29299 + _ASM_EXTABLE(24b,100b)
29300 + _ASM_EXTABLE(25b,100b)
29301 + _ASM_EXTABLE(26b,100b)
29302 + _ASM_EXTABLE(27b,100b)
29303 + _ASM_EXTABLE(28b,100b)
29304 + _ASM_EXTABLE(29b,100b)
29305 + _ASM_EXTABLE(30b,100b)
29306 + _ASM_EXTABLE(31b,100b)
29307 + _ASM_EXTABLE(32b,100b)
29308 + _ASM_EXTABLE(33b,100b)
29309 + _ASM_EXTABLE(34b,100b)
29310 + _ASM_EXTABLE(35b,100b)
29311 + _ASM_EXTABLE(36b,100b)
29312 + _ASM_EXTABLE(37b,100b)
29313 + _ASM_EXTABLE(99b,101b)
29314 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29315 + : "1"(to), "2"(from), "0"(size)
29316 + : "eax", "edx", "memory");
29317 + return size;
29318 +}
29319 +
29320 +static unsigned long __size_overflow(3)
29321 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29322 {
29323 int d0, d1;
29324 __asm__ __volatile__(
29325 " .align 2,0x90\n"
29326 - "0: movl 32(%4), %%eax\n"
29327 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29328 " cmpl $67, %0\n"
29329 " jbe 2f\n"
29330 - "1: movl 64(%4), %%eax\n"
29331 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29332 " .align 2,0x90\n"
29333 - "2: movl 0(%4), %%eax\n"
29334 - "21: movl 4(%4), %%edx\n"
29335 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29336 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29337 " movl %%eax, 0(%3)\n"
29338 " movl %%edx, 4(%3)\n"
29339 - "3: movl 8(%4), %%eax\n"
29340 - "31: movl 12(%4),%%edx\n"
29341 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29342 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29343 " movl %%eax, 8(%3)\n"
29344 " movl %%edx, 12(%3)\n"
29345 - "4: movl 16(%4), %%eax\n"
29346 - "41: movl 20(%4), %%edx\n"
29347 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29348 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29349 " movl %%eax, 16(%3)\n"
29350 " movl %%edx, 20(%3)\n"
29351 - "10: movl 24(%4), %%eax\n"
29352 - "51: movl 28(%4), %%edx\n"
29353 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29354 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29355 " movl %%eax, 24(%3)\n"
29356 " movl %%edx, 28(%3)\n"
29357 - "11: movl 32(%4), %%eax\n"
29358 - "61: movl 36(%4), %%edx\n"
29359 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29360 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29361 " movl %%eax, 32(%3)\n"
29362 " movl %%edx, 36(%3)\n"
29363 - "12: movl 40(%4), %%eax\n"
29364 - "71: movl 44(%4), %%edx\n"
29365 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29366 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29367 " movl %%eax, 40(%3)\n"
29368 " movl %%edx, 44(%3)\n"
29369 - "13: movl 48(%4), %%eax\n"
29370 - "81: movl 52(%4), %%edx\n"
29371 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29372 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29373 " movl %%eax, 48(%3)\n"
29374 " movl %%edx, 52(%3)\n"
29375 - "14: movl 56(%4), %%eax\n"
29376 - "91: movl 60(%4), %%edx\n"
29377 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29378 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29379 " movl %%eax, 56(%3)\n"
29380 " movl %%edx, 60(%3)\n"
29381 " addl $-64, %0\n"
29382 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29383 " shrl $2, %0\n"
29384 " andl $3, %%eax\n"
29385 " cld\n"
29386 - "6: rep; movsl\n"
29387 + "6: rep; "__copyuser_seg" movsl\n"
29388 " movl %%eax,%0\n"
29389 - "7: rep; movsb\n"
29390 + "7: rep; "__copyuser_seg" movsb\n"
29391 "8:\n"
29392 ".section .fixup,\"ax\"\n"
29393 "9: lea 0(%%eax,%0,4),%0\n"
29394 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29395 * hyoshiok@miraclelinux.com
29396 */
29397
29398 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29399 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29400 const void __user *from, unsigned long size)
29401 {
29402 int d0, d1;
29403
29404 __asm__ __volatile__(
29405 " .align 2,0x90\n"
29406 - "0: movl 32(%4), %%eax\n"
29407 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29408 " cmpl $67, %0\n"
29409 " jbe 2f\n"
29410 - "1: movl 64(%4), %%eax\n"
29411 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29412 " .align 2,0x90\n"
29413 - "2: movl 0(%4), %%eax\n"
29414 - "21: movl 4(%4), %%edx\n"
29415 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29416 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29417 " movnti %%eax, 0(%3)\n"
29418 " movnti %%edx, 4(%3)\n"
29419 - "3: movl 8(%4), %%eax\n"
29420 - "31: movl 12(%4),%%edx\n"
29421 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29422 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29423 " movnti %%eax, 8(%3)\n"
29424 " movnti %%edx, 12(%3)\n"
29425 - "4: movl 16(%4), %%eax\n"
29426 - "41: movl 20(%4), %%edx\n"
29427 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29428 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29429 " movnti %%eax, 16(%3)\n"
29430 " movnti %%edx, 20(%3)\n"
29431 - "10: movl 24(%4), %%eax\n"
29432 - "51: movl 28(%4), %%edx\n"
29433 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29434 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29435 " movnti %%eax, 24(%3)\n"
29436 " movnti %%edx, 28(%3)\n"
29437 - "11: movl 32(%4), %%eax\n"
29438 - "61: movl 36(%4), %%edx\n"
29439 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29440 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29441 " movnti %%eax, 32(%3)\n"
29442 " movnti %%edx, 36(%3)\n"
29443 - "12: movl 40(%4), %%eax\n"
29444 - "71: movl 44(%4), %%edx\n"
29445 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29446 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29447 " movnti %%eax, 40(%3)\n"
29448 " movnti %%edx, 44(%3)\n"
29449 - "13: movl 48(%4), %%eax\n"
29450 - "81: movl 52(%4), %%edx\n"
29451 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29452 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29453 " movnti %%eax, 48(%3)\n"
29454 " movnti %%edx, 52(%3)\n"
29455 - "14: movl 56(%4), %%eax\n"
29456 - "91: movl 60(%4), %%edx\n"
29457 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29458 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29459 " movnti %%eax, 56(%3)\n"
29460 " movnti %%edx, 60(%3)\n"
29461 " addl $-64, %0\n"
29462 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29463 " shrl $2, %0\n"
29464 " andl $3, %%eax\n"
29465 " cld\n"
29466 - "6: rep; movsl\n"
29467 + "6: rep; "__copyuser_seg" movsl\n"
29468 " movl %%eax,%0\n"
29469 - "7: rep; movsb\n"
29470 + "7: rep; "__copyuser_seg" movsb\n"
29471 "8:\n"
29472 ".section .fixup,\"ax\"\n"
29473 "9: lea 0(%%eax,%0,4),%0\n"
29474 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29475 return size;
29476 }
29477
29478 -static unsigned long __copy_user_intel_nocache(void *to,
29479 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29480 const void __user *from, unsigned long size)
29481 {
29482 int d0, d1;
29483
29484 __asm__ __volatile__(
29485 " .align 2,0x90\n"
29486 - "0: movl 32(%4), %%eax\n"
29487 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29488 " cmpl $67, %0\n"
29489 " jbe 2f\n"
29490 - "1: movl 64(%4), %%eax\n"
29491 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29492 " .align 2,0x90\n"
29493 - "2: movl 0(%4), %%eax\n"
29494 - "21: movl 4(%4), %%edx\n"
29495 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29496 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29497 " movnti %%eax, 0(%3)\n"
29498 " movnti %%edx, 4(%3)\n"
29499 - "3: movl 8(%4), %%eax\n"
29500 - "31: movl 12(%4),%%edx\n"
29501 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29502 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29503 " movnti %%eax, 8(%3)\n"
29504 " movnti %%edx, 12(%3)\n"
29505 - "4: movl 16(%4), %%eax\n"
29506 - "41: movl 20(%4), %%edx\n"
29507 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29508 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29509 " movnti %%eax, 16(%3)\n"
29510 " movnti %%edx, 20(%3)\n"
29511 - "10: movl 24(%4), %%eax\n"
29512 - "51: movl 28(%4), %%edx\n"
29513 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29514 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29515 " movnti %%eax, 24(%3)\n"
29516 " movnti %%edx, 28(%3)\n"
29517 - "11: movl 32(%4), %%eax\n"
29518 - "61: movl 36(%4), %%edx\n"
29519 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29520 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29521 " movnti %%eax, 32(%3)\n"
29522 " movnti %%edx, 36(%3)\n"
29523 - "12: movl 40(%4), %%eax\n"
29524 - "71: movl 44(%4), %%edx\n"
29525 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29526 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29527 " movnti %%eax, 40(%3)\n"
29528 " movnti %%edx, 44(%3)\n"
29529 - "13: movl 48(%4), %%eax\n"
29530 - "81: movl 52(%4), %%edx\n"
29531 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29532 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29533 " movnti %%eax, 48(%3)\n"
29534 " movnti %%edx, 52(%3)\n"
29535 - "14: movl 56(%4), %%eax\n"
29536 - "91: movl 60(%4), %%edx\n"
29537 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29538 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29539 " movnti %%eax, 56(%3)\n"
29540 " movnti %%edx, 60(%3)\n"
29541 " addl $-64, %0\n"
29542 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29543 " shrl $2, %0\n"
29544 " andl $3, %%eax\n"
29545 " cld\n"
29546 - "6: rep; movsl\n"
29547 + "6: rep; "__copyuser_seg" movsl\n"
29548 " movl %%eax,%0\n"
29549 - "7: rep; movsb\n"
29550 + "7: rep; "__copyuser_seg" movsb\n"
29551 "8:\n"
29552 ".section .fixup,\"ax\"\n"
29553 "9: lea 0(%%eax,%0,4),%0\n"
29554 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29555 */
29556 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29557 unsigned long size);
29558 -unsigned long __copy_user_intel(void __user *to, const void *from,
29559 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29560 + unsigned long size);
29561 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29562 unsigned long size);
29563 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29564 const void __user *from, unsigned long size);
29565 #endif /* CONFIG_X86_INTEL_USERCOPY */
29566
29567 /* Generic arbitrary sized copy. */
29568 -#define __copy_user(to, from, size) \
29569 +#define __copy_user(to, from, size, prefix, set, restore) \
29570 do { \
29571 int __d0, __d1, __d2; \
29572 __asm__ __volatile__( \
29573 + set \
29574 " cmp $7,%0\n" \
29575 " jbe 1f\n" \
29576 " movl %1,%0\n" \
29577 " negl %0\n" \
29578 " andl $7,%0\n" \
29579 " subl %0,%3\n" \
29580 - "4: rep; movsb\n" \
29581 + "4: rep; "prefix"movsb\n" \
29582 " movl %3,%0\n" \
29583 " shrl $2,%0\n" \
29584 " andl $3,%3\n" \
29585 " .align 2,0x90\n" \
29586 - "0: rep; movsl\n" \
29587 + "0: rep; "prefix"movsl\n" \
29588 " movl %3,%0\n" \
29589 - "1: rep; movsb\n" \
29590 + "1: rep; "prefix"movsb\n" \
29591 "2:\n" \
29592 + restore \
29593 ".section .fixup,\"ax\"\n" \
29594 "5: addl %3,%0\n" \
29595 " jmp 2b\n" \
29596 @@ -538,14 +650,14 @@ do { \
29597 " negl %0\n" \
29598 " andl $7,%0\n" \
29599 " subl %0,%3\n" \
29600 - "4: rep; movsb\n" \
29601 + "4: rep; "__copyuser_seg"movsb\n" \
29602 " movl %3,%0\n" \
29603 " shrl $2,%0\n" \
29604 " andl $3,%3\n" \
29605 " .align 2,0x90\n" \
29606 - "0: rep; movsl\n" \
29607 + "0: rep; "__copyuser_seg"movsl\n" \
29608 " movl %3,%0\n" \
29609 - "1: rep; movsb\n" \
29610 + "1: rep; "__copyuser_seg"movsb\n" \
29611 "2:\n" \
29612 ".section .fixup,\"ax\"\n" \
29613 "5: addl %3,%0\n" \
29614 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29615 {
29616 stac();
29617 if (movsl_is_ok(to, from, n))
29618 - __copy_user(to, from, n);
29619 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29620 else
29621 - n = __copy_user_intel(to, from, n);
29622 + n = __generic_copy_to_user_intel(to, from, n);
29623 clac();
29624 return n;
29625 }
29626 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29627 {
29628 stac();
29629 if (movsl_is_ok(to, from, n))
29630 - __copy_user(to, from, n);
29631 + __copy_user(to, from, n, __copyuser_seg, "", "");
29632 else
29633 - n = __copy_user_intel((void __user *)to,
29634 - (const void *)from, n);
29635 + n = __generic_copy_from_user_intel(to, from, n);
29636 clac();
29637 return n;
29638 }
29639 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29640 if (n > 64 && cpu_has_xmm2)
29641 n = __copy_user_intel_nocache(to, from, n);
29642 else
29643 - __copy_user(to, from, n);
29644 + __copy_user(to, from, n, __copyuser_seg, "", "");
29645 #else
29646 - __copy_user(to, from, n);
29647 + __copy_user(to, from, n, __copyuser_seg, "", "");
29648 #endif
29649 clac();
29650 return n;
29651 }
29652 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29653
29654 -/**
29655 - * copy_to_user: - Copy a block of data into user space.
29656 - * @to: Destination address, in user space.
29657 - * @from: Source address, in kernel space.
29658 - * @n: Number of bytes to copy.
29659 - *
29660 - * Context: User context only. This function may sleep.
29661 - *
29662 - * Copy data from kernel space to user space.
29663 - *
29664 - * Returns number of bytes that could not be copied.
29665 - * On success, this will be zero.
29666 - */
29667 -unsigned long
29668 -copy_to_user(void __user *to, const void *from, unsigned long n)
29669 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29670 +void __set_fs(mm_segment_t x)
29671 {
29672 - if (access_ok(VERIFY_WRITE, to, n))
29673 - n = __copy_to_user(to, from, n);
29674 - return n;
29675 + switch (x.seg) {
29676 + case 0:
29677 + loadsegment(gs, 0);
29678 + break;
29679 + case TASK_SIZE_MAX:
29680 + loadsegment(gs, __USER_DS);
29681 + break;
29682 + case -1UL:
29683 + loadsegment(gs, __KERNEL_DS);
29684 + break;
29685 + default:
29686 + BUG();
29687 + }
29688 }
29689 -EXPORT_SYMBOL(copy_to_user);
29690 +EXPORT_SYMBOL(__set_fs);
29691
29692 -/**
29693 - * copy_from_user: - Copy a block of data from user space.
29694 - * @to: Destination address, in kernel space.
29695 - * @from: Source address, in user space.
29696 - * @n: Number of bytes to copy.
29697 - *
29698 - * Context: User context only. This function may sleep.
29699 - *
29700 - * Copy data from user space to kernel space.
29701 - *
29702 - * Returns number of bytes that could not be copied.
29703 - * On success, this will be zero.
29704 - *
29705 - * If some data could not be copied, this function will pad the copied
29706 - * data to the requested size using zero bytes.
29707 - */
29708 -unsigned long
29709 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29710 +void set_fs(mm_segment_t x)
29711 {
29712 - if (access_ok(VERIFY_READ, from, n))
29713 - n = __copy_from_user(to, from, n);
29714 - else
29715 - memset(to, 0, n);
29716 - return n;
29717 + current_thread_info()->addr_limit = x;
29718 + __set_fs(x);
29719 }
29720 -EXPORT_SYMBOL(_copy_from_user);
29721 +EXPORT_SYMBOL(set_fs);
29722 +#endif
29723 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29724 index 906fea3..0194a18 100644
29725 --- a/arch/x86/lib/usercopy_64.c
29726 +++ b/arch/x86/lib/usercopy_64.c
29727 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29728 might_fault();
29729 /* no memory constraint because it doesn't change any memory gcc knows
29730 about */
29731 + pax_open_userland();
29732 stac();
29733 asm volatile(
29734 " testq %[size8],%[size8]\n"
29735 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29736 _ASM_EXTABLE(0b,3b)
29737 _ASM_EXTABLE(1b,2b)
29738 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29739 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29740 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29741 [zero] "r" (0UL), [eight] "r" (8UL));
29742 clac();
29743 + pax_close_userland();
29744 return size;
29745 }
29746 EXPORT_SYMBOL(__clear_user);
29747 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29748 }
29749 EXPORT_SYMBOL(clear_user);
29750
29751 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29752 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29753 {
29754 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29755 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29756 - }
29757 - return len;
29758 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29759 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29760 + return len;
29761 }
29762 EXPORT_SYMBOL(copy_in_user);
29763
29764 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29765 * it is not necessary to optimize tail handling.
29766 */
29767 unsigned long
29768 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29769 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29770 {
29771 char c;
29772 unsigned zero_len;
29773
29774 + clac();
29775 + pax_close_userland();
29776 for (; len; --len, to++) {
29777 if (__get_user_nocheck(c, from++, sizeof(char)))
29778 break;
29779 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29780 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29781 if (__put_user_nocheck(c, to++, sizeof(char)))
29782 break;
29783 - clac();
29784 return len;
29785 }
29786 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29787 index 23d8e5f..9ccc13a 100644
29788 --- a/arch/x86/mm/Makefile
29789 +++ b/arch/x86/mm/Makefile
29790 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29791 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29792
29793 obj-$(CONFIG_MEMTEST) += memtest.o
29794 +
29795 +quote:="
29796 +obj-$(CONFIG_X86_64) += uderef_64.o
29797 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29798 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29799 index 903ec1e..c4166b2 100644
29800 --- a/arch/x86/mm/extable.c
29801 +++ b/arch/x86/mm/extable.c
29802 @@ -6,12 +6,24 @@
29803 static inline unsigned long
29804 ex_insn_addr(const struct exception_table_entry *x)
29805 {
29806 - return (unsigned long)&x->insn + x->insn;
29807 + unsigned long reloc = 0;
29808 +
29809 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29810 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29811 +#endif
29812 +
29813 + return (unsigned long)&x->insn + x->insn + reloc;
29814 }
29815 static inline unsigned long
29816 ex_fixup_addr(const struct exception_table_entry *x)
29817 {
29818 - return (unsigned long)&x->fixup + x->fixup;
29819 + unsigned long reloc = 0;
29820 +
29821 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29822 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29823 +#endif
29824 +
29825 + return (unsigned long)&x->fixup + x->fixup + reloc;
29826 }
29827
29828 int fixup_exception(struct pt_regs *regs)
29829 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29830 unsigned long new_ip;
29831
29832 #ifdef CONFIG_PNPBIOS
29833 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29834 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29835 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29836 extern u32 pnp_bios_is_utter_crap;
29837 pnp_bios_is_utter_crap = 1;
29838 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29839 i += 4;
29840 p->fixup -= i;
29841 i += 4;
29842 +
29843 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29844 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29845 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29846 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29847 +#endif
29848 +
29849 }
29850 }
29851
29852 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29853 index 654be4a..a4a3da1 100644
29854 --- a/arch/x86/mm/fault.c
29855 +++ b/arch/x86/mm/fault.c
29856 @@ -14,11 +14,18 @@
29857 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29858 #include <linux/prefetch.h> /* prefetchw */
29859 #include <linux/context_tracking.h> /* exception_enter(), ... */
29860 +#include <linux/unistd.h>
29861 +#include <linux/compiler.h>
29862
29863 #include <asm/traps.h> /* dotraplinkage, ... */
29864 #include <asm/pgalloc.h> /* pgd_*(), ... */
29865 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29866 #include <asm/fixmap.h> /* VSYSCALL_START */
29867 +#include <asm/tlbflush.h>
29868 +
29869 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29870 +#include <asm/stacktrace.h>
29871 +#endif
29872
29873 /*
29874 * Page fault error code bits:
29875 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29876 int ret = 0;
29877
29878 /* kprobe_running() needs smp_processor_id() */
29879 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29880 + if (kprobes_built_in() && !user_mode(regs)) {
29881 preempt_disable();
29882 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29883 ret = 1;
29884 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29885 return !instr_lo || (instr_lo>>1) == 1;
29886 case 0x00:
29887 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29888 - if (probe_kernel_address(instr, opcode))
29889 + if (user_mode(regs)) {
29890 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29891 + return 0;
29892 + } else if (probe_kernel_address(instr, opcode))
29893 return 0;
29894
29895 *prefetch = (instr_lo == 0xF) &&
29896 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29897 while (instr < max_instr) {
29898 unsigned char opcode;
29899
29900 - if (probe_kernel_address(instr, opcode))
29901 + if (user_mode(regs)) {
29902 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29903 + break;
29904 + } else if (probe_kernel_address(instr, opcode))
29905 break;
29906
29907 instr++;
29908 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29909 force_sig_info(si_signo, &info, tsk);
29910 }
29911
29912 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29913 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29914 +#endif
29915 +
29916 +#ifdef CONFIG_PAX_EMUTRAMP
29917 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29918 +#endif
29919 +
29920 +#ifdef CONFIG_PAX_PAGEEXEC
29921 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29922 +{
29923 + pgd_t *pgd;
29924 + pud_t *pud;
29925 + pmd_t *pmd;
29926 +
29927 + pgd = pgd_offset(mm, address);
29928 + if (!pgd_present(*pgd))
29929 + return NULL;
29930 + pud = pud_offset(pgd, address);
29931 + if (!pud_present(*pud))
29932 + return NULL;
29933 + pmd = pmd_offset(pud, address);
29934 + if (!pmd_present(*pmd))
29935 + return NULL;
29936 + return pmd;
29937 +}
29938 +#endif
29939 +
29940 DEFINE_SPINLOCK(pgd_lock);
29941 LIST_HEAD(pgd_list);
29942
29943 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29944 for (address = VMALLOC_START & PMD_MASK;
29945 address >= TASK_SIZE && address < FIXADDR_TOP;
29946 address += PMD_SIZE) {
29947 +
29948 +#ifdef CONFIG_PAX_PER_CPU_PGD
29949 + unsigned long cpu;
29950 +#else
29951 struct page *page;
29952 +#endif
29953
29954 spin_lock(&pgd_lock);
29955 +
29956 +#ifdef CONFIG_PAX_PER_CPU_PGD
29957 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29958 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29959 + pmd_t *ret;
29960 +
29961 + ret = vmalloc_sync_one(pgd, address);
29962 + if (!ret)
29963 + break;
29964 + pgd = get_cpu_pgd(cpu, kernel);
29965 +#else
29966 list_for_each_entry(page, &pgd_list, lru) {
29967 + pgd_t *pgd;
29968 spinlock_t *pgt_lock;
29969 pmd_t *ret;
29970
29971 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29972 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29973
29974 spin_lock(pgt_lock);
29975 - ret = vmalloc_sync_one(page_address(page), address);
29976 + pgd = page_address(page);
29977 +#endif
29978 +
29979 + ret = vmalloc_sync_one(pgd, address);
29980 +
29981 +#ifndef CONFIG_PAX_PER_CPU_PGD
29982 spin_unlock(pgt_lock);
29983 +#endif
29984
29985 if (!ret)
29986 break;
29987 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29988 * an interrupt in the middle of a task switch..
29989 */
29990 pgd_paddr = read_cr3();
29991 +
29992 +#ifdef CONFIG_PAX_PER_CPU_PGD
29993 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29994 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29995 +#endif
29996 +
29997 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29998 if (!pmd_k)
29999 return -1;
30000 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30001 * happen within a race in page table update. In the later
30002 * case just flush:
30003 */
30004 - pgd = pgd_offset(current->active_mm, address);
30005 +
30006 pgd_ref = pgd_offset_k(address);
30007 if (pgd_none(*pgd_ref))
30008 return -1;
30009
30010 +#ifdef CONFIG_PAX_PER_CPU_PGD
30011 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30012 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30013 + if (pgd_none(*pgd)) {
30014 + set_pgd(pgd, *pgd_ref);
30015 + arch_flush_lazy_mmu_mode();
30016 + } else {
30017 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30018 + }
30019 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30020 +#else
30021 + pgd = pgd_offset(current->active_mm, address);
30022 +#endif
30023 +
30024 if (pgd_none(*pgd)) {
30025 set_pgd(pgd, *pgd_ref);
30026 arch_flush_lazy_mmu_mode();
30027 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30028 static int is_errata100(struct pt_regs *regs, unsigned long address)
30029 {
30030 #ifdef CONFIG_X86_64
30031 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30032 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30033 return 1;
30034 #endif
30035 return 0;
30036 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30037 }
30038
30039 static const char nx_warning[] = KERN_CRIT
30040 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30041 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30042
30043 static void
30044 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30045 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30046 if (!oops_may_print())
30047 return;
30048
30049 - if (error_code & PF_INSTR) {
30050 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30051 unsigned int level;
30052
30053 pte_t *pte = lookup_address(address, &level);
30054
30055 if (pte && pte_present(*pte) && !pte_exec(*pte))
30056 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30057 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30058 }
30059
30060 +#ifdef CONFIG_PAX_KERNEXEC
30061 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30062 + if (current->signal->curr_ip)
30063 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30064 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30065 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30066 + else
30067 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30068 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30069 + }
30070 +#endif
30071 +
30072 printk(KERN_ALERT "BUG: unable to handle kernel ");
30073 if (address < PAGE_SIZE)
30074 printk(KERN_CONT "NULL pointer dereference");
30075 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30076 return;
30077 }
30078 #endif
30079 +
30080 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30081 + if (pax_is_fetch_fault(regs, error_code, address)) {
30082 +
30083 +#ifdef CONFIG_PAX_EMUTRAMP
30084 + switch (pax_handle_fetch_fault(regs)) {
30085 + case 2:
30086 + return;
30087 + }
30088 +#endif
30089 +
30090 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30091 + do_group_exit(SIGKILL);
30092 + }
30093 +#endif
30094 +
30095 /* Kernel addresses are always protection faults: */
30096 if (address >= TASK_SIZE)
30097 error_code |= PF_PROT;
30098 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30099 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30100 printk(KERN_ERR
30101 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30102 - tsk->comm, tsk->pid, address);
30103 + tsk->comm, task_pid_nr(tsk), address);
30104 code = BUS_MCEERR_AR;
30105 }
30106 #endif
30107 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30108 return 1;
30109 }
30110
30111 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30112 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30113 +{
30114 + pte_t *pte;
30115 + pmd_t *pmd;
30116 + spinlock_t *ptl;
30117 + unsigned char pte_mask;
30118 +
30119 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30120 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30121 + return 0;
30122 +
30123 + /* PaX: it's our fault, let's handle it if we can */
30124 +
30125 + /* PaX: take a look at read faults before acquiring any locks */
30126 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30127 + /* instruction fetch attempt from a protected page in user mode */
30128 + up_read(&mm->mmap_sem);
30129 +
30130 +#ifdef CONFIG_PAX_EMUTRAMP
30131 + switch (pax_handle_fetch_fault(regs)) {
30132 + case 2:
30133 + return 1;
30134 + }
30135 +#endif
30136 +
30137 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30138 + do_group_exit(SIGKILL);
30139 + }
30140 +
30141 + pmd = pax_get_pmd(mm, address);
30142 + if (unlikely(!pmd))
30143 + return 0;
30144 +
30145 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30146 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30147 + pte_unmap_unlock(pte, ptl);
30148 + return 0;
30149 + }
30150 +
30151 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30152 + /* write attempt to a protected page in user mode */
30153 + pte_unmap_unlock(pte, ptl);
30154 + return 0;
30155 + }
30156 +
30157 +#ifdef CONFIG_SMP
30158 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30159 +#else
30160 + if (likely(address > get_limit(regs->cs)))
30161 +#endif
30162 + {
30163 + set_pte(pte, pte_mkread(*pte));
30164 + __flush_tlb_one(address);
30165 + pte_unmap_unlock(pte, ptl);
30166 + up_read(&mm->mmap_sem);
30167 + return 1;
30168 + }
30169 +
30170 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30171 +
30172 + /*
30173 + * PaX: fill DTLB with user rights and retry
30174 + */
30175 + __asm__ __volatile__ (
30176 + "orb %2,(%1)\n"
30177 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30178 +/*
30179 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30180 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30181 + * page fault when examined during a TLB load attempt. this is true not only
30182 + * for PTEs holding a non-present entry but also present entries that will
30183 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30184 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30185 + * for our target pages since their PTEs are simply not in the TLBs at all.
30186 +
30187 + * the best thing in omitting it is that we gain around 15-20% speed in the
30188 + * fast path of the page fault handler and can get rid of tracing since we
30189 + * can no longer flush unintended entries.
30190 + */
30191 + "invlpg (%0)\n"
30192 +#endif
30193 + __copyuser_seg"testb $0,(%0)\n"
30194 + "xorb %3,(%1)\n"
30195 + :
30196 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30197 + : "memory", "cc");
30198 + pte_unmap_unlock(pte, ptl);
30199 + up_read(&mm->mmap_sem);
30200 + return 1;
30201 +}
30202 +#endif
30203 +
30204 /*
30205 * Handle a spurious fault caused by a stale TLB entry.
30206 *
30207 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30208 static inline int
30209 access_error(unsigned long error_code, struct vm_area_struct *vma)
30210 {
30211 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30212 + return 1;
30213 +
30214 if (error_code & PF_WRITE) {
30215 /* write, present and write, not present: */
30216 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30217 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30218 if (error_code & PF_USER)
30219 return false;
30220
30221 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30222 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30223 return false;
30224
30225 return true;
30226 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30227 {
30228 struct vm_area_struct *vma;
30229 struct task_struct *tsk;
30230 - unsigned long address;
30231 struct mm_struct *mm;
30232 int fault;
30233 int write = error_code & PF_WRITE;
30234 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30235 (write ? FAULT_FLAG_WRITE : 0);
30236
30237 - tsk = current;
30238 - mm = tsk->mm;
30239 -
30240 /* Get the faulting address: */
30241 - address = read_cr2();
30242 + unsigned long address = read_cr2();
30243 +
30244 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30245 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30246 + if (!search_exception_tables(regs->ip)) {
30247 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30248 + bad_area_nosemaphore(regs, error_code, address);
30249 + return;
30250 + }
30251 + if (address < pax_user_shadow_base) {
30252 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30253 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30254 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30255 + } else
30256 + address -= pax_user_shadow_base;
30257 + }
30258 +#endif
30259 +
30260 + tsk = current;
30261 + mm = tsk->mm;
30262
30263 /*
30264 * Detect and handle instructions that would cause a page fault for
30265 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30266 * User-mode registers count as a user access even for any
30267 * potential system fault or CPU buglet:
30268 */
30269 - if (user_mode_vm(regs)) {
30270 + if (user_mode(regs)) {
30271 local_irq_enable();
30272 error_code |= PF_USER;
30273 } else {
30274 @@ -1142,6 +1365,11 @@ retry:
30275 might_sleep();
30276 }
30277
30278 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30279 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30280 + return;
30281 +#endif
30282 +
30283 vma = find_vma(mm, address);
30284 if (unlikely(!vma)) {
30285 bad_area(regs, error_code, address);
30286 @@ -1153,18 +1381,24 @@ retry:
30287 bad_area(regs, error_code, address);
30288 return;
30289 }
30290 - if (error_code & PF_USER) {
30291 - /*
30292 - * Accessing the stack below %sp is always a bug.
30293 - * The large cushion allows instructions like enter
30294 - * and pusha to work. ("enter $65535, $31" pushes
30295 - * 32 pointers and then decrements %sp by 65535.)
30296 - */
30297 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30298 - bad_area(regs, error_code, address);
30299 - return;
30300 - }
30301 + /*
30302 + * Accessing the stack below %sp is always a bug.
30303 + * The large cushion allows instructions like enter
30304 + * and pusha to work. ("enter $65535, $31" pushes
30305 + * 32 pointers and then decrements %sp by 65535.)
30306 + */
30307 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30308 + bad_area(regs, error_code, address);
30309 + return;
30310 }
30311 +
30312 +#ifdef CONFIG_PAX_SEGMEXEC
30313 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30314 + bad_area(regs, error_code, address);
30315 + return;
30316 + }
30317 +#endif
30318 +
30319 if (unlikely(expand_stack(vma, address))) {
30320 bad_area(regs, error_code, address);
30321 return;
30322 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30323 __do_page_fault(regs, error_code);
30324 exception_exit(prev_state);
30325 }
30326 +
30327 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30328 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30329 +{
30330 + struct mm_struct *mm = current->mm;
30331 + unsigned long ip = regs->ip;
30332 +
30333 + if (v8086_mode(regs))
30334 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30335 +
30336 +#ifdef CONFIG_PAX_PAGEEXEC
30337 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30338 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30339 + return true;
30340 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30341 + return true;
30342 + return false;
30343 + }
30344 +#endif
30345 +
30346 +#ifdef CONFIG_PAX_SEGMEXEC
30347 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30348 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30349 + return true;
30350 + return false;
30351 + }
30352 +#endif
30353 +
30354 + return false;
30355 +}
30356 +#endif
30357 +
30358 +#ifdef CONFIG_PAX_EMUTRAMP
30359 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30360 +{
30361 + int err;
30362 +
30363 + do { /* PaX: libffi trampoline emulation */
30364 + unsigned char mov, jmp;
30365 + unsigned int addr1, addr2;
30366 +
30367 +#ifdef CONFIG_X86_64
30368 + if ((regs->ip + 9) >> 32)
30369 + break;
30370 +#endif
30371 +
30372 + err = get_user(mov, (unsigned char __user *)regs->ip);
30373 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30374 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30375 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30376 +
30377 + if (err)
30378 + break;
30379 +
30380 + if (mov == 0xB8 && jmp == 0xE9) {
30381 + regs->ax = addr1;
30382 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30383 + return 2;
30384 + }
30385 + } while (0);
30386 +
30387 + do { /* PaX: gcc trampoline emulation #1 */
30388 + unsigned char mov1, mov2;
30389 + unsigned short jmp;
30390 + unsigned int addr1, addr2;
30391 +
30392 +#ifdef CONFIG_X86_64
30393 + if ((regs->ip + 11) >> 32)
30394 + break;
30395 +#endif
30396 +
30397 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30398 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30399 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30400 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30401 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30402 +
30403 + if (err)
30404 + break;
30405 +
30406 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30407 + regs->cx = addr1;
30408 + regs->ax = addr2;
30409 + regs->ip = addr2;
30410 + return 2;
30411 + }
30412 + } while (0);
30413 +
30414 + do { /* PaX: gcc trampoline emulation #2 */
30415 + unsigned char mov, jmp;
30416 + unsigned int addr1, addr2;
30417 +
30418 +#ifdef CONFIG_X86_64
30419 + if ((regs->ip + 9) >> 32)
30420 + break;
30421 +#endif
30422 +
30423 + err = get_user(mov, (unsigned char __user *)regs->ip);
30424 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30425 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30426 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30427 +
30428 + if (err)
30429 + break;
30430 +
30431 + if (mov == 0xB9 && jmp == 0xE9) {
30432 + regs->cx = addr1;
30433 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30434 + return 2;
30435 + }
30436 + } while (0);
30437 +
30438 + return 1; /* PaX in action */
30439 +}
30440 +
30441 +#ifdef CONFIG_X86_64
30442 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30443 +{
30444 + int err;
30445 +
30446 + do { /* PaX: libffi trampoline emulation */
30447 + unsigned short mov1, mov2, jmp1;
30448 + unsigned char stcclc, jmp2;
30449 + unsigned long addr1, addr2;
30450 +
30451 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30452 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30453 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30454 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30455 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30456 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30457 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30458 +
30459 + if (err)
30460 + break;
30461 +
30462 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30463 + regs->r11 = addr1;
30464 + regs->r10 = addr2;
30465 + if (stcclc == 0xF8)
30466 + regs->flags &= ~X86_EFLAGS_CF;
30467 + else
30468 + regs->flags |= X86_EFLAGS_CF;
30469 + regs->ip = addr1;
30470 + return 2;
30471 + }
30472 + } while (0);
30473 +
30474 + do { /* PaX: gcc trampoline emulation #1 */
30475 + unsigned short mov1, mov2, jmp1;
30476 + unsigned char jmp2;
30477 + unsigned int addr1;
30478 + unsigned long addr2;
30479 +
30480 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30481 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30482 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30483 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30484 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30485 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30486 +
30487 + if (err)
30488 + break;
30489 +
30490 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30491 + regs->r11 = addr1;
30492 + regs->r10 = addr2;
30493 + regs->ip = addr1;
30494 + return 2;
30495 + }
30496 + } while (0);
30497 +
30498 + do { /* PaX: gcc trampoline emulation #2 */
30499 + unsigned short mov1, mov2, jmp1;
30500 + unsigned char jmp2;
30501 + unsigned long addr1, addr2;
30502 +
30503 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30504 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30505 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30506 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30507 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30508 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30509 +
30510 + if (err)
30511 + break;
30512 +
30513 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30514 + regs->r11 = addr1;
30515 + regs->r10 = addr2;
30516 + regs->ip = addr1;
30517 + return 2;
30518 + }
30519 + } while (0);
30520 +
30521 + return 1; /* PaX in action */
30522 +}
30523 +#endif
30524 +
30525 +/*
30526 + * PaX: decide what to do with offenders (regs->ip = fault address)
30527 + *
30528 + * returns 1 when task should be killed
30529 + * 2 when gcc trampoline was detected
30530 + */
30531 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30532 +{
30533 + if (v8086_mode(regs))
30534 + return 1;
30535 +
30536 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30537 + return 1;
30538 +
30539 +#ifdef CONFIG_X86_32
30540 + return pax_handle_fetch_fault_32(regs);
30541 +#else
30542 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30543 + return pax_handle_fetch_fault_32(regs);
30544 + else
30545 + return pax_handle_fetch_fault_64(regs);
30546 +#endif
30547 +}
30548 +#endif
30549 +
30550 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30551 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30552 +{
30553 + long i;
30554 +
30555 + printk(KERN_ERR "PAX: bytes at PC: ");
30556 + for (i = 0; i < 20; i++) {
30557 + unsigned char c;
30558 + if (get_user(c, (unsigned char __force_user *)pc+i))
30559 + printk(KERN_CONT "?? ");
30560 + else
30561 + printk(KERN_CONT "%02x ", c);
30562 + }
30563 + printk("\n");
30564 +
30565 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30566 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30567 + unsigned long c;
30568 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30569 +#ifdef CONFIG_X86_32
30570 + printk(KERN_CONT "???????? ");
30571 +#else
30572 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30573 + printk(KERN_CONT "???????? ???????? ");
30574 + else
30575 + printk(KERN_CONT "???????????????? ");
30576 +#endif
30577 + } else {
30578 +#ifdef CONFIG_X86_64
30579 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30580 + printk(KERN_CONT "%08x ", (unsigned int)c);
30581 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30582 + } else
30583 +#endif
30584 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30585 + }
30586 + }
30587 + printk("\n");
30588 +}
30589 +#endif
30590 +
30591 +/**
30592 + * probe_kernel_write(): safely attempt to write to a location
30593 + * @dst: address to write to
30594 + * @src: pointer to the data that shall be written
30595 + * @size: size of the data chunk
30596 + *
30597 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30598 + * happens, handle that and return -EFAULT.
30599 + */
30600 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30601 +{
30602 + long ret;
30603 + mm_segment_t old_fs = get_fs();
30604 +
30605 + set_fs(KERNEL_DS);
30606 + pagefault_disable();
30607 + pax_open_kernel();
30608 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30609 + pax_close_kernel();
30610 + pagefault_enable();
30611 + set_fs(old_fs);
30612 +
30613 + return ret ? -EFAULT : 0;
30614 +}
30615 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30616 index dd74e46..7d26398 100644
30617 --- a/arch/x86/mm/gup.c
30618 +++ b/arch/x86/mm/gup.c
30619 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30620 addr = start;
30621 len = (unsigned long) nr_pages << PAGE_SHIFT;
30622 end = start + len;
30623 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30624 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30625 (void __user *)start, len)))
30626 return 0;
30627
30628 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30629 index 4500142..53a363c 100644
30630 --- a/arch/x86/mm/highmem_32.c
30631 +++ b/arch/x86/mm/highmem_32.c
30632 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30633 idx = type + KM_TYPE_NR*smp_processor_id();
30634 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30635 BUG_ON(!pte_none(*(kmap_pte-idx)));
30636 +
30637 + pax_open_kernel();
30638 set_pte(kmap_pte-idx, mk_pte(page, prot));
30639 + pax_close_kernel();
30640 +
30641 arch_flush_lazy_mmu_mode();
30642
30643 return (void *)vaddr;
30644 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30645 index 7e73e8c..11d3b86 100644
30646 --- a/arch/x86/mm/hugetlbpage.c
30647 +++ b/arch/x86/mm/hugetlbpage.c
30648 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30649 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30650 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30651 unsigned long addr, unsigned long len,
30652 - unsigned long pgoff, unsigned long flags)
30653 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30654 {
30655 struct hstate *h = hstate_file(file);
30656 struct vm_unmapped_area_info info;
30657 -
30658 +
30659 info.flags = 0;
30660 info.length = len;
30661 info.low_limit = TASK_UNMAPPED_BASE;
30662 +
30663 +#ifdef CONFIG_PAX_RANDMMAP
30664 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30665 + info.low_limit += current->mm->delta_mmap;
30666 +#endif
30667 +
30668 info.high_limit = TASK_SIZE;
30669 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30670 info.align_offset = 0;
30671 + info.threadstack_offset = offset;
30672 return vm_unmapped_area(&info);
30673 }
30674
30675 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30676 unsigned long addr0, unsigned long len,
30677 - unsigned long pgoff, unsigned long flags)
30678 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30679 {
30680 struct hstate *h = hstate_file(file);
30681 struct vm_unmapped_area_info info;
30682 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30683 info.high_limit = current->mm->mmap_base;
30684 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30685 info.align_offset = 0;
30686 + info.threadstack_offset = offset;
30687 addr = vm_unmapped_area(&info);
30688
30689 /*
30690 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30691 VM_BUG_ON(addr != -ENOMEM);
30692 info.flags = 0;
30693 info.low_limit = TASK_UNMAPPED_BASE;
30694 +
30695 +#ifdef CONFIG_PAX_RANDMMAP
30696 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30697 + info.low_limit += current->mm->delta_mmap;
30698 +#endif
30699 +
30700 info.high_limit = TASK_SIZE;
30701 addr = vm_unmapped_area(&info);
30702 }
30703 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30704 struct hstate *h = hstate_file(file);
30705 struct mm_struct *mm = current->mm;
30706 struct vm_area_struct *vma;
30707 + unsigned long pax_task_size = TASK_SIZE;
30708 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30709
30710 if (len & ~huge_page_mask(h))
30711 return -EINVAL;
30712 - if (len > TASK_SIZE)
30713 +
30714 +#ifdef CONFIG_PAX_SEGMEXEC
30715 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30716 + pax_task_size = SEGMEXEC_TASK_SIZE;
30717 +#endif
30718 +
30719 + pax_task_size -= PAGE_SIZE;
30720 +
30721 + if (len > pax_task_size)
30722 return -ENOMEM;
30723
30724 if (flags & MAP_FIXED) {
30725 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30726 return addr;
30727 }
30728
30729 +#ifdef CONFIG_PAX_RANDMMAP
30730 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30731 +#endif
30732 +
30733 if (addr) {
30734 addr = ALIGN(addr, huge_page_size(h));
30735 vma = find_vma(mm, addr);
30736 - if (TASK_SIZE - len >= addr &&
30737 - (!vma || addr + len <= vma->vm_start))
30738 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30739 return addr;
30740 }
30741 if (mm->get_unmapped_area == arch_get_unmapped_area)
30742 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30743 - pgoff, flags);
30744 + pgoff, flags, offset);
30745 else
30746 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30747 - pgoff, flags);
30748 + pgoff, flags, offset);
30749 }
30750
30751 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30752 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30753 index 04664cd..dae6e5d 100644
30754 --- a/arch/x86/mm/init.c
30755 +++ b/arch/x86/mm/init.c
30756 @@ -4,6 +4,7 @@
30757 #include <linux/swap.h>
30758 #include <linux/memblock.h>
30759 #include <linux/bootmem.h> /* for max_low_pfn */
30760 +#include <linux/tboot.h>
30761
30762 #include <asm/cacheflush.h>
30763 #include <asm/e820.h>
30764 @@ -17,6 +18,8 @@
30765 #include <asm/proto.h>
30766 #include <asm/dma.h> /* for MAX_DMA_PFN */
30767 #include <asm/microcode.h>
30768 +#include <asm/desc.h>
30769 +#include <asm/bios_ebda.h>
30770
30771 #include "mm_internal.h"
30772
30773 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30774 early_ioremap_page_table_range_init();
30775 #endif
30776
30777 +#ifdef CONFIG_PAX_PER_CPU_PGD
30778 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30779 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30780 + KERNEL_PGD_PTRS);
30781 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30782 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30783 + KERNEL_PGD_PTRS);
30784 + load_cr3(get_cpu_pgd(0, kernel));
30785 +#else
30786 load_cr3(swapper_pg_dir);
30787 +#endif
30788 +
30789 __flush_tlb_all();
30790
30791 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30792 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30793 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30794 * mmio resources as well as potential bios/acpi data regions.
30795 */
30796 +
30797 +#ifdef CONFIG_GRKERNSEC_KMEM
30798 +static unsigned int ebda_start __read_only;
30799 +static unsigned int ebda_end __read_only;
30800 +#endif
30801 +
30802 int devmem_is_allowed(unsigned long pagenr)
30803 {
30804 - if (pagenr < 256)
30805 +#ifdef CONFIG_GRKERNSEC_KMEM
30806 + /* allow BDA */
30807 + if (!pagenr)
30808 return 1;
30809 + /* allow EBDA */
30810 + if (pagenr >= ebda_start && pagenr < ebda_end)
30811 + return 1;
30812 + /* if tboot is in use, allow access to its hardcoded serial log range */
30813 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30814 + return 1;
30815 +#else
30816 + if (!pagenr)
30817 + return 1;
30818 +#ifdef CONFIG_VM86
30819 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30820 + return 1;
30821 +#endif
30822 +#endif
30823 +
30824 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30825 + return 1;
30826 +#ifdef CONFIG_GRKERNSEC_KMEM
30827 + /* throw out everything else below 1MB */
30828 + if (pagenr <= 256)
30829 + return 0;
30830 +#endif
30831 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30832 return 0;
30833 if (!page_is_ram(pagenr))
30834 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30835 #endif
30836 }
30837
30838 +#ifdef CONFIG_GRKERNSEC_KMEM
30839 +static inline void gr_init_ebda(void)
30840 +{
30841 + unsigned int ebda_addr;
30842 + unsigned int ebda_size = 0;
30843 +
30844 + ebda_addr = get_bios_ebda();
30845 + if (ebda_addr) {
30846 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30847 + ebda_size <<= 10;
30848 + }
30849 + if (ebda_addr && ebda_size) {
30850 + ebda_start = ebda_addr >> PAGE_SHIFT;
30851 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30852 + } else {
30853 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30854 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30855 + }
30856 +}
30857 +#else
30858 +static inline void gr_init_ebda(void) { }
30859 +#endif
30860 +
30861 void free_initmem(void)
30862 {
30863 +#ifdef CONFIG_PAX_KERNEXEC
30864 +#ifdef CONFIG_X86_32
30865 + /* PaX: limit KERNEL_CS to actual size */
30866 + unsigned long addr, limit;
30867 + struct desc_struct d;
30868 + int cpu;
30869 +#else
30870 + pgd_t *pgd;
30871 + pud_t *pud;
30872 + pmd_t *pmd;
30873 + unsigned long addr, end;
30874 +#endif
30875 +#endif
30876 +
30877 + gr_init_ebda();
30878 +
30879 +#ifdef CONFIG_PAX_KERNEXEC
30880 +#ifdef CONFIG_X86_32
30881 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30882 + limit = (limit - 1UL) >> PAGE_SHIFT;
30883 +
30884 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30885 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30886 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30887 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30888 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30889 + }
30890 +
30891 + /* PaX: make KERNEL_CS read-only */
30892 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30893 + if (!paravirt_enabled())
30894 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30895 +/*
30896 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30897 + pgd = pgd_offset_k(addr);
30898 + pud = pud_offset(pgd, addr);
30899 + pmd = pmd_offset(pud, addr);
30900 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30901 + }
30902 +*/
30903 +#ifdef CONFIG_X86_PAE
30904 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30905 +/*
30906 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30907 + pgd = pgd_offset_k(addr);
30908 + pud = pud_offset(pgd, addr);
30909 + pmd = pmd_offset(pud, addr);
30910 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30911 + }
30912 +*/
30913 +#endif
30914 +
30915 +#ifdef CONFIG_MODULES
30916 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30917 +#endif
30918 +
30919 +#else
30920 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30921 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30922 + pgd = pgd_offset_k(addr);
30923 + pud = pud_offset(pgd, addr);
30924 + pmd = pmd_offset(pud, addr);
30925 + if (!pmd_present(*pmd))
30926 + continue;
30927 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30928 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30929 + else
30930 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30931 + }
30932 +
30933 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30934 + end = addr + KERNEL_IMAGE_SIZE;
30935 + for (; addr < end; addr += PMD_SIZE) {
30936 + pgd = pgd_offset_k(addr);
30937 + pud = pud_offset(pgd, addr);
30938 + pmd = pmd_offset(pud, addr);
30939 + if (!pmd_present(*pmd))
30940 + continue;
30941 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30942 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30943 + }
30944 +#endif
30945 +
30946 + flush_tlb_all();
30947 +#endif
30948 +
30949 free_init_pages("unused kernel",
30950 (unsigned long)(&__init_begin),
30951 (unsigned long)(&__init_end));
30952 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30953 index 4287f1f..3b99c71 100644
30954 --- a/arch/x86/mm/init_32.c
30955 +++ b/arch/x86/mm/init_32.c
30956 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30957 bool __read_mostly __vmalloc_start_set = false;
30958
30959 /*
30960 - * Creates a middle page table and puts a pointer to it in the
30961 - * given global directory entry. This only returns the gd entry
30962 - * in non-PAE compilation mode, since the middle layer is folded.
30963 - */
30964 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30965 -{
30966 - pud_t *pud;
30967 - pmd_t *pmd_table;
30968 -
30969 -#ifdef CONFIG_X86_PAE
30970 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30971 - pmd_table = (pmd_t *)alloc_low_page();
30972 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30973 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30974 - pud = pud_offset(pgd, 0);
30975 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30976 -
30977 - return pmd_table;
30978 - }
30979 -#endif
30980 - pud = pud_offset(pgd, 0);
30981 - pmd_table = pmd_offset(pud, 0);
30982 -
30983 - return pmd_table;
30984 -}
30985 -
30986 -/*
30987 * Create a page table and place a pointer to it in a middle page
30988 * directory entry:
30989 */
30990 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30991 pte_t *page_table = (pte_t *)alloc_low_page();
30992
30993 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30994 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30995 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30996 +#else
30997 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30998 +#endif
30999 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31000 }
31001
31002 return pte_offset_kernel(pmd, 0);
31003 }
31004
31005 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31006 +{
31007 + pud_t *pud;
31008 + pmd_t *pmd_table;
31009 +
31010 + pud = pud_offset(pgd, 0);
31011 + pmd_table = pmd_offset(pud, 0);
31012 +
31013 + return pmd_table;
31014 +}
31015 +
31016 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31017 {
31018 int pgd_idx = pgd_index(vaddr);
31019 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31020 int pgd_idx, pmd_idx;
31021 unsigned long vaddr;
31022 pgd_t *pgd;
31023 + pud_t *pud;
31024 pmd_t *pmd;
31025 pte_t *pte = NULL;
31026 unsigned long count = page_table_range_init_count(start, end);
31027 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31028 pgd = pgd_base + pgd_idx;
31029
31030 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31031 - pmd = one_md_table_init(pgd);
31032 - pmd = pmd + pmd_index(vaddr);
31033 + pud = pud_offset(pgd, vaddr);
31034 + pmd = pmd_offset(pud, vaddr);
31035 +
31036 +#ifdef CONFIG_X86_PAE
31037 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31038 +#endif
31039 +
31040 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31041 pmd++, pmd_idx++) {
31042 pte = page_table_kmap_check(one_page_table_init(pmd),
31043 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31044 }
31045 }
31046
31047 -static inline int is_kernel_text(unsigned long addr)
31048 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31049 {
31050 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31051 - return 1;
31052 - return 0;
31053 + if ((start > ktla_ktva((unsigned long)_etext) ||
31054 + end <= ktla_ktva((unsigned long)_stext)) &&
31055 + (start > ktla_ktva((unsigned long)_einittext) ||
31056 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31057 +
31058 +#ifdef CONFIG_ACPI_SLEEP
31059 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31060 +#endif
31061 +
31062 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31063 + return 0;
31064 + return 1;
31065 }
31066
31067 /*
31068 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31069 unsigned long last_map_addr = end;
31070 unsigned long start_pfn, end_pfn;
31071 pgd_t *pgd_base = swapper_pg_dir;
31072 - int pgd_idx, pmd_idx, pte_ofs;
31073 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31074 unsigned long pfn;
31075 pgd_t *pgd;
31076 + pud_t *pud;
31077 pmd_t *pmd;
31078 pte_t *pte;
31079 unsigned pages_2m, pages_4k;
31080 @@ -291,8 +295,13 @@ repeat:
31081 pfn = start_pfn;
31082 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31083 pgd = pgd_base + pgd_idx;
31084 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31085 - pmd = one_md_table_init(pgd);
31086 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31087 + pud = pud_offset(pgd, 0);
31088 + pmd = pmd_offset(pud, 0);
31089 +
31090 +#ifdef CONFIG_X86_PAE
31091 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31092 +#endif
31093
31094 if (pfn >= end_pfn)
31095 continue;
31096 @@ -304,14 +313,13 @@ repeat:
31097 #endif
31098 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31099 pmd++, pmd_idx++) {
31100 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31101 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31102
31103 /*
31104 * Map with big pages if possible, otherwise
31105 * create normal page tables:
31106 */
31107 if (use_pse) {
31108 - unsigned int addr2;
31109 pgprot_t prot = PAGE_KERNEL_LARGE;
31110 /*
31111 * first pass will use the same initial
31112 @@ -322,11 +330,7 @@ repeat:
31113 _PAGE_PSE);
31114
31115 pfn &= PMD_MASK >> PAGE_SHIFT;
31116 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31117 - PAGE_OFFSET + PAGE_SIZE-1;
31118 -
31119 - if (is_kernel_text(addr) ||
31120 - is_kernel_text(addr2))
31121 + if (is_kernel_text(address, address + PMD_SIZE))
31122 prot = PAGE_KERNEL_LARGE_EXEC;
31123
31124 pages_2m++;
31125 @@ -343,7 +347,7 @@ repeat:
31126 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31127 pte += pte_ofs;
31128 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31129 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31130 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31131 pgprot_t prot = PAGE_KERNEL;
31132 /*
31133 * first pass will use the same initial
31134 @@ -351,7 +355,7 @@ repeat:
31135 */
31136 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31137
31138 - if (is_kernel_text(addr))
31139 + if (is_kernel_text(address, address + PAGE_SIZE))
31140 prot = PAGE_KERNEL_EXEC;
31141
31142 pages_4k++;
31143 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31144
31145 pud = pud_offset(pgd, va);
31146 pmd = pmd_offset(pud, va);
31147 - if (!pmd_present(*pmd))
31148 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31149 break;
31150
31151 /* should not be large page here */
31152 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31153
31154 static void __init pagetable_init(void)
31155 {
31156 - pgd_t *pgd_base = swapper_pg_dir;
31157 -
31158 - permanent_kmaps_init(pgd_base);
31159 + permanent_kmaps_init(swapper_pg_dir);
31160 }
31161
31162 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31163 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31164 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31165
31166 /* user-defined highmem size */
31167 @@ -787,10 +789,10 @@ void __init mem_init(void)
31168 ((unsigned long)&__init_end -
31169 (unsigned long)&__init_begin) >> 10,
31170
31171 - (unsigned long)&_etext, (unsigned long)&_edata,
31172 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31173 + (unsigned long)&_sdata, (unsigned long)&_edata,
31174 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31175
31176 - (unsigned long)&_text, (unsigned long)&_etext,
31177 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31178 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31179
31180 /*
31181 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31182 if (!kernel_set_to_readonly)
31183 return;
31184
31185 + start = ktla_ktva(start);
31186 pr_debug("Set kernel text: %lx - %lx for read write\n",
31187 start, start+size);
31188
31189 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31190 if (!kernel_set_to_readonly)
31191 return;
31192
31193 + start = ktla_ktva(start);
31194 pr_debug("Set kernel text: %lx - %lx for read only\n",
31195 start, start+size);
31196
31197 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31198 unsigned long start = PFN_ALIGN(_text);
31199 unsigned long size = PFN_ALIGN(_etext) - start;
31200
31201 + start = ktla_ktva(start);
31202 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31203 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31204 size >> 10);
31205 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31206 index 104d56a..62ba13f1 100644
31207 --- a/arch/x86/mm/init_64.c
31208 +++ b/arch/x86/mm/init_64.c
31209 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31210 * around without checking the pgd every time.
31211 */
31212
31213 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31214 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31215 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31216
31217 int force_personality32;
31218 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31219
31220 for (address = start; address <= end; address += PGDIR_SIZE) {
31221 const pgd_t *pgd_ref = pgd_offset_k(address);
31222 +
31223 +#ifdef CONFIG_PAX_PER_CPU_PGD
31224 + unsigned long cpu;
31225 +#else
31226 struct page *page;
31227 +#endif
31228
31229 if (pgd_none(*pgd_ref))
31230 continue;
31231
31232 spin_lock(&pgd_lock);
31233 +
31234 +#ifdef CONFIG_PAX_PER_CPU_PGD
31235 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31236 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31237 +
31238 + if (pgd_none(*pgd))
31239 + set_pgd(pgd, *pgd_ref);
31240 + else
31241 + BUG_ON(pgd_page_vaddr(*pgd)
31242 + != pgd_page_vaddr(*pgd_ref));
31243 + pgd = pgd_offset_cpu(cpu, kernel, address);
31244 +#else
31245 list_for_each_entry(page, &pgd_list, lru) {
31246 pgd_t *pgd;
31247 spinlock_t *pgt_lock;
31248 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31249 /* the pgt_lock only for Xen */
31250 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31251 spin_lock(pgt_lock);
31252 +#endif
31253
31254 if (pgd_none(*pgd))
31255 set_pgd(pgd, *pgd_ref);
31256 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31257 BUG_ON(pgd_page_vaddr(*pgd)
31258 != pgd_page_vaddr(*pgd_ref));
31259
31260 +#ifndef CONFIG_PAX_PER_CPU_PGD
31261 spin_unlock(pgt_lock);
31262 +#endif
31263 +
31264 }
31265 spin_unlock(&pgd_lock);
31266 }
31267 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31268 {
31269 if (pgd_none(*pgd)) {
31270 pud_t *pud = (pud_t *)spp_getpage();
31271 - pgd_populate(&init_mm, pgd, pud);
31272 + pgd_populate_kernel(&init_mm, pgd, pud);
31273 if (pud != pud_offset(pgd, 0))
31274 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31275 pud, pud_offset(pgd, 0));
31276 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31277 {
31278 if (pud_none(*pud)) {
31279 pmd_t *pmd = (pmd_t *) spp_getpage();
31280 - pud_populate(&init_mm, pud, pmd);
31281 + pud_populate_kernel(&init_mm, pud, pmd);
31282 if (pmd != pmd_offset(pud, 0))
31283 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31284 pmd, pmd_offset(pud, 0));
31285 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31286 pmd = fill_pmd(pud, vaddr);
31287 pte = fill_pte(pmd, vaddr);
31288
31289 + pax_open_kernel();
31290 set_pte(pte, new_pte);
31291 + pax_close_kernel();
31292
31293 /*
31294 * It's enough to flush this one mapping.
31295 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31296 pgd = pgd_offset_k((unsigned long)__va(phys));
31297 if (pgd_none(*pgd)) {
31298 pud = (pud_t *) spp_getpage();
31299 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31300 - _PAGE_USER));
31301 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31302 }
31303 pud = pud_offset(pgd, (unsigned long)__va(phys));
31304 if (pud_none(*pud)) {
31305 pmd = (pmd_t *) spp_getpage();
31306 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31307 - _PAGE_USER));
31308 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31309 }
31310 pmd = pmd_offset(pud, phys);
31311 BUG_ON(!pmd_none(*pmd));
31312 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31313 prot);
31314
31315 spin_lock(&init_mm.page_table_lock);
31316 - pud_populate(&init_mm, pud, pmd);
31317 + pud_populate_kernel(&init_mm, pud, pmd);
31318 spin_unlock(&init_mm.page_table_lock);
31319 }
31320 __flush_tlb_all();
31321 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31322 page_size_mask);
31323
31324 spin_lock(&init_mm.page_table_lock);
31325 - pgd_populate(&init_mm, pgd, pud);
31326 + pgd_populate_kernel(&init_mm, pgd, pud);
31327 spin_unlock(&init_mm.page_table_lock);
31328 pgd_changed = true;
31329 }
31330 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31331 static struct vm_area_struct gate_vma = {
31332 .vm_start = VSYSCALL_START,
31333 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31334 - .vm_page_prot = PAGE_READONLY_EXEC,
31335 - .vm_flags = VM_READ | VM_EXEC
31336 + .vm_page_prot = PAGE_READONLY,
31337 + .vm_flags = VM_READ
31338 };
31339
31340 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31341 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31342
31343 const char *arch_vma_name(struct vm_area_struct *vma)
31344 {
31345 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31346 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31347 return "[vdso]";
31348 if (vma == &gate_vma)
31349 return "[vsyscall]";
31350 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31351 index 7b179b4..6bd17777 100644
31352 --- a/arch/x86/mm/iomap_32.c
31353 +++ b/arch/x86/mm/iomap_32.c
31354 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31355 type = kmap_atomic_idx_push();
31356 idx = type + KM_TYPE_NR * smp_processor_id();
31357 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31358 +
31359 + pax_open_kernel();
31360 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31361 + pax_close_kernel();
31362 +
31363 arch_flush_lazy_mmu_mode();
31364
31365 return (void *)vaddr;
31366 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31367 index 0215e2c..1c62dab 100644
31368 --- a/arch/x86/mm/ioremap.c
31369 +++ b/arch/x86/mm/ioremap.c
31370 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31371 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31372 int is_ram = page_is_ram(pfn);
31373
31374 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31375 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31376 return NULL;
31377 WARN_ON_ONCE(is_ram);
31378 }
31379 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31380 *
31381 * Caller must ensure there is only one unmapping for the same pointer.
31382 */
31383 -void iounmap(volatile void __iomem *addr)
31384 +void iounmap(const volatile void __iomem *addr)
31385 {
31386 struct vm_struct *p, *o;
31387
31388 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31389
31390 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31391 if (page_is_ram(start >> PAGE_SHIFT))
31392 +#ifdef CONFIG_HIGHMEM
31393 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31394 +#endif
31395 return __va(phys);
31396
31397 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31398 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31399 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31400 {
31401 if (page_is_ram(phys >> PAGE_SHIFT))
31402 +#ifdef CONFIG_HIGHMEM
31403 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31404 +#endif
31405 return;
31406
31407 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31408 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31409 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31410
31411 static __initdata int after_paging_init;
31412 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31413 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31414
31415 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31416 {
31417 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31418 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31419
31420 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31421 - memset(bm_pte, 0, sizeof(bm_pte));
31422 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31423 + pmd_populate_user(&init_mm, pmd, bm_pte);
31424
31425 /*
31426 * The boot-ioremap range spans multiple pmds, for which
31427 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31428 index d87dd6d..bf3fa66 100644
31429 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31430 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31431 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31432 * memory (e.g. tracked pages)? For now, we need this to avoid
31433 * invoking kmemcheck for PnP BIOS calls.
31434 */
31435 - if (regs->flags & X86_VM_MASK)
31436 + if (v8086_mode(regs))
31437 return false;
31438 - if (regs->cs != __KERNEL_CS)
31439 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31440 return false;
31441
31442 pte = kmemcheck_pte_lookup(address);
31443 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31444 index 25e7e13..1964579 100644
31445 --- a/arch/x86/mm/mmap.c
31446 +++ b/arch/x86/mm/mmap.c
31447 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31448 * Leave an at least ~128 MB hole with possible stack randomization.
31449 */
31450 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31451 -#define MAX_GAP (TASK_SIZE/6*5)
31452 +#define MAX_GAP (pax_task_size/6*5)
31453
31454 static int mmap_is_legacy(void)
31455 {
31456 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31457 return rnd << PAGE_SHIFT;
31458 }
31459
31460 -static unsigned long mmap_base(void)
31461 +static unsigned long mmap_base(struct mm_struct *mm)
31462 {
31463 unsigned long gap = rlimit(RLIMIT_STACK);
31464 + unsigned long pax_task_size = TASK_SIZE;
31465 +
31466 +#ifdef CONFIG_PAX_SEGMEXEC
31467 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31468 + pax_task_size = SEGMEXEC_TASK_SIZE;
31469 +#endif
31470
31471 if (gap < MIN_GAP)
31472 gap = MIN_GAP;
31473 else if (gap > MAX_GAP)
31474 gap = MAX_GAP;
31475
31476 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31477 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31478 }
31479
31480 /*
31481 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31482 * does, but not when emulating X86_32
31483 */
31484 -static unsigned long mmap_legacy_base(void)
31485 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31486 {
31487 - if (mmap_is_ia32())
31488 + if (mmap_is_ia32()) {
31489 +
31490 +#ifdef CONFIG_PAX_SEGMEXEC
31491 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31492 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31493 + else
31494 +#endif
31495 +
31496 return TASK_UNMAPPED_BASE;
31497 - else
31498 + } else
31499 return TASK_UNMAPPED_BASE + mmap_rnd();
31500 }
31501
31502 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31503 */
31504 void arch_pick_mmap_layout(struct mm_struct *mm)
31505 {
31506 - mm->mmap_legacy_base = mmap_legacy_base();
31507 - mm->mmap_base = mmap_base();
31508 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31509 + mm->mmap_base = mmap_base(mm);
31510 +
31511 +#ifdef CONFIG_PAX_RANDMMAP
31512 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31513 + mm->mmap_legacy_base += mm->delta_mmap;
31514 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31515 + }
31516 +#endif
31517
31518 if (mmap_is_legacy()) {
31519 mm->mmap_base = mm->mmap_legacy_base;
31520 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31521 index 0057a7a..95c7edd 100644
31522 --- a/arch/x86/mm/mmio-mod.c
31523 +++ b/arch/x86/mm/mmio-mod.c
31524 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31525 break;
31526 default:
31527 {
31528 - unsigned char *ip = (unsigned char *)instptr;
31529 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31530 my_trace->opcode = MMIO_UNKNOWN_OP;
31531 my_trace->width = 0;
31532 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31533 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31534 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31535 void __iomem *addr)
31536 {
31537 - static atomic_t next_id;
31538 + static atomic_unchecked_t next_id;
31539 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31540 /* These are page-unaligned. */
31541 struct mmiotrace_map map = {
31542 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31543 .private = trace
31544 },
31545 .phys = offset,
31546 - .id = atomic_inc_return(&next_id)
31547 + .id = atomic_inc_return_unchecked(&next_id)
31548 };
31549 map.map_id = trace->id;
31550
31551 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31552 ioremap_trace_core(offset, size, addr);
31553 }
31554
31555 -static void iounmap_trace_core(volatile void __iomem *addr)
31556 +static void iounmap_trace_core(const volatile void __iomem *addr)
31557 {
31558 struct mmiotrace_map map = {
31559 .phys = 0,
31560 @@ -328,7 +328,7 @@ not_enabled:
31561 }
31562 }
31563
31564 -void mmiotrace_iounmap(volatile void __iomem *addr)
31565 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31566 {
31567 might_sleep();
31568 if (is_enabled()) /* recheck and proper locking in *_core() */
31569 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31570 index 8bf93ba..dbcd670 100644
31571 --- a/arch/x86/mm/numa.c
31572 +++ b/arch/x86/mm/numa.c
31573 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31574 return true;
31575 }
31576
31577 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31578 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31579 {
31580 unsigned long uninitialized_var(pfn_align);
31581 int i, nid;
31582 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31583 index d0b1773..4c3327c 100644
31584 --- a/arch/x86/mm/pageattr-test.c
31585 +++ b/arch/x86/mm/pageattr-test.c
31586 @@ -36,7 +36,7 @@ enum {
31587
31588 static int pte_testbit(pte_t pte)
31589 {
31590 - return pte_flags(pte) & _PAGE_UNUSED1;
31591 + return pte_flags(pte) & _PAGE_CPA_TEST;
31592 }
31593
31594 struct split_state {
31595 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31596 index bb32480..75f2f5e 100644
31597 --- a/arch/x86/mm/pageattr.c
31598 +++ b/arch/x86/mm/pageattr.c
31599 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31600 */
31601 #ifdef CONFIG_PCI_BIOS
31602 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31603 - pgprot_val(forbidden) |= _PAGE_NX;
31604 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31605 #endif
31606
31607 /*
31608 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31609 * Does not cover __inittext since that is gone later on. On
31610 * 64bit we do not enforce !NX on the low mapping
31611 */
31612 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31613 - pgprot_val(forbidden) |= _PAGE_NX;
31614 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31615 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31616
31617 +#ifdef CONFIG_DEBUG_RODATA
31618 /*
31619 * The .rodata section needs to be read-only. Using the pfn
31620 * catches all aliases.
31621 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31622 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31623 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31624 pgprot_val(forbidden) |= _PAGE_RW;
31625 +#endif
31626
31627 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31628 /*
31629 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31630 }
31631 #endif
31632
31633 +#ifdef CONFIG_PAX_KERNEXEC
31634 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31635 + pgprot_val(forbidden) |= _PAGE_RW;
31636 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31637 + }
31638 +#endif
31639 +
31640 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31641
31642 return prot;
31643 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31644 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31645 {
31646 /* change init_mm */
31647 + pax_open_kernel();
31648 set_pte_atomic(kpte, pte);
31649 +
31650 #ifdef CONFIG_X86_32
31651 if (!SHARED_KERNEL_PMD) {
31652 +
31653 +#ifdef CONFIG_PAX_PER_CPU_PGD
31654 + unsigned long cpu;
31655 +#else
31656 struct page *page;
31657 +#endif
31658
31659 +#ifdef CONFIG_PAX_PER_CPU_PGD
31660 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31661 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31662 +#else
31663 list_for_each_entry(page, &pgd_list, lru) {
31664 - pgd_t *pgd;
31665 + pgd_t *pgd = (pgd_t *)page_address(page);
31666 +#endif
31667 +
31668 pud_t *pud;
31669 pmd_t *pmd;
31670
31671 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31672 + pgd += pgd_index(address);
31673 pud = pud_offset(pgd, address);
31674 pmd = pmd_offset(pud, address);
31675 set_pte_atomic((pte_t *)pmd, pte);
31676 }
31677 }
31678 #endif
31679 + pax_close_kernel();
31680 }
31681
31682 static int
31683 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31684 index 6574388..87e9bef 100644
31685 --- a/arch/x86/mm/pat.c
31686 +++ b/arch/x86/mm/pat.c
31687 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31688
31689 if (!entry) {
31690 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31691 - current->comm, current->pid, start, end - 1);
31692 + current->comm, task_pid_nr(current), start, end - 1);
31693 return -EINVAL;
31694 }
31695
31696 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31697
31698 while (cursor < to) {
31699 if (!devmem_is_allowed(pfn)) {
31700 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31701 - current->comm, from, to - 1);
31702 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31703 + current->comm, from, to - 1, cursor);
31704 return 0;
31705 }
31706 cursor += PAGE_SIZE;
31707 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31708 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31709 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31710 "for [mem %#010Lx-%#010Lx]\n",
31711 - current->comm, current->pid,
31712 + current->comm, task_pid_nr(current),
31713 cattr_name(flags),
31714 base, (unsigned long long)(base + size-1));
31715 return -EINVAL;
31716 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31717 flags = lookup_memtype(paddr);
31718 if (want_flags != flags) {
31719 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31720 - current->comm, current->pid,
31721 + current->comm, task_pid_nr(current),
31722 cattr_name(want_flags),
31723 (unsigned long long)paddr,
31724 (unsigned long long)(paddr + size - 1),
31725 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31726 free_memtype(paddr, paddr + size);
31727 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31728 " for [mem %#010Lx-%#010Lx], got %s\n",
31729 - current->comm, current->pid,
31730 + current->comm, task_pid_nr(current),
31731 cattr_name(want_flags),
31732 (unsigned long long)paddr,
31733 (unsigned long long)(paddr + size - 1),
31734 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31735 index 415f6c4..d319983 100644
31736 --- a/arch/x86/mm/pat_rbtree.c
31737 +++ b/arch/x86/mm/pat_rbtree.c
31738 @@ -160,7 +160,7 @@ success:
31739
31740 failure:
31741 printk(KERN_INFO "%s:%d conflicting memory types "
31742 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31743 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31744 end, cattr_name(found_type), cattr_name(match->type));
31745 return -EBUSY;
31746 }
31747 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31748 index 9f0614d..92ae64a 100644
31749 --- a/arch/x86/mm/pf_in.c
31750 +++ b/arch/x86/mm/pf_in.c
31751 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31752 int i;
31753 enum reason_type rv = OTHERS;
31754
31755 - p = (unsigned char *)ins_addr;
31756 + p = (unsigned char *)ktla_ktva(ins_addr);
31757 p += skip_prefix(p, &prf);
31758 p += get_opcode(p, &opcode);
31759
31760 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31761 struct prefix_bits prf;
31762 int i;
31763
31764 - p = (unsigned char *)ins_addr;
31765 + p = (unsigned char *)ktla_ktva(ins_addr);
31766 p += skip_prefix(p, &prf);
31767 p += get_opcode(p, &opcode);
31768
31769 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31770 struct prefix_bits prf;
31771 int i;
31772
31773 - p = (unsigned char *)ins_addr;
31774 + p = (unsigned char *)ktla_ktva(ins_addr);
31775 p += skip_prefix(p, &prf);
31776 p += get_opcode(p, &opcode);
31777
31778 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31779 struct prefix_bits prf;
31780 int i;
31781
31782 - p = (unsigned char *)ins_addr;
31783 + p = (unsigned char *)ktla_ktva(ins_addr);
31784 p += skip_prefix(p, &prf);
31785 p += get_opcode(p, &opcode);
31786 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31787 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31788 struct prefix_bits prf;
31789 int i;
31790
31791 - p = (unsigned char *)ins_addr;
31792 + p = (unsigned char *)ktla_ktva(ins_addr);
31793 p += skip_prefix(p, &prf);
31794 p += get_opcode(p, &opcode);
31795 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31796 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31797 index dfa537a..fd45c64 100644
31798 --- a/arch/x86/mm/pgtable.c
31799 +++ b/arch/x86/mm/pgtable.c
31800 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31801 list_del(&page->lru);
31802 }
31803
31804 -#define UNSHARED_PTRS_PER_PGD \
31805 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31806 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31807 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31808
31809 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31810 +{
31811 + unsigned int count = USER_PGD_PTRS;
31812
31813 + if (!pax_user_shadow_base)
31814 + return;
31815 +
31816 + while (count--)
31817 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31818 +}
31819 +#endif
31820 +
31821 +#ifdef CONFIG_PAX_PER_CPU_PGD
31822 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31823 +{
31824 + unsigned int count = USER_PGD_PTRS;
31825 +
31826 + while (count--) {
31827 + pgd_t pgd;
31828 +
31829 +#ifdef CONFIG_X86_64
31830 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31831 +#else
31832 + pgd = *src++;
31833 +#endif
31834 +
31835 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31836 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31837 +#endif
31838 +
31839 + *dst++ = pgd;
31840 + }
31841 +
31842 +}
31843 +#endif
31844 +
31845 +#ifdef CONFIG_X86_64
31846 +#define pxd_t pud_t
31847 +#define pyd_t pgd_t
31848 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31849 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31850 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31851 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31852 +#define PYD_SIZE PGDIR_SIZE
31853 +#else
31854 +#define pxd_t pmd_t
31855 +#define pyd_t pud_t
31856 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31857 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31858 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31859 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31860 +#define PYD_SIZE PUD_SIZE
31861 +#endif
31862 +
31863 +#ifdef CONFIG_PAX_PER_CPU_PGD
31864 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31865 +static inline void pgd_dtor(pgd_t *pgd) {}
31866 +#else
31867 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31868 {
31869 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31870 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31871 pgd_list_del(pgd);
31872 spin_unlock(&pgd_lock);
31873 }
31874 +#endif
31875
31876 /*
31877 * List of all pgd's needed for non-PAE so it can invalidate entries
31878 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31879 * -- nyc
31880 */
31881
31882 -#ifdef CONFIG_X86_PAE
31883 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31884 /*
31885 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31886 * updating the top-level pagetable entries to guarantee the
31887 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31888 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31889 * and initialize the kernel pmds here.
31890 */
31891 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31892 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31893
31894 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31895 {
31896 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31897 */
31898 flush_tlb_mm(mm);
31899 }
31900 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31901 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31902 #else /* !CONFIG_X86_PAE */
31903
31904 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31905 -#define PREALLOCATED_PMDS 0
31906 +#define PREALLOCATED_PXDS 0
31907
31908 #endif /* CONFIG_X86_PAE */
31909
31910 -static void free_pmds(pmd_t *pmds[])
31911 +static void free_pxds(pxd_t *pxds[])
31912 {
31913 int i;
31914
31915 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31916 - if (pmds[i])
31917 - free_page((unsigned long)pmds[i]);
31918 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31919 + if (pxds[i])
31920 + free_page((unsigned long)pxds[i]);
31921 }
31922
31923 -static int preallocate_pmds(pmd_t *pmds[])
31924 +static int preallocate_pxds(pxd_t *pxds[])
31925 {
31926 int i;
31927 bool failed = false;
31928
31929 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31930 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31931 - if (pmd == NULL)
31932 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31933 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31934 + if (pxd == NULL)
31935 failed = true;
31936 - pmds[i] = pmd;
31937 + pxds[i] = pxd;
31938 }
31939
31940 if (failed) {
31941 - free_pmds(pmds);
31942 + free_pxds(pxds);
31943 return -ENOMEM;
31944 }
31945
31946 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31947 * preallocate which never got a corresponding vma will need to be
31948 * freed manually.
31949 */
31950 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31951 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31952 {
31953 int i;
31954
31955 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31956 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31957 pgd_t pgd = pgdp[i];
31958
31959 if (pgd_val(pgd) != 0) {
31960 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31961 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31962
31963 - pgdp[i] = native_make_pgd(0);
31964 + set_pgd(pgdp + i, native_make_pgd(0));
31965
31966 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31967 - pmd_free(mm, pmd);
31968 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31969 + pxd_free(mm, pxd);
31970 }
31971 }
31972 }
31973
31974 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31975 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31976 {
31977 - pud_t *pud;
31978 + pyd_t *pyd;
31979 int i;
31980
31981 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31982 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31983 return;
31984
31985 - pud = pud_offset(pgd, 0);
31986 -
31987 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31988 - pmd_t *pmd = pmds[i];
31989 +#ifdef CONFIG_X86_64
31990 + pyd = pyd_offset(mm, 0L);
31991 +#else
31992 + pyd = pyd_offset(pgd, 0L);
31993 +#endif
31994
31995 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31996 + pxd_t *pxd = pxds[i];
31997 if (i >= KERNEL_PGD_BOUNDARY)
31998 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31999 - sizeof(pmd_t) * PTRS_PER_PMD);
32000 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32001 + sizeof(pxd_t) * PTRS_PER_PMD);
32002
32003 - pud_populate(mm, pud, pmd);
32004 + pyd_populate(mm, pyd, pxd);
32005 }
32006 }
32007
32008 pgd_t *pgd_alloc(struct mm_struct *mm)
32009 {
32010 pgd_t *pgd;
32011 - pmd_t *pmds[PREALLOCATED_PMDS];
32012 + pxd_t *pxds[PREALLOCATED_PXDS];
32013
32014 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32015
32016 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32017
32018 mm->pgd = pgd;
32019
32020 - if (preallocate_pmds(pmds) != 0)
32021 + if (preallocate_pxds(pxds) != 0)
32022 goto out_free_pgd;
32023
32024 if (paravirt_pgd_alloc(mm) != 0)
32025 - goto out_free_pmds;
32026 + goto out_free_pxds;
32027
32028 /*
32029 * Make sure that pre-populating the pmds is atomic with
32030 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32031 spin_lock(&pgd_lock);
32032
32033 pgd_ctor(mm, pgd);
32034 - pgd_prepopulate_pmd(mm, pgd, pmds);
32035 + pgd_prepopulate_pxd(mm, pgd, pxds);
32036
32037 spin_unlock(&pgd_lock);
32038
32039 return pgd;
32040
32041 -out_free_pmds:
32042 - free_pmds(pmds);
32043 +out_free_pxds:
32044 + free_pxds(pxds);
32045 out_free_pgd:
32046 free_page((unsigned long)pgd);
32047 out:
32048 @@ -300,7 +363,7 @@ out:
32049
32050 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32051 {
32052 - pgd_mop_up_pmds(mm, pgd);
32053 + pgd_mop_up_pxds(mm, pgd);
32054 pgd_dtor(pgd);
32055 paravirt_pgd_free(mm, pgd);
32056 free_page((unsigned long)pgd);
32057 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32058 index a69bcb8..19068ab 100644
32059 --- a/arch/x86/mm/pgtable_32.c
32060 +++ b/arch/x86/mm/pgtable_32.c
32061 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32062 return;
32063 }
32064 pte = pte_offset_kernel(pmd, vaddr);
32065 +
32066 + pax_open_kernel();
32067 if (pte_val(pteval))
32068 set_pte_at(&init_mm, vaddr, pte, pteval);
32069 else
32070 pte_clear(&init_mm, vaddr, pte);
32071 + pax_close_kernel();
32072
32073 /*
32074 * It's enough to flush this one mapping.
32075 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32076 index e666cbb..61788c45 100644
32077 --- a/arch/x86/mm/physaddr.c
32078 +++ b/arch/x86/mm/physaddr.c
32079 @@ -10,7 +10,7 @@
32080 #ifdef CONFIG_X86_64
32081
32082 #ifdef CONFIG_DEBUG_VIRTUAL
32083 -unsigned long __phys_addr(unsigned long x)
32084 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32085 {
32086 unsigned long y = x - __START_KERNEL_map;
32087
32088 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32089 #else
32090
32091 #ifdef CONFIG_DEBUG_VIRTUAL
32092 -unsigned long __phys_addr(unsigned long x)
32093 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32094 {
32095 unsigned long phys_addr = x - PAGE_OFFSET;
32096 /* VMALLOC_* aren't constants */
32097 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32098 index 90555bf..f5f1828 100644
32099 --- a/arch/x86/mm/setup_nx.c
32100 +++ b/arch/x86/mm/setup_nx.c
32101 @@ -5,8 +5,10 @@
32102 #include <asm/pgtable.h>
32103 #include <asm/proto.h>
32104
32105 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32106 static int disable_nx;
32107
32108 +#ifndef CONFIG_PAX_PAGEEXEC
32109 /*
32110 * noexec = on|off
32111 *
32112 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32113 return 0;
32114 }
32115 early_param("noexec", noexec_setup);
32116 +#endif
32117 +
32118 +#endif
32119
32120 void x86_configure_nx(void)
32121 {
32122 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32123 if (cpu_has_nx && !disable_nx)
32124 __supported_pte_mask |= _PAGE_NX;
32125 else
32126 +#endif
32127 __supported_pte_mask &= ~_PAGE_NX;
32128 }
32129
32130 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32131 index 282375f..e03a98f 100644
32132 --- a/arch/x86/mm/tlb.c
32133 +++ b/arch/x86/mm/tlb.c
32134 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32135 BUG();
32136 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32137 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32138 +
32139 +#ifndef CONFIG_PAX_PER_CPU_PGD
32140 load_cr3(swapper_pg_dir);
32141 +#endif
32142 +
32143 }
32144 }
32145 EXPORT_SYMBOL_GPL(leave_mm);
32146 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32147 new file mode 100644
32148 index 0000000..dace51c
32149 --- /dev/null
32150 +++ b/arch/x86/mm/uderef_64.c
32151 @@ -0,0 +1,37 @@
32152 +#include <linux/mm.h>
32153 +#include <asm/pgtable.h>
32154 +#include <asm/uaccess.h>
32155 +
32156 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32157 +/* PaX: due to the special call convention these functions must
32158 + * - remain leaf functions under all configurations,
32159 + * - never be called directly, only dereferenced from the wrappers.
32160 + */
32161 +void __pax_open_userland(void)
32162 +{
32163 + unsigned int cpu;
32164 +
32165 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32166 + return;
32167 +
32168 + cpu = raw_get_cpu();
32169 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32170 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32171 + raw_put_cpu_no_resched();
32172 +}
32173 +EXPORT_SYMBOL(__pax_open_userland);
32174 +
32175 +void __pax_close_userland(void)
32176 +{
32177 + unsigned int cpu;
32178 +
32179 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32180 + return;
32181 +
32182 + cpu = raw_get_cpu();
32183 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32184 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32185 + raw_put_cpu_no_resched();
32186 +}
32187 +EXPORT_SYMBOL(__pax_close_userland);
32188 +#endif
32189 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32190 index 877b9a1..a8ecf42 100644
32191 --- a/arch/x86/net/bpf_jit.S
32192 +++ b/arch/x86/net/bpf_jit.S
32193 @@ -9,6 +9,7 @@
32194 */
32195 #include <linux/linkage.h>
32196 #include <asm/dwarf2.h>
32197 +#include <asm/alternative-asm.h>
32198
32199 /*
32200 * Calling convention :
32201 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32202 jle bpf_slow_path_word
32203 mov (SKBDATA,%rsi),%eax
32204 bswap %eax /* ntohl() */
32205 + pax_force_retaddr
32206 ret
32207
32208 sk_load_half:
32209 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32210 jle bpf_slow_path_half
32211 movzwl (SKBDATA,%rsi),%eax
32212 rol $8,%ax # ntohs()
32213 + pax_force_retaddr
32214 ret
32215
32216 sk_load_byte:
32217 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32218 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32219 jle bpf_slow_path_byte
32220 movzbl (SKBDATA,%rsi),%eax
32221 + pax_force_retaddr
32222 ret
32223
32224 /**
32225 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32226 movzbl (SKBDATA,%rsi),%ebx
32227 and $15,%bl
32228 shl $2,%bl
32229 + pax_force_retaddr
32230 ret
32231
32232 /* rsi contains offset and can be scratched */
32233 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32234 js bpf_error
32235 mov -12(%rbp),%eax
32236 bswap %eax
32237 + pax_force_retaddr
32238 ret
32239
32240 bpf_slow_path_half:
32241 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32242 mov -12(%rbp),%ax
32243 rol $8,%ax
32244 movzwl %ax,%eax
32245 + pax_force_retaddr
32246 ret
32247
32248 bpf_slow_path_byte:
32249 bpf_slow_path_common(1)
32250 js bpf_error
32251 movzbl -12(%rbp),%eax
32252 + pax_force_retaddr
32253 ret
32254
32255 bpf_slow_path_byte_msh:
32256 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32257 and $15,%al
32258 shl $2,%al
32259 xchg %eax,%ebx
32260 + pax_force_retaddr
32261 ret
32262
32263 #define sk_negative_common(SIZE) \
32264 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32265 sk_negative_common(4)
32266 mov (%rax), %eax
32267 bswap %eax
32268 + pax_force_retaddr
32269 ret
32270
32271 bpf_slow_path_half_neg:
32272 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32273 mov (%rax),%ax
32274 rol $8,%ax
32275 movzwl %ax,%eax
32276 + pax_force_retaddr
32277 ret
32278
32279 bpf_slow_path_byte_neg:
32280 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32281 .globl sk_load_byte_negative_offset
32282 sk_negative_common(1)
32283 movzbl (%rax), %eax
32284 + pax_force_retaddr
32285 ret
32286
32287 bpf_slow_path_byte_msh_neg:
32288 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32289 and $15,%al
32290 shl $2,%al
32291 xchg %eax,%ebx
32292 + pax_force_retaddr
32293 ret
32294
32295 bpf_error:
32296 @@ -197,4 +210,5 @@ bpf_error:
32297 xor %eax,%eax
32298 mov -8(%rbp),%rbx
32299 leaveq
32300 + pax_force_retaddr
32301 ret
32302 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32303 index 79c216a..08d39cc 100644
32304 --- a/arch/x86/net/bpf_jit_comp.c
32305 +++ b/arch/x86/net/bpf_jit_comp.c
32306 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32307 return ptr + len;
32308 }
32309
32310 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32311 +#define MAX_INSTR_CODE_SIZE 96
32312 +#else
32313 +#define MAX_INSTR_CODE_SIZE 64
32314 +#endif
32315 +
32316 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32317
32318 #define EMIT1(b1) EMIT(b1, 1)
32319 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32320 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32321 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32322 +
32323 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32324 +/* original constant will appear in ecx */
32325 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32326 +do { \
32327 + /* mov ecx, randkey */ \
32328 + EMIT1(0xb9); \
32329 + EMIT(_key, 4); \
32330 + /* xor ecx, randkey ^ off */ \
32331 + EMIT2(0x81, 0xf1); \
32332 + EMIT((_key) ^ (_off), 4); \
32333 +} while (0)
32334 +
32335 +#define EMIT1_off32(b1, _off) \
32336 +do { \
32337 + switch (b1) { \
32338 + case 0x05: /* add eax, imm32 */ \
32339 + case 0x2d: /* sub eax, imm32 */ \
32340 + case 0x25: /* and eax, imm32 */ \
32341 + case 0x0d: /* or eax, imm32 */ \
32342 + case 0xb8: /* mov eax, imm32 */ \
32343 + case 0x35: /* xor eax, imm32 */ \
32344 + case 0x3d: /* cmp eax, imm32 */ \
32345 + case 0xa9: /* test eax, imm32 */ \
32346 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32347 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32348 + break; \
32349 + case 0xbb: /* mov ebx, imm32 */ \
32350 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32351 + /* mov ebx, ecx */ \
32352 + EMIT2(0x89, 0xcb); \
32353 + break; \
32354 + case 0xbe: /* mov esi, imm32 */ \
32355 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32356 + /* mov esi, ecx */ \
32357 + EMIT2(0x89, 0xce); \
32358 + break; \
32359 + case 0xe8: /* call rel imm32, always to known funcs */ \
32360 + EMIT1(b1); \
32361 + EMIT(_off, 4); \
32362 + break; \
32363 + case 0xe9: /* jmp rel imm32 */ \
32364 + EMIT1(b1); \
32365 + EMIT(_off, 4); \
32366 + /* prevent fall-through, we're not called if off = 0 */ \
32367 + EMIT(0xcccccccc, 4); \
32368 + EMIT(0xcccccccc, 4); \
32369 + break; \
32370 + default: \
32371 + BUILD_BUG(); \
32372 + } \
32373 +} while (0)
32374 +
32375 +#define EMIT2_off32(b1, b2, _off) \
32376 +do { \
32377 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32378 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32379 + EMIT(randkey, 4); \
32380 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32381 + EMIT((_off) - randkey, 4); \
32382 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32383 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32384 + /* imul eax, ecx */ \
32385 + EMIT3(0x0f, 0xaf, 0xc1); \
32386 + } else { \
32387 + BUILD_BUG(); \
32388 + } \
32389 +} while (0)
32390 +#else
32391 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32392 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32393 +#endif
32394
32395 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32396 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32397 @@ -91,6 +168,24 @@ do { \
32398 #define X86_JBE 0x76
32399 #define X86_JA 0x77
32400
32401 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32402 +#define APPEND_FLOW_VERIFY() \
32403 +do { \
32404 + /* mov ecx, randkey */ \
32405 + EMIT1(0xb9); \
32406 + EMIT(randkey, 4); \
32407 + /* cmp ecx, randkey */ \
32408 + EMIT2(0x81, 0xf9); \
32409 + EMIT(randkey, 4); \
32410 + /* jz after 8 int 3s */ \
32411 + EMIT2(0x74, 0x08); \
32412 + EMIT(0xcccccccc, 4); \
32413 + EMIT(0xcccccccc, 4); \
32414 +} while (0)
32415 +#else
32416 +#define APPEND_FLOW_VERIFY() do { } while (0)
32417 +#endif
32418 +
32419 #define EMIT_COND_JMP(op, offset) \
32420 do { \
32421 if (is_near(offset)) \
32422 @@ -98,6 +193,7 @@ do { \
32423 else { \
32424 EMIT2(0x0f, op + 0x10); \
32425 EMIT(offset, 4); /* jxx .+off32 */ \
32426 + APPEND_FLOW_VERIFY(); \
32427 } \
32428 } while (0)
32429
32430 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32431 return -1;
32432 }
32433
32434 -struct bpf_binary_header {
32435 - unsigned int pages;
32436 - /* Note : for security reasons, bpf code will follow a randomly
32437 - * sized amount of int3 instructions
32438 - */
32439 - u8 image[];
32440 -};
32441 -
32442 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32443 +/* Note : for security reasons, bpf code will follow a randomly
32444 + * sized amount of int3 instructions
32445 + */
32446 +static u8 *bpf_alloc_binary(unsigned int proglen,
32447 u8 **image_ptr)
32448 {
32449 unsigned int sz, hole;
32450 - struct bpf_binary_header *header;
32451 + u8 *header;
32452
32453 /* Most of BPF filters are really small,
32454 * but if some of them fill a page, allow at least
32455 * 128 extra bytes to insert a random section of int3
32456 */
32457 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32458 - header = module_alloc(sz);
32459 + sz = round_up(proglen + 128, PAGE_SIZE);
32460 + header = module_alloc_exec(sz);
32461 if (!header)
32462 return NULL;
32463
32464 + pax_open_kernel();
32465 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32466 + pax_close_kernel();
32467
32468 - header->pages = sz / PAGE_SIZE;
32469 - hole = sz - (proglen + sizeof(*header));
32470 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32471
32472 /* insert a random number of int3 instructions before BPF code */
32473 - *image_ptr = &header->image[prandom_u32() % hole];
32474 + *image_ptr = &header[prandom_u32() % hole];
32475 return header;
32476 }
32477
32478 void bpf_jit_compile(struct sk_filter *fp)
32479 {
32480 - u8 temp[64];
32481 + u8 temp[MAX_INSTR_CODE_SIZE];
32482 u8 *prog;
32483 unsigned int proglen, oldproglen = 0;
32484 int ilen, i;
32485 int t_offset, f_offset;
32486 u8 t_op, f_op, seen = 0, pass;
32487 u8 *image = NULL;
32488 - struct bpf_binary_header *header = NULL;
32489 + u8 *header = NULL;
32490 u8 *func;
32491 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32492 unsigned int cleanup_addr; /* epilogue code offset */
32493 unsigned int *addrs;
32494 const struct sock_filter *filter = fp->insns;
32495 int flen = fp->len;
32496 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32497 + unsigned int randkey;
32498 +#endif
32499
32500 if (!bpf_jit_enable)
32501 return;
32502 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32503 if (addrs == NULL)
32504 return;
32505
32506 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32507 + randkey = get_random_int();
32508 +#endif
32509 +
32510 /* Before first pass, make a rough estimation of addrs[]
32511 - * each bpf instruction is translated to less than 64 bytes
32512 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32513 */
32514 for (proglen = 0, i = 0; i < flen; i++) {
32515 - proglen += 64;
32516 + proglen += MAX_INSTR_CODE_SIZE;
32517 addrs[i] = proglen;
32518 }
32519 cleanup_addr = proglen; /* epilogue address */
32520 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32521 case BPF_S_ALU_MUL_K: /* A *= K */
32522 if (is_imm8(K))
32523 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32524 - else {
32525 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32526 - EMIT(K, 4);
32527 - }
32528 + else
32529 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32530 break;
32531 case BPF_S_ALU_DIV_X: /* A /= X; */
32532 seen |= SEEN_XREG;
32533 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32534 break;
32535 case BPF_S_ALU_MOD_K: /* A %= K; */
32536 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32537 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32538 + DILUTE_CONST_SEQUENCE(K, randkey);
32539 +#else
32540 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32541 +#endif
32542 EMIT2(0xf7, 0xf1); /* div %ecx */
32543 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32544 break;
32545 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32546 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32547 + DILUTE_CONST_SEQUENCE(K, randkey);
32548 + // imul rax, rcx
32549 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32550 +#else
32551 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32552 EMIT(K, 4);
32553 +#endif
32554 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32555 break;
32556 case BPF_S_ALU_AND_X:
32557 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32558 if (is_imm8(K)) {
32559 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32560 } else {
32561 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32562 - EMIT(K, 4);
32563 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32564 }
32565 } else {
32566 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32567 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32568 if (unlikely(proglen + ilen > oldproglen)) {
32569 pr_err("bpb_jit_compile fatal error\n");
32570 kfree(addrs);
32571 - module_free(NULL, header);
32572 + module_free_exec(NULL, image);
32573 return;
32574 }
32575 + pax_open_kernel();
32576 memcpy(image + proglen, temp, ilen);
32577 + pax_close_kernel();
32578 }
32579 proglen += ilen;
32580 addrs[i] = proglen;
32581 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32582
32583 if (image) {
32584 bpf_flush_icache(header, image + proglen);
32585 - set_memory_ro((unsigned long)header, header->pages);
32586 fp->bpf_func = (void *)image;
32587 }
32588 out:
32589 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32590 {
32591 if (fp->bpf_func != sk_run_filter) {
32592 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32593 - struct bpf_binary_header *header = (void *)addr;
32594 -
32595 - set_memory_rw(addr, header->pages);
32596 - module_free(NULL, header);
32597 + set_memory_rw(addr, 1);
32598 + module_free_exec(NULL, (void *)addr);
32599 }
32600 }
32601 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32602 index d6aa6e8..266395a 100644
32603 --- a/arch/x86/oprofile/backtrace.c
32604 +++ b/arch/x86/oprofile/backtrace.c
32605 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32606 struct stack_frame_ia32 *fp;
32607 unsigned long bytes;
32608
32609 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32610 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32611 if (bytes != sizeof(bufhead))
32612 return NULL;
32613
32614 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32615 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32616
32617 oprofile_add_trace(bufhead[0].return_address);
32618
32619 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32620 struct stack_frame bufhead[2];
32621 unsigned long bytes;
32622
32623 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32624 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32625 if (bytes != sizeof(bufhead))
32626 return NULL;
32627
32628 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32629 {
32630 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32631
32632 - if (!user_mode_vm(regs)) {
32633 + if (!user_mode(regs)) {
32634 unsigned long stack = kernel_stack_pointer(regs);
32635 if (depth)
32636 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32637 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32638 index 48768df..ba9143c 100644
32639 --- a/arch/x86/oprofile/nmi_int.c
32640 +++ b/arch/x86/oprofile/nmi_int.c
32641 @@ -23,6 +23,7 @@
32642 #include <asm/nmi.h>
32643 #include <asm/msr.h>
32644 #include <asm/apic.h>
32645 +#include <asm/pgtable.h>
32646
32647 #include "op_counter.h"
32648 #include "op_x86_model.h"
32649 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32650 if (ret)
32651 return ret;
32652
32653 - if (!model->num_virt_counters)
32654 - model->num_virt_counters = model->num_counters;
32655 + if (!model->num_virt_counters) {
32656 + pax_open_kernel();
32657 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32658 + pax_close_kernel();
32659 + }
32660
32661 mux_init(ops);
32662
32663 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32664 index b2b9443..be58856 100644
32665 --- a/arch/x86/oprofile/op_model_amd.c
32666 +++ b/arch/x86/oprofile/op_model_amd.c
32667 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32668 num_counters = AMD64_NUM_COUNTERS;
32669 }
32670
32671 - op_amd_spec.num_counters = num_counters;
32672 - op_amd_spec.num_controls = num_counters;
32673 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32674 + pax_open_kernel();
32675 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32676 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32677 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32678 + pax_close_kernel();
32679
32680 return 0;
32681 }
32682 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32683 index d90528e..0127e2b 100644
32684 --- a/arch/x86/oprofile/op_model_ppro.c
32685 +++ b/arch/x86/oprofile/op_model_ppro.c
32686 @@ -19,6 +19,7 @@
32687 #include <asm/msr.h>
32688 #include <asm/apic.h>
32689 #include <asm/nmi.h>
32690 +#include <asm/pgtable.h>
32691
32692 #include "op_x86_model.h"
32693 #include "op_counter.h"
32694 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32695
32696 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32697
32698 - op_arch_perfmon_spec.num_counters = num_counters;
32699 - op_arch_perfmon_spec.num_controls = num_counters;
32700 + pax_open_kernel();
32701 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32702 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32703 + pax_close_kernel();
32704 }
32705
32706 static int arch_perfmon_init(struct oprofile_operations *ignore)
32707 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32708 index 71e8a67..6a313bb 100644
32709 --- a/arch/x86/oprofile/op_x86_model.h
32710 +++ b/arch/x86/oprofile/op_x86_model.h
32711 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32712 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32713 struct op_msrs const * const msrs);
32714 #endif
32715 -};
32716 +} __do_const;
32717
32718 struct op_counter_config;
32719
32720 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32721 index 372e9b8..e775a6c 100644
32722 --- a/arch/x86/pci/irq.c
32723 +++ b/arch/x86/pci/irq.c
32724 @@ -50,7 +50,7 @@ struct irq_router {
32725 struct irq_router_handler {
32726 u16 vendor;
32727 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32728 -};
32729 +} __do_const;
32730
32731 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32732 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32733 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32734 return 0;
32735 }
32736
32737 -static __initdata struct irq_router_handler pirq_routers[] = {
32738 +static __initconst const struct irq_router_handler pirq_routers[] = {
32739 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32740 { PCI_VENDOR_ID_AL, ali_router_probe },
32741 { PCI_VENDOR_ID_ITE, ite_router_probe },
32742 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32743 static void __init pirq_find_router(struct irq_router *r)
32744 {
32745 struct irq_routing_table *rt = pirq_table;
32746 - struct irq_router_handler *h;
32747 + const struct irq_router_handler *h;
32748
32749 #ifdef CONFIG_PCI_BIOS
32750 if (!rt->signature) {
32751 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32752 return 0;
32753 }
32754
32755 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32756 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32757 {
32758 .callback = fix_broken_hp_bios_irq9,
32759 .ident = "HP Pavilion N5400 Series Laptop",
32760 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32761 index 6eb18c4..20d83de 100644
32762 --- a/arch/x86/pci/mrst.c
32763 +++ b/arch/x86/pci/mrst.c
32764 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32765 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32766 pci_mmcfg_late_init();
32767 pcibios_enable_irq = mrst_pci_irq_enable;
32768 - pci_root_ops = pci_mrst_ops;
32769 + pax_open_kernel();
32770 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32771 + pax_close_kernel();
32772 pci_soc_mode = 1;
32773 /* Continue with standard init */
32774 return 1;
32775 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32776 index c77b24a..c979855 100644
32777 --- a/arch/x86/pci/pcbios.c
32778 +++ b/arch/x86/pci/pcbios.c
32779 @@ -79,7 +79,7 @@ union bios32 {
32780 static struct {
32781 unsigned long address;
32782 unsigned short segment;
32783 -} bios32_indirect = { 0, __KERNEL_CS };
32784 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32785
32786 /*
32787 * Returns the entry point for the given service, NULL on error
32788 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32789 unsigned long length; /* %ecx */
32790 unsigned long entry; /* %edx */
32791 unsigned long flags;
32792 + struct desc_struct d, *gdt;
32793
32794 local_irq_save(flags);
32795 - __asm__("lcall *(%%edi); cld"
32796 +
32797 + gdt = get_cpu_gdt_table(smp_processor_id());
32798 +
32799 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32800 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32801 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32802 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32803 +
32804 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32805 : "=a" (return_code),
32806 "=b" (address),
32807 "=c" (length),
32808 "=d" (entry)
32809 : "0" (service),
32810 "1" (0),
32811 - "D" (&bios32_indirect));
32812 + "D" (&bios32_indirect),
32813 + "r"(__PCIBIOS_DS)
32814 + : "memory");
32815 +
32816 + pax_open_kernel();
32817 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32818 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32819 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32820 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32821 + pax_close_kernel();
32822 +
32823 local_irq_restore(flags);
32824
32825 switch (return_code) {
32826 - case 0:
32827 - return address + entry;
32828 - case 0x80: /* Not present */
32829 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32830 - return 0;
32831 - default: /* Shouldn't happen */
32832 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32833 - service, return_code);
32834 + case 0: {
32835 + int cpu;
32836 + unsigned char flags;
32837 +
32838 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32839 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32840 + printk(KERN_WARNING "bios32_service: not valid\n");
32841 return 0;
32842 + }
32843 + address = address + PAGE_OFFSET;
32844 + length += 16UL; /* some BIOSs underreport this... */
32845 + flags = 4;
32846 + if (length >= 64*1024*1024) {
32847 + length >>= PAGE_SHIFT;
32848 + flags |= 8;
32849 + }
32850 +
32851 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32852 + gdt = get_cpu_gdt_table(cpu);
32853 + pack_descriptor(&d, address, length, 0x9b, flags);
32854 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32855 + pack_descriptor(&d, address, length, 0x93, flags);
32856 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32857 + }
32858 + return entry;
32859 + }
32860 + case 0x80: /* Not present */
32861 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32862 + return 0;
32863 + default: /* Shouldn't happen */
32864 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32865 + service, return_code);
32866 + return 0;
32867 }
32868 }
32869
32870 static struct {
32871 unsigned long address;
32872 unsigned short segment;
32873 -} pci_indirect = { 0, __KERNEL_CS };
32874 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32875
32876 -static int pci_bios_present;
32877 +static int pci_bios_present __read_only;
32878
32879 static int check_pcibios(void)
32880 {
32881 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32882 unsigned long flags, pcibios_entry;
32883
32884 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32885 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32886 + pci_indirect.address = pcibios_entry;
32887
32888 local_irq_save(flags);
32889 - __asm__(
32890 - "lcall *(%%edi); cld\n\t"
32891 + __asm__("movw %w6, %%ds\n\t"
32892 + "lcall *%%ss:(%%edi); cld\n\t"
32893 + "push %%ss\n\t"
32894 + "pop %%ds\n\t"
32895 "jc 1f\n\t"
32896 "xor %%ah, %%ah\n"
32897 "1:"
32898 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32899 "=b" (ebx),
32900 "=c" (ecx)
32901 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32902 - "D" (&pci_indirect)
32903 + "D" (&pci_indirect),
32904 + "r" (__PCIBIOS_DS)
32905 : "memory");
32906 local_irq_restore(flags);
32907
32908 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32909
32910 switch (len) {
32911 case 1:
32912 - __asm__("lcall *(%%esi); cld\n\t"
32913 + __asm__("movw %w6, %%ds\n\t"
32914 + "lcall *%%ss:(%%esi); cld\n\t"
32915 + "push %%ss\n\t"
32916 + "pop %%ds\n\t"
32917 "jc 1f\n\t"
32918 "xor %%ah, %%ah\n"
32919 "1:"
32920 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32921 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32922 "b" (bx),
32923 "D" ((long)reg),
32924 - "S" (&pci_indirect));
32925 + "S" (&pci_indirect),
32926 + "r" (__PCIBIOS_DS));
32927 /*
32928 * Zero-extend the result beyond 8 bits, do not trust the
32929 * BIOS having done it:
32930 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32931 *value &= 0xff;
32932 break;
32933 case 2:
32934 - __asm__("lcall *(%%esi); cld\n\t"
32935 + __asm__("movw %w6, %%ds\n\t"
32936 + "lcall *%%ss:(%%esi); cld\n\t"
32937 + "push %%ss\n\t"
32938 + "pop %%ds\n\t"
32939 "jc 1f\n\t"
32940 "xor %%ah, %%ah\n"
32941 "1:"
32942 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32943 : "1" (PCIBIOS_READ_CONFIG_WORD),
32944 "b" (bx),
32945 "D" ((long)reg),
32946 - "S" (&pci_indirect));
32947 + "S" (&pci_indirect),
32948 + "r" (__PCIBIOS_DS));
32949 /*
32950 * Zero-extend the result beyond 16 bits, do not trust the
32951 * BIOS having done it:
32952 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32953 *value &= 0xffff;
32954 break;
32955 case 4:
32956 - __asm__("lcall *(%%esi); cld\n\t"
32957 + __asm__("movw %w6, %%ds\n\t"
32958 + "lcall *%%ss:(%%esi); cld\n\t"
32959 + "push %%ss\n\t"
32960 + "pop %%ds\n\t"
32961 "jc 1f\n\t"
32962 "xor %%ah, %%ah\n"
32963 "1:"
32964 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32965 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32966 "b" (bx),
32967 "D" ((long)reg),
32968 - "S" (&pci_indirect));
32969 + "S" (&pci_indirect),
32970 + "r" (__PCIBIOS_DS));
32971 break;
32972 }
32973
32974 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32975
32976 switch (len) {
32977 case 1:
32978 - __asm__("lcall *(%%esi); cld\n\t"
32979 + __asm__("movw %w6, %%ds\n\t"
32980 + "lcall *%%ss:(%%esi); cld\n\t"
32981 + "push %%ss\n\t"
32982 + "pop %%ds\n\t"
32983 "jc 1f\n\t"
32984 "xor %%ah, %%ah\n"
32985 "1:"
32986 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32987 "c" (value),
32988 "b" (bx),
32989 "D" ((long)reg),
32990 - "S" (&pci_indirect));
32991 + "S" (&pci_indirect),
32992 + "r" (__PCIBIOS_DS));
32993 break;
32994 case 2:
32995 - __asm__("lcall *(%%esi); cld\n\t"
32996 + __asm__("movw %w6, %%ds\n\t"
32997 + "lcall *%%ss:(%%esi); cld\n\t"
32998 + "push %%ss\n\t"
32999 + "pop %%ds\n\t"
33000 "jc 1f\n\t"
33001 "xor %%ah, %%ah\n"
33002 "1:"
33003 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33004 "c" (value),
33005 "b" (bx),
33006 "D" ((long)reg),
33007 - "S" (&pci_indirect));
33008 + "S" (&pci_indirect),
33009 + "r" (__PCIBIOS_DS));
33010 break;
33011 case 4:
33012 - __asm__("lcall *(%%esi); cld\n\t"
33013 + __asm__("movw %w6, %%ds\n\t"
33014 + "lcall *%%ss:(%%esi); cld\n\t"
33015 + "push %%ss\n\t"
33016 + "pop %%ds\n\t"
33017 "jc 1f\n\t"
33018 "xor %%ah, %%ah\n"
33019 "1:"
33020 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33021 "c" (value),
33022 "b" (bx),
33023 "D" ((long)reg),
33024 - "S" (&pci_indirect));
33025 + "S" (&pci_indirect),
33026 + "r" (__PCIBIOS_DS));
33027 break;
33028 }
33029
33030 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33031
33032 DBG("PCI: Fetching IRQ routing table... ");
33033 __asm__("push %%es\n\t"
33034 + "movw %w8, %%ds\n\t"
33035 "push %%ds\n\t"
33036 "pop %%es\n\t"
33037 - "lcall *(%%esi); cld\n\t"
33038 + "lcall *%%ss:(%%esi); cld\n\t"
33039 "pop %%es\n\t"
33040 + "push %%ss\n\t"
33041 + "pop %%ds\n"
33042 "jc 1f\n\t"
33043 "xor %%ah, %%ah\n"
33044 "1:"
33045 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33046 "1" (0),
33047 "D" ((long) &opt),
33048 "S" (&pci_indirect),
33049 - "m" (opt)
33050 + "m" (opt),
33051 + "r" (__PCIBIOS_DS)
33052 : "memory");
33053 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33054 if (ret & 0xff00)
33055 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33056 {
33057 int ret;
33058
33059 - __asm__("lcall *(%%esi); cld\n\t"
33060 + __asm__("movw %w5, %%ds\n\t"
33061 + "lcall *%%ss:(%%esi); cld\n\t"
33062 + "push %%ss\n\t"
33063 + "pop %%ds\n"
33064 "jc 1f\n\t"
33065 "xor %%ah, %%ah\n"
33066 "1:"
33067 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33068 : "0" (PCIBIOS_SET_PCI_HW_INT),
33069 "b" ((dev->bus->number << 8) | dev->devfn),
33070 "c" ((irq << 8) | (pin + 10)),
33071 - "S" (&pci_indirect));
33072 + "S" (&pci_indirect),
33073 + "r" (__PCIBIOS_DS));
33074 return !(ret & 0xff00);
33075 }
33076 EXPORT_SYMBOL(pcibios_set_irq_routing);
33077 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33078 index 40e4469..d915bf9 100644
33079 --- a/arch/x86/platform/efi/efi_32.c
33080 +++ b/arch/x86/platform/efi/efi_32.c
33081 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33082 {
33083 struct desc_ptr gdt_descr;
33084
33085 +#ifdef CONFIG_PAX_KERNEXEC
33086 + struct desc_struct d;
33087 +#endif
33088 +
33089 local_irq_save(efi_rt_eflags);
33090
33091 load_cr3(initial_page_table);
33092 __flush_tlb_all();
33093
33094 +#ifdef CONFIG_PAX_KERNEXEC
33095 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33096 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33097 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33098 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33099 +#endif
33100 +
33101 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33102 gdt_descr.size = GDT_SIZE - 1;
33103 load_gdt(&gdt_descr);
33104 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33105 {
33106 struct desc_ptr gdt_descr;
33107
33108 +#ifdef CONFIG_PAX_KERNEXEC
33109 + struct desc_struct d;
33110 +
33111 + memset(&d, 0, sizeof d);
33112 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33113 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33114 +#endif
33115 +
33116 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33117 gdt_descr.size = GDT_SIZE - 1;
33118 load_gdt(&gdt_descr);
33119
33120 +#ifdef CONFIG_PAX_PER_CPU_PGD
33121 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33122 +#else
33123 load_cr3(swapper_pg_dir);
33124 +#endif
33125 +
33126 __flush_tlb_all();
33127
33128 local_irq_restore(efi_rt_eflags);
33129 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33130 index 39a0e7f1..872396e 100644
33131 --- a/arch/x86/platform/efi/efi_64.c
33132 +++ b/arch/x86/platform/efi/efi_64.c
33133 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33134 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33135 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33136 }
33137 +
33138 +#ifdef CONFIG_PAX_PER_CPU_PGD
33139 + load_cr3(swapper_pg_dir);
33140 +#endif
33141 +
33142 __flush_tlb_all();
33143 }
33144
33145 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33146 for (pgd = 0; pgd < n_pgds; pgd++)
33147 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33148 kfree(save_pgd);
33149 +
33150 +#ifdef CONFIG_PAX_PER_CPU_PGD
33151 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33152 +#endif
33153 +
33154 __flush_tlb_all();
33155 local_irq_restore(efi_flags);
33156 early_code_mapping_set_exec(0);
33157 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33158 index fbe66e6..eae5e38 100644
33159 --- a/arch/x86/platform/efi/efi_stub_32.S
33160 +++ b/arch/x86/platform/efi/efi_stub_32.S
33161 @@ -6,7 +6,9 @@
33162 */
33163
33164 #include <linux/linkage.h>
33165 +#include <linux/init.h>
33166 #include <asm/page_types.h>
33167 +#include <asm/segment.h>
33168
33169 /*
33170 * efi_call_phys(void *, ...) is a function with variable parameters.
33171 @@ -20,7 +22,7 @@
33172 * service functions will comply with gcc calling convention, too.
33173 */
33174
33175 -.text
33176 +__INIT
33177 ENTRY(efi_call_phys)
33178 /*
33179 * 0. The function can only be called in Linux kernel. So CS has been
33180 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33181 * The mapping of lower virtual memory has been created in prelog and
33182 * epilog.
33183 */
33184 - movl $1f, %edx
33185 - subl $__PAGE_OFFSET, %edx
33186 - jmp *%edx
33187 +#ifdef CONFIG_PAX_KERNEXEC
33188 + movl $(__KERNEXEC_EFI_DS), %edx
33189 + mov %edx, %ds
33190 + mov %edx, %es
33191 + mov %edx, %ss
33192 + addl $2f,(1f)
33193 + ljmp *(1f)
33194 +
33195 +__INITDATA
33196 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33197 +.previous
33198 +
33199 +2:
33200 + subl $2b,(1b)
33201 +#else
33202 + jmp 1f-__PAGE_OFFSET
33203 1:
33204 +#endif
33205
33206 /*
33207 * 2. Now on the top of stack is the return
33208 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33209 * parameter 2, ..., param n. To make things easy, we save the return
33210 * address of efi_call_phys in a global variable.
33211 */
33212 - popl %edx
33213 - movl %edx, saved_return_addr
33214 - /* get the function pointer into ECX*/
33215 - popl %ecx
33216 - movl %ecx, efi_rt_function_ptr
33217 - movl $2f, %edx
33218 - subl $__PAGE_OFFSET, %edx
33219 - pushl %edx
33220 + popl (saved_return_addr)
33221 + popl (efi_rt_function_ptr)
33222
33223 /*
33224 * 3. Clear PG bit in %CR0.
33225 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33226 /*
33227 * 5. Call the physical function.
33228 */
33229 - jmp *%ecx
33230 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33231
33232 -2:
33233 /*
33234 * 6. After EFI runtime service returns, control will return to
33235 * following instruction. We'd better readjust stack pointer first.
33236 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33237 movl %cr0, %edx
33238 orl $0x80000000, %edx
33239 movl %edx, %cr0
33240 - jmp 1f
33241 -1:
33242 +
33243 /*
33244 * 8. Now restore the virtual mode from flat mode by
33245 * adding EIP with PAGE_OFFSET.
33246 */
33247 - movl $1f, %edx
33248 - jmp *%edx
33249 +#ifdef CONFIG_PAX_KERNEXEC
33250 + movl $(__KERNEL_DS), %edx
33251 + mov %edx, %ds
33252 + mov %edx, %es
33253 + mov %edx, %ss
33254 + ljmp $(__KERNEL_CS),$1f
33255 +#else
33256 + jmp 1f+__PAGE_OFFSET
33257 +#endif
33258 1:
33259
33260 /*
33261 * 9. Balance the stack. And because EAX contain the return value,
33262 * we'd better not clobber it.
33263 */
33264 - leal efi_rt_function_ptr, %edx
33265 - movl (%edx), %ecx
33266 - pushl %ecx
33267 + pushl (efi_rt_function_ptr)
33268
33269 /*
33270 - * 10. Push the saved return address onto the stack and return.
33271 + * 10. Return to the saved return address.
33272 */
33273 - leal saved_return_addr, %edx
33274 - movl (%edx), %ecx
33275 - pushl %ecx
33276 - ret
33277 + jmpl *(saved_return_addr)
33278 ENDPROC(efi_call_phys)
33279 .previous
33280
33281 -.data
33282 +__INITDATA
33283 saved_return_addr:
33284 .long 0
33285 efi_rt_function_ptr:
33286 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33287 index 4c07cca..2c8427d 100644
33288 --- a/arch/x86/platform/efi/efi_stub_64.S
33289 +++ b/arch/x86/platform/efi/efi_stub_64.S
33290 @@ -7,6 +7,7 @@
33291 */
33292
33293 #include <linux/linkage.h>
33294 +#include <asm/alternative-asm.h>
33295
33296 #define SAVE_XMM \
33297 mov %rsp, %rax; \
33298 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33299 call *%rdi
33300 addq $32, %rsp
33301 RESTORE_XMM
33302 + pax_force_retaddr 0, 1
33303 ret
33304 ENDPROC(efi_call0)
33305
33306 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33307 call *%rdi
33308 addq $32, %rsp
33309 RESTORE_XMM
33310 + pax_force_retaddr 0, 1
33311 ret
33312 ENDPROC(efi_call1)
33313
33314 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33315 call *%rdi
33316 addq $32, %rsp
33317 RESTORE_XMM
33318 + pax_force_retaddr 0, 1
33319 ret
33320 ENDPROC(efi_call2)
33321
33322 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33323 call *%rdi
33324 addq $32, %rsp
33325 RESTORE_XMM
33326 + pax_force_retaddr 0, 1
33327 ret
33328 ENDPROC(efi_call3)
33329
33330 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33331 call *%rdi
33332 addq $32, %rsp
33333 RESTORE_XMM
33334 + pax_force_retaddr 0, 1
33335 ret
33336 ENDPROC(efi_call4)
33337
33338 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33339 call *%rdi
33340 addq $48, %rsp
33341 RESTORE_XMM
33342 + pax_force_retaddr 0, 1
33343 ret
33344 ENDPROC(efi_call5)
33345
33346 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33347 call *%rdi
33348 addq $48, %rsp
33349 RESTORE_XMM
33350 + pax_force_retaddr 0, 1
33351 ret
33352 ENDPROC(efi_call6)
33353 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33354 index 47fe66f..6206449 100644
33355 --- a/arch/x86/platform/mrst/mrst.c
33356 +++ b/arch/x86/platform/mrst/mrst.c
33357 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33358 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33359 int sfi_mrtc_num;
33360
33361 -static void mrst_power_off(void)
33362 +static __noreturn void mrst_power_off(void)
33363 {
33364 + BUG();
33365 }
33366
33367 -static void mrst_reboot(void)
33368 +static __noreturn void mrst_reboot(void)
33369 {
33370 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33371 + BUG();
33372 }
33373
33374 /* parse all the mtimer info to a static mtimer array */
33375 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33376 index d6ee929..3637cb5 100644
33377 --- a/arch/x86/platform/olpc/olpc_dt.c
33378 +++ b/arch/x86/platform/olpc/olpc_dt.c
33379 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33380 return res;
33381 }
33382
33383 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33384 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33385 .nextprop = olpc_dt_nextprop,
33386 .getproplen = olpc_dt_getproplen,
33387 .getproperty = olpc_dt_getproperty,
33388 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33389 index 1cf5b30..fd45732 100644
33390 --- a/arch/x86/power/cpu.c
33391 +++ b/arch/x86/power/cpu.c
33392 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33393 static void fix_processor_context(void)
33394 {
33395 int cpu = smp_processor_id();
33396 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33397 -#ifdef CONFIG_X86_64
33398 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33399 - tss_desc tss;
33400 -#endif
33401 + struct tss_struct *t = init_tss + cpu;
33402 +
33403 set_tss_desc(cpu, t); /*
33404 * This just modifies memory; should not be
33405 * necessary. But... This is necessary, because
33406 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33407 */
33408
33409 #ifdef CONFIG_X86_64
33410 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33411 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33412 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33413 -
33414 syscall_init(); /* This sets MSR_*STAR and related */
33415 #endif
33416 load_TR_desc(); /* This does ltr */
33417 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33418 index a44f457..9140171 100644
33419 --- a/arch/x86/realmode/init.c
33420 +++ b/arch/x86/realmode/init.c
33421 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33422 __va(real_mode_header->trampoline_header);
33423
33424 #ifdef CONFIG_X86_32
33425 - trampoline_header->start = __pa_symbol(startup_32_smp);
33426 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33427 +
33428 +#ifdef CONFIG_PAX_KERNEXEC
33429 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33430 +#endif
33431 +
33432 + trampoline_header->boot_cs = __BOOT_CS;
33433 trampoline_header->gdt_limit = __BOOT_DS + 7;
33434 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33435 #else
33436 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33437 *trampoline_cr4_features = read_cr4();
33438
33439 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33440 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33441 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33442 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33443 #endif
33444 }
33445 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33446 index 8869287..d577672 100644
33447 --- a/arch/x86/realmode/rm/Makefile
33448 +++ b/arch/x86/realmode/rm/Makefile
33449 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33450 $(call cc-option, -fno-unit-at-a-time)) \
33451 $(call cc-option, -fno-stack-protector) \
33452 $(call cc-option, -mpreferred-stack-boundary=2)
33453 +ifdef CONSTIFY_PLUGIN
33454 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33455 +endif
33456 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33457 GCOV_PROFILE := n
33458 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33459 index a28221d..93c40f1 100644
33460 --- a/arch/x86/realmode/rm/header.S
33461 +++ b/arch/x86/realmode/rm/header.S
33462 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33463 #endif
33464 /* APM/BIOS reboot */
33465 .long pa_machine_real_restart_asm
33466 -#ifdef CONFIG_X86_64
33467 +#ifdef CONFIG_X86_32
33468 + .long __KERNEL_CS
33469 +#else
33470 .long __KERNEL32_CS
33471 #endif
33472 END(real_mode_header)
33473 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33474 index c1b2791..f9e31c7 100644
33475 --- a/arch/x86/realmode/rm/trampoline_32.S
33476 +++ b/arch/x86/realmode/rm/trampoline_32.S
33477 @@ -25,6 +25,12 @@
33478 #include <asm/page_types.h>
33479 #include "realmode.h"
33480
33481 +#ifdef CONFIG_PAX_KERNEXEC
33482 +#define ta(X) (X)
33483 +#else
33484 +#define ta(X) (pa_ ## X)
33485 +#endif
33486 +
33487 .text
33488 .code16
33489
33490 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33491
33492 cli # We should be safe anyway
33493
33494 - movl tr_start, %eax # where we need to go
33495 -
33496 movl $0xA5A5A5A5, trampoline_status
33497 # write marker for master knows we're running
33498
33499 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33500 movw $1, %dx # protected mode (PE) bit
33501 lmsw %dx # into protected mode
33502
33503 - ljmpl $__BOOT_CS, $pa_startup_32
33504 + ljmpl *(trampoline_header)
33505
33506 .section ".text32","ax"
33507 .code32
33508 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33509 .balign 8
33510 GLOBAL(trampoline_header)
33511 tr_start: .space 4
33512 - tr_gdt_pad: .space 2
33513 + tr_boot_cs: .space 2
33514 tr_gdt: .space 6
33515 END(trampoline_header)
33516
33517 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33518 index bb360dc..d0fd8f8 100644
33519 --- a/arch/x86/realmode/rm/trampoline_64.S
33520 +++ b/arch/x86/realmode/rm/trampoline_64.S
33521 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33522 movl %edx, %gs
33523
33524 movl pa_tr_cr4, %eax
33525 + andl $~X86_CR4_PCIDE, %eax
33526 movl %eax, %cr4 # Enable PAE mode
33527
33528 # Setup trampoline 4 level pagetables
33529 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33530 wrmsr
33531
33532 # Enable paging and in turn activate Long Mode
33533 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33534 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33535 movl %eax, %cr0
33536
33537 /*
33538 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33539 index e812034..c747134 100644
33540 --- a/arch/x86/tools/Makefile
33541 +++ b/arch/x86/tools/Makefile
33542 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33543
33544 $(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
33545
33546 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33547 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33548 hostprogs-y += relocs
33549 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33550 relocs: $(obj)/relocs
33551 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33552 index f7bab68..b6d9886 100644
33553 --- a/arch/x86/tools/relocs.c
33554 +++ b/arch/x86/tools/relocs.c
33555 @@ -1,5 +1,7 @@
33556 /* This is included from relocs_32/64.c */
33557
33558 +#include "../../../include/generated/autoconf.h"
33559 +
33560 #define ElfW(type) _ElfW(ELF_BITS, type)
33561 #define _ElfW(bits, type) __ElfW(bits, type)
33562 #define __ElfW(bits, type) Elf##bits##_##type
33563 @@ -11,6 +13,7 @@
33564 #define Elf_Sym ElfW(Sym)
33565
33566 static Elf_Ehdr ehdr;
33567 +static Elf_Phdr *phdr;
33568
33569 struct relocs {
33570 uint32_t *offset;
33571 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33572 }
33573 }
33574
33575 +static void read_phdrs(FILE *fp)
33576 +{
33577 + unsigned int i;
33578 +
33579 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33580 + if (!phdr) {
33581 + die("Unable to allocate %d program headers\n",
33582 + ehdr.e_phnum);
33583 + }
33584 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33585 + die("Seek to %d failed: %s\n",
33586 + ehdr.e_phoff, strerror(errno));
33587 + }
33588 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33589 + die("Cannot read ELF program headers: %s\n",
33590 + strerror(errno));
33591 + }
33592 + for(i = 0; i < ehdr.e_phnum; i++) {
33593 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33594 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33595 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33596 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33597 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33598 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33599 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33600 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33601 + }
33602 +
33603 +}
33604 +
33605 static void read_shdrs(FILE *fp)
33606 {
33607 - int i;
33608 + unsigned int i;
33609 Elf_Shdr shdr;
33610
33611 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33612 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33613
33614 static void read_strtabs(FILE *fp)
33615 {
33616 - int i;
33617 + unsigned int i;
33618 for (i = 0; i < ehdr.e_shnum; i++) {
33619 struct section *sec = &secs[i];
33620 if (sec->shdr.sh_type != SHT_STRTAB) {
33621 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33622
33623 static void read_symtabs(FILE *fp)
33624 {
33625 - int i,j;
33626 + unsigned int i,j;
33627 for (i = 0; i < ehdr.e_shnum; i++) {
33628 struct section *sec = &secs[i];
33629 if (sec->shdr.sh_type != SHT_SYMTAB) {
33630 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33631 }
33632
33633
33634 -static void read_relocs(FILE *fp)
33635 +static void read_relocs(FILE *fp, int use_real_mode)
33636 {
33637 - int i,j;
33638 + unsigned int i,j;
33639 + uint32_t base;
33640 +
33641 for (i = 0; i < ehdr.e_shnum; i++) {
33642 struct section *sec = &secs[i];
33643 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33644 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33645 die("Cannot read symbol table: %s\n",
33646 strerror(errno));
33647 }
33648 + base = 0;
33649 +
33650 +#ifdef CONFIG_X86_32
33651 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33652 + if (phdr[j].p_type != PT_LOAD )
33653 + continue;
33654 + 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)
33655 + continue;
33656 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33657 + break;
33658 + }
33659 +#endif
33660 +
33661 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33662 Elf_Rel *rel = &sec->reltab[j];
33663 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33664 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33665 rel->r_info = elf_xword_to_cpu(rel->r_info);
33666 #if (SHT_REL_TYPE == SHT_RELA)
33667 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33668 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33669
33670 static void print_absolute_symbols(void)
33671 {
33672 - int i;
33673 + unsigned int i;
33674 const char *format;
33675
33676 if (ELF_BITS == 64)
33677 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33678 for (i = 0; i < ehdr.e_shnum; i++) {
33679 struct section *sec = &secs[i];
33680 char *sym_strtab;
33681 - int j;
33682 + unsigned int j;
33683
33684 if (sec->shdr.sh_type != SHT_SYMTAB) {
33685 continue;
33686 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33687
33688 static void print_absolute_relocs(void)
33689 {
33690 - int i, printed = 0;
33691 + unsigned int i, printed = 0;
33692 const char *format;
33693
33694 if (ELF_BITS == 64)
33695 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33696 struct section *sec_applies, *sec_symtab;
33697 char *sym_strtab;
33698 Elf_Sym *sh_symtab;
33699 - int j;
33700 + unsigned int j;
33701 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33702 continue;
33703 }
33704 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33705 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33706 Elf_Sym *sym, const char *symname))
33707 {
33708 - int i;
33709 + unsigned int i;
33710 /* Walk through the relocations */
33711 for (i = 0; i < ehdr.e_shnum; i++) {
33712 char *sym_strtab;
33713 Elf_Sym *sh_symtab;
33714 struct section *sec_applies, *sec_symtab;
33715 - int j;
33716 + unsigned int j;
33717 struct section *sec = &secs[i];
33718
33719 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33720 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33721 {
33722 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33723 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33724 + char *sym_strtab = sec->link->link->strtab;
33725 +
33726 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33727 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33728 + return 0;
33729 +
33730 +#ifdef CONFIG_PAX_KERNEXEC
33731 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33732 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33733 + return 0;
33734 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33735 + return 0;
33736 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33737 + return 0;
33738 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33739 + return 0;
33740 +#endif
33741
33742 switch (r_type) {
33743 case R_386_NONE:
33744 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33745
33746 static void emit_relocs(int as_text, int use_real_mode)
33747 {
33748 - int i;
33749 + unsigned int i;
33750 int (*write_reloc)(uint32_t, FILE *) = write32;
33751 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33752 const char *symname);
33753 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33754 {
33755 regex_init(use_real_mode);
33756 read_ehdr(fp);
33757 + read_phdrs(fp);
33758 read_shdrs(fp);
33759 read_strtabs(fp);
33760 read_symtabs(fp);
33761 - read_relocs(fp);
33762 + read_relocs(fp, use_real_mode);
33763 if (ELF_BITS == 64)
33764 percpu_init();
33765 if (show_absolute_syms) {
33766 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33767 index 80ffa5b..a33bd15 100644
33768 --- a/arch/x86/um/tls_32.c
33769 +++ b/arch/x86/um/tls_32.c
33770 @@ -260,7 +260,7 @@ out:
33771 if (unlikely(task == current &&
33772 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33773 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33774 - "without flushed TLS.", current->pid);
33775 + "without flushed TLS.", task_pid_nr(current));
33776 }
33777
33778 return 0;
33779 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33780 index fd14be1..e3c79c0 100644
33781 --- a/arch/x86/vdso/Makefile
33782 +++ b/arch/x86/vdso/Makefile
33783 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33784 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33785 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33786
33787 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33788 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33789 GCOV_PROFILE := n
33790
33791 #
33792 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33793 index d6bfb87..876ee18 100644
33794 --- a/arch/x86/vdso/vdso32-setup.c
33795 +++ b/arch/x86/vdso/vdso32-setup.c
33796 @@ -25,6 +25,7 @@
33797 #include <asm/tlbflush.h>
33798 #include <asm/vdso.h>
33799 #include <asm/proto.h>
33800 +#include <asm/mman.h>
33801
33802 enum {
33803 VDSO_DISABLED = 0,
33804 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33805 void enable_sep_cpu(void)
33806 {
33807 int cpu = get_cpu();
33808 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33809 + struct tss_struct *tss = init_tss + cpu;
33810
33811 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33812 put_cpu();
33813 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33814 gate_vma.vm_start = FIXADDR_USER_START;
33815 gate_vma.vm_end = FIXADDR_USER_END;
33816 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33817 - gate_vma.vm_page_prot = __P101;
33818 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33819
33820 return 0;
33821 }
33822 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33823 if (compat)
33824 addr = VDSO_HIGH_BASE;
33825 else {
33826 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33827 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33828 if (IS_ERR_VALUE(addr)) {
33829 ret = addr;
33830 goto up_fail;
33831 }
33832 }
33833
33834 - current->mm->context.vdso = (void *)addr;
33835 + current->mm->context.vdso = addr;
33836
33837 if (compat_uses_vma || !compat) {
33838 /*
33839 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33840 }
33841
33842 current_thread_info()->sysenter_return =
33843 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33844 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33845
33846 up_fail:
33847 if (ret)
33848 - current->mm->context.vdso = NULL;
33849 + current->mm->context.vdso = 0;
33850
33851 up_write(&mm->mmap_sem);
33852
33853 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33854
33855 const char *arch_vma_name(struct vm_area_struct *vma)
33856 {
33857 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33858 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33859 return "[vdso]";
33860 +
33861 +#ifdef CONFIG_PAX_SEGMEXEC
33862 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33863 + return "[vdso]";
33864 +#endif
33865 +
33866 return NULL;
33867 }
33868
33869 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33870 * Check to see if the corresponding task was created in compat vdso
33871 * mode.
33872 */
33873 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33874 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33875 return &gate_vma;
33876 return NULL;
33877 }
33878 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33879 index 431e875..cbb23f3 100644
33880 --- a/arch/x86/vdso/vma.c
33881 +++ b/arch/x86/vdso/vma.c
33882 @@ -16,8 +16,6 @@
33883 #include <asm/vdso.h>
33884 #include <asm/page.h>
33885
33886 -unsigned int __read_mostly vdso_enabled = 1;
33887 -
33888 extern char vdso_start[], vdso_end[];
33889 extern unsigned short vdso_sync_cpuid;
33890
33891 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33892 * unaligned here as a result of stack start randomization.
33893 */
33894 addr = PAGE_ALIGN(addr);
33895 - addr = align_vdso_addr(addr);
33896
33897 return addr;
33898 }
33899 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33900 unsigned size)
33901 {
33902 struct mm_struct *mm = current->mm;
33903 - unsigned long addr;
33904 + unsigned long addr = 0;
33905 int ret;
33906
33907 - if (!vdso_enabled)
33908 - return 0;
33909 -
33910 down_write(&mm->mmap_sem);
33911 +
33912 +#ifdef CONFIG_PAX_RANDMMAP
33913 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33914 +#endif
33915 +
33916 addr = vdso_addr(mm->start_stack, size);
33917 + addr = align_vdso_addr(addr);
33918 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33919 if (IS_ERR_VALUE(addr)) {
33920 ret = addr;
33921 goto up_fail;
33922 }
33923
33924 - current->mm->context.vdso = (void *)addr;
33925 + mm->context.vdso = addr;
33926
33927 ret = install_special_mapping(mm, addr, size,
33928 VM_READ|VM_EXEC|
33929 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33930 pages);
33931 - if (ret) {
33932 - current->mm->context.vdso = NULL;
33933 - goto up_fail;
33934 - }
33935 + if (ret)
33936 + mm->context.vdso = 0;
33937
33938 up_fail:
33939 up_write(&mm->mmap_sem);
33940 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33941 vdsox32_size);
33942 }
33943 #endif
33944 -
33945 -static __init int vdso_setup(char *s)
33946 -{
33947 - vdso_enabled = simple_strtoul(s, NULL, 0);
33948 - return 0;
33949 -}
33950 -__setup("vdso=", vdso_setup);
33951 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33952 index 193097e..7590269 100644
33953 --- a/arch/x86/xen/enlighten.c
33954 +++ b/arch/x86/xen/enlighten.c
33955 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33956
33957 struct shared_info xen_dummy_shared_info;
33958
33959 -void *xen_initial_gdt;
33960 -
33961 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33962 __read_mostly int xen_have_vector_callback;
33963 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33964 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33965 {
33966 unsigned long va = dtr->address;
33967 unsigned int size = dtr->size + 1;
33968 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33969 - unsigned long frames[pages];
33970 + unsigned long frames[65536 / PAGE_SIZE];
33971 int f;
33972
33973 /*
33974 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33975 {
33976 unsigned long va = dtr->address;
33977 unsigned int size = dtr->size + 1;
33978 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33979 - unsigned long frames[pages];
33980 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33981 int f;
33982
33983 /*
33984 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33985 * 8-byte entries, or 16 4k pages..
33986 */
33987
33988 - BUG_ON(size > 65536);
33989 + BUG_ON(size > GDT_SIZE);
33990 BUG_ON(va & ~PAGE_MASK);
33991
33992 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33993 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33994 return 0;
33995 }
33996
33997 -static void set_xen_basic_apic_ops(void)
33998 +static void __init set_xen_basic_apic_ops(void)
33999 {
34000 apic->read = xen_apic_read;
34001 apic->write = xen_apic_write;
34002 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34003 #endif
34004 };
34005
34006 -static void xen_reboot(int reason)
34007 +static __noreturn void xen_reboot(int reason)
34008 {
34009 struct sched_shutdown r = { .reason = reason };
34010
34011 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34012 - BUG();
34013 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34014 + BUG();
34015 }
34016
34017 -static void xen_restart(char *msg)
34018 +static __noreturn void xen_restart(char *msg)
34019 {
34020 xen_reboot(SHUTDOWN_reboot);
34021 }
34022
34023 -static void xen_emergency_restart(void)
34024 +static __noreturn void xen_emergency_restart(void)
34025 {
34026 xen_reboot(SHUTDOWN_reboot);
34027 }
34028
34029 -static void xen_machine_halt(void)
34030 +static __noreturn void xen_machine_halt(void)
34031 {
34032 xen_reboot(SHUTDOWN_poweroff);
34033 }
34034
34035 -static void xen_machine_power_off(void)
34036 +static __noreturn void xen_machine_power_off(void)
34037 {
34038 if (pm_power_off)
34039 pm_power_off();
34040 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34041 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34042
34043 /* Work out if we support NX */
34044 - x86_configure_nx();
34045 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34046 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34047 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34048 + unsigned l, h;
34049 +
34050 + __supported_pte_mask |= _PAGE_NX;
34051 + rdmsr(MSR_EFER, l, h);
34052 + l |= EFER_NX;
34053 + wrmsr(MSR_EFER, l, h);
34054 + }
34055 +#endif
34056
34057 xen_setup_features();
34058
34059 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34060
34061 machine_ops = xen_machine_ops;
34062
34063 - /*
34064 - * The only reliable way to retain the initial address of the
34065 - * percpu gdt_page is to remember it here, so we can go and
34066 - * mark it RW later, when the initial percpu area is freed.
34067 - */
34068 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34069 -
34070 xen_smp_init();
34071
34072 #ifdef CONFIG_ACPI_NUMA
34073 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34074 index fdc3ba2..3daee39 100644
34075 --- a/arch/x86/xen/mmu.c
34076 +++ b/arch/x86/xen/mmu.c
34077 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34078 /* L3_k[510] -> level2_kernel_pgt
34079 * L3_i[511] -> level2_fixmap_pgt */
34080 convert_pfn_mfn(level3_kernel_pgt);
34081 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34082 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34083 + convert_pfn_mfn(level3_vmemmap_pgt);
34084
34085 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34086 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34087 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34088 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34089 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34090 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34091 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34092 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34093 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34094 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34095 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34096 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34097 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34098 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34099
34100 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34101 pv_mmu_ops.set_pud = xen_set_pud;
34102 #if PAGETABLE_LEVELS == 4
34103 pv_mmu_ops.set_pgd = xen_set_pgd;
34104 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34105 #endif
34106
34107 /* This will work as long as patching hasn't happened yet
34108 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34109 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34110 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34111 .set_pgd = xen_set_pgd_hyper,
34112 + .set_pgd_batched = xen_set_pgd_hyper,
34113
34114 .alloc_pud = xen_alloc_pmd_init,
34115 .release_pud = xen_release_pmd_init,
34116 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34117 index b81c88e..2cbe7b8 100644
34118 --- a/arch/x86/xen/smp.c
34119 +++ b/arch/x86/xen/smp.c
34120 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34121 {
34122 BUG_ON(smp_processor_id() != 0);
34123 native_smp_prepare_boot_cpu();
34124 -
34125 - /* We've switched to the "real" per-cpu gdt, so make sure the
34126 - old memory can be recycled */
34127 - make_lowmem_page_readwrite(xen_initial_gdt);
34128 -
34129 xen_filter_cpu_maps();
34130 xen_setup_vcpu_info_placement();
34131 }
34132 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34133 ctxt->user_regs.ss = __KERNEL_DS;
34134 #ifdef CONFIG_X86_32
34135 ctxt->user_regs.fs = __KERNEL_PERCPU;
34136 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34137 + savesegment(gs, ctxt->user_regs.gs);
34138 #else
34139 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34140 #endif
34141 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34142
34143 {
34144 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34145 - ctxt->user_regs.ds = __USER_DS;
34146 - ctxt->user_regs.es = __USER_DS;
34147 + ctxt->user_regs.ds = __KERNEL_DS;
34148 + ctxt->user_regs.es = __KERNEL_DS;
34149
34150 xen_copy_trap_info(ctxt->trap_ctxt);
34151
34152 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34153 int rc;
34154
34155 per_cpu(current_task, cpu) = idle;
34156 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34157 #ifdef CONFIG_X86_32
34158 irq_ctx_init(cpu);
34159 #else
34160 clear_tsk_thread_flag(idle, TIF_FORK);
34161 - per_cpu(kernel_stack, cpu) =
34162 - (unsigned long)task_stack_page(idle) -
34163 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34164 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34165 #endif
34166 xen_setup_runstate_info(cpu);
34167 xen_setup_timer(cpu);
34168 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34169
34170 void __init xen_smp_init(void)
34171 {
34172 - smp_ops = xen_smp_ops;
34173 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34174 xen_fill_possible_map();
34175 xen_init_spinlocks();
34176 }
34177 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34178 index 33ca6e4..0ded929 100644
34179 --- a/arch/x86/xen/xen-asm_32.S
34180 +++ b/arch/x86/xen/xen-asm_32.S
34181 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34182 ESP_OFFSET=4 # bytes pushed onto stack
34183
34184 /*
34185 - * Store vcpu_info pointer for easy access. Do it this way to
34186 - * avoid having to reload %fs
34187 + * Store vcpu_info pointer for easy access.
34188 */
34189 #ifdef CONFIG_SMP
34190 - GET_THREAD_INFO(%eax)
34191 - movl %ss:TI_cpu(%eax), %eax
34192 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34193 - mov %ss:xen_vcpu(%eax), %eax
34194 + push %fs
34195 + mov $(__KERNEL_PERCPU), %eax
34196 + mov %eax, %fs
34197 + mov PER_CPU_VAR(xen_vcpu), %eax
34198 + pop %fs
34199 #else
34200 movl %ss:xen_vcpu, %eax
34201 #endif
34202 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34203 index 7faed58..ba4427c 100644
34204 --- a/arch/x86/xen/xen-head.S
34205 +++ b/arch/x86/xen/xen-head.S
34206 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34207 #ifdef CONFIG_X86_32
34208 mov %esi,xen_start_info
34209 mov $init_thread_union+THREAD_SIZE,%esp
34210 +#ifdef CONFIG_SMP
34211 + movl $cpu_gdt_table,%edi
34212 + movl $__per_cpu_load,%eax
34213 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34214 + rorl $16,%eax
34215 + movb %al,__KERNEL_PERCPU + 4(%edi)
34216 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34217 + movl $__per_cpu_end - 1,%eax
34218 + subl $__per_cpu_start,%eax
34219 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34220 +#endif
34221 #else
34222 mov %rsi,xen_start_info
34223 mov $init_thread_union+THREAD_SIZE,%rsp
34224 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34225 index 86782c5..fa272c8 100644
34226 --- a/arch/x86/xen/xen-ops.h
34227 +++ b/arch/x86/xen/xen-ops.h
34228 @@ -10,8 +10,6 @@
34229 extern const char xen_hypervisor_callback[];
34230 extern const char xen_failsafe_callback[];
34231
34232 -extern void *xen_initial_gdt;
34233 -
34234 struct trap_info;
34235 void xen_copy_trap_info(struct trap_info *traps);
34236
34237 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34238 index 525bd3d..ef888b1 100644
34239 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34240 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34241 @@ -119,9 +119,9 @@
34242 ----------------------------------------------------------------------*/
34243
34244 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34245 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34246 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34247 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34248 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34249
34250 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34251 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34252 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34253 index 2f33760..835e50a 100644
34254 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34255 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34256 @@ -11,6 +11,7 @@
34257 #ifndef _XTENSA_CORE_H
34258 #define _XTENSA_CORE_H
34259
34260 +#include <linux/const.h>
34261
34262 /****************************************************************************
34263 Parameters Useful for Any Code, USER or PRIVILEGED
34264 @@ -112,9 +113,9 @@
34265 ----------------------------------------------------------------------*/
34266
34267 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34268 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34269 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34270 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34271 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34272
34273 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34274 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34275 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34276 index af00795..2bb8105 100644
34277 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34278 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34279 @@ -11,6 +11,7 @@
34280 #ifndef _XTENSA_CORE_CONFIGURATION_H
34281 #define _XTENSA_CORE_CONFIGURATION_H
34282
34283 +#include <linux/const.h>
34284
34285 /****************************************************************************
34286 Parameters Useful for Any Code, USER or PRIVILEGED
34287 @@ -118,9 +119,9 @@
34288 ----------------------------------------------------------------------*/
34289
34290 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34291 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34292 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34293 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34294 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34295
34296 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34297 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34298 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34299 index 290792a..416f287 100644
34300 --- a/block/blk-cgroup.c
34301 +++ b/block/blk-cgroup.c
34302 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34303
34304 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34305 {
34306 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34307 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34308 struct blkcg *blkcg;
34309 struct cgroup *parent = cgroup->parent;
34310
34311 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34312
34313 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34314 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34315 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34316 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34317 done:
34318 spin_lock_init(&blkcg->lock);
34319 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34320 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34321 index 4b8d9b54..a7178c0 100644
34322 --- a/block/blk-iopoll.c
34323 +++ b/block/blk-iopoll.c
34324 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34325 }
34326 EXPORT_SYMBOL(blk_iopoll_complete);
34327
34328 -static void blk_iopoll_softirq(struct softirq_action *h)
34329 +static __latent_entropy void blk_iopoll_softirq(void)
34330 {
34331 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34332 int rearm = 0, budget = blk_iopoll_budget;
34333 diff --git a/block/blk-map.c b/block/blk-map.c
34334 index 623e1cd..ca1e109 100644
34335 --- a/block/blk-map.c
34336 +++ b/block/blk-map.c
34337 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34338 if (!len || !kbuf)
34339 return -EINVAL;
34340
34341 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34342 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34343 if (do_copy)
34344 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34345 else
34346 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34347 index ec9e606..3f38839 100644
34348 --- a/block/blk-softirq.c
34349 +++ b/block/blk-softirq.c
34350 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34351 * Softirq action handler - move entries to local list and loop over them
34352 * while passing them to the queue registered handler.
34353 */
34354 -static void blk_done_softirq(struct softirq_action *h)
34355 +static __latent_entropy void blk_done_softirq(void)
34356 {
34357 struct list_head *cpu_list, local_list;
34358
34359 diff --git a/block/bsg.c b/block/bsg.c
34360 index 420a5a9..23834aa 100644
34361 --- a/block/bsg.c
34362 +++ b/block/bsg.c
34363 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34364 struct sg_io_v4 *hdr, struct bsg_device *bd,
34365 fmode_t has_write_perm)
34366 {
34367 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34368 + unsigned char *cmdptr;
34369 +
34370 if (hdr->request_len > BLK_MAX_CDB) {
34371 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34372 if (!rq->cmd)
34373 return -ENOMEM;
34374 - }
34375 + cmdptr = rq->cmd;
34376 + } else
34377 + cmdptr = tmpcmd;
34378
34379 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34380 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34381 hdr->request_len))
34382 return -EFAULT;
34383
34384 + if (cmdptr != rq->cmd)
34385 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34386 +
34387 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34388 if (blk_verify_command(rq->cmd, has_write_perm))
34389 return -EPERM;
34390 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34391 index 7e5d474..0cf0017 100644
34392 --- a/block/compat_ioctl.c
34393 +++ b/block/compat_ioctl.c
34394 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34395 err |= __get_user(f->spec1, &uf->spec1);
34396 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34397 err |= __get_user(name, &uf->name);
34398 - f->name = compat_ptr(name);
34399 + f->name = (void __force_kernel *)compat_ptr(name);
34400 if (err) {
34401 err = -EFAULT;
34402 goto out;
34403 diff --git a/block/genhd.c b/block/genhd.c
34404 index dadf42b..48dc887 100644
34405 --- a/block/genhd.c
34406 +++ b/block/genhd.c
34407 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34408
34409 /*
34410 * Register device numbers dev..(dev+range-1)
34411 - * range must be nonzero
34412 + * Noop if @range is zero.
34413 * The hash chain is sorted on range, so that subranges can override.
34414 */
34415 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34416 struct kobject *(*probe)(dev_t, int *, void *),
34417 int (*lock)(dev_t, void *), void *data)
34418 {
34419 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34420 + if (range)
34421 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34422 }
34423
34424 EXPORT_SYMBOL(blk_register_region);
34425
34426 +/* undo blk_register_region(), noop if @range is zero */
34427 void blk_unregister_region(dev_t devt, unsigned long range)
34428 {
34429 - kobj_unmap(bdev_map, devt, range);
34430 + if (range)
34431 + kobj_unmap(bdev_map, devt, range);
34432 }
34433
34434 EXPORT_SYMBOL(blk_unregister_region);
34435 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34436 index c85fc89..51e690b 100644
34437 --- a/block/partitions/efi.c
34438 +++ b/block/partitions/efi.c
34439 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34440 if (!gpt)
34441 return NULL;
34442
34443 + if (!le32_to_cpu(gpt->num_partition_entries))
34444 + return NULL;
34445 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34446 + if (!pte)
34447 + return NULL;
34448 +
34449 count = le32_to_cpu(gpt->num_partition_entries) *
34450 le32_to_cpu(gpt->sizeof_partition_entry);
34451 - if (!count)
34452 - return NULL;
34453 - pte = kmalloc(count, GFP_KERNEL);
34454 - if (!pte)
34455 - return NULL;
34456 -
34457 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34458 (u8 *) pte,
34459 count) < count) {
34460 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34461 index a5ffcc9..3cedc9c 100644
34462 --- a/block/scsi_ioctl.c
34463 +++ b/block/scsi_ioctl.c
34464 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34465 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34466 struct sg_io_hdr *hdr, fmode_t mode)
34467 {
34468 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34469 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34470 + unsigned char *cmdptr;
34471 +
34472 + if (rq->cmd != rq->__cmd)
34473 + cmdptr = rq->cmd;
34474 + else
34475 + cmdptr = tmpcmd;
34476 +
34477 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34478 return -EFAULT;
34479 +
34480 + if (cmdptr != rq->cmd)
34481 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34482 +
34483 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34484 return -EPERM;
34485
34486 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34487 int err;
34488 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34489 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34490 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34491 + unsigned char *cmdptr;
34492
34493 if (!sic)
34494 return -EINVAL;
34495 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34496 */
34497 err = -EFAULT;
34498 rq->cmd_len = cmdlen;
34499 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34500 +
34501 + if (rq->cmd != rq->__cmd)
34502 + cmdptr = rq->cmd;
34503 + else
34504 + cmdptr = tmpcmd;
34505 +
34506 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34507 goto error;
34508
34509 + if (rq->cmd != cmdptr)
34510 + memcpy(rq->cmd, cmdptr, cmdlen);
34511 +
34512 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34513 goto error;
34514
34515 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34516 index 7bdd61b..afec999 100644
34517 --- a/crypto/cryptd.c
34518 +++ b/crypto/cryptd.c
34519 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34520
34521 struct cryptd_blkcipher_request_ctx {
34522 crypto_completion_t complete;
34523 -};
34524 +} __no_const;
34525
34526 struct cryptd_hash_ctx {
34527 struct crypto_shash *child;
34528 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34529
34530 struct cryptd_aead_request_ctx {
34531 crypto_completion_t complete;
34532 -};
34533 +} __no_const;
34534
34535 static void cryptd_queue_worker(struct work_struct *work);
34536
34537 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34538 index f8c920c..ab2cb5a 100644
34539 --- a/crypto/pcrypt.c
34540 +++ b/crypto/pcrypt.c
34541 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34542 int ret;
34543
34544 pinst->kobj.kset = pcrypt_kset;
34545 - ret = kobject_add(&pinst->kobj, NULL, name);
34546 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34547 if (!ret)
34548 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34549
34550 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34551 index f220d64..d359ad6 100644
34552 --- a/drivers/acpi/apei/apei-internal.h
34553 +++ b/drivers/acpi/apei/apei-internal.h
34554 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34555 struct apei_exec_ins_type {
34556 u32 flags;
34557 apei_exec_ins_func_t run;
34558 -};
34559 +} __do_const;
34560
34561 struct apei_exec_context {
34562 u32 ip;
34563 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34564 index 33dc6a0..4b24b47 100644
34565 --- a/drivers/acpi/apei/cper.c
34566 +++ b/drivers/acpi/apei/cper.c
34567 @@ -39,12 +39,12 @@
34568 */
34569 u64 cper_next_record_id(void)
34570 {
34571 - static atomic64_t seq;
34572 + static atomic64_unchecked_t seq;
34573
34574 - if (!atomic64_read(&seq))
34575 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34576 + if (!atomic64_read_unchecked(&seq))
34577 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34578
34579 - return atomic64_inc_return(&seq);
34580 + return atomic64_inc_return_unchecked(&seq);
34581 }
34582 EXPORT_SYMBOL_GPL(cper_next_record_id);
34583
34584 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34585 index ec9b57d..9682b3a 100644
34586 --- a/drivers/acpi/apei/ghes.c
34587 +++ b/drivers/acpi/apei/ghes.c
34588 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34589 const struct acpi_hest_generic *generic,
34590 const struct acpi_hest_generic_status *estatus)
34591 {
34592 - static atomic_t seqno;
34593 + static atomic_unchecked_t seqno;
34594 unsigned int curr_seqno;
34595 char pfx_seq[64];
34596
34597 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34598 else
34599 pfx = KERN_ERR;
34600 }
34601 - curr_seqno = atomic_inc_return(&seqno);
34602 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34603 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34604 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34605 pfx_seq, generic->header.source_id);
34606 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34607 index be60399..778b33e8 100644
34608 --- a/drivers/acpi/bgrt.c
34609 +++ b/drivers/acpi/bgrt.c
34610 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34611 return -ENODEV;
34612
34613 sysfs_bin_attr_init(&image_attr);
34614 - image_attr.private = bgrt_image;
34615 - image_attr.size = bgrt_image_size;
34616 + pax_open_kernel();
34617 + *(void **)&image_attr.private = bgrt_image;
34618 + *(size_t *)&image_attr.size = bgrt_image_size;
34619 + pax_close_kernel();
34620
34621 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34622 if (!bgrt_kobj)
34623 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34624 index cb96296..b81293b 100644
34625 --- a/drivers/acpi/blacklist.c
34626 +++ b/drivers/acpi/blacklist.c
34627 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34628 u32 is_critical_error;
34629 };
34630
34631 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34632 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34633
34634 /*
34635 * POLICY: If *anything* doesn't work, put it on the blacklist.
34636 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34637 return 0;
34638 }
34639
34640 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34641 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34642 {
34643 .callback = dmi_disable_osi_vista,
34644 .ident = "Fujitsu Siemens",
34645 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34646 index f98dd00..7b69865 100644
34647 --- a/drivers/acpi/processor_idle.c
34648 +++ b/drivers/acpi/processor_idle.c
34649 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34650 {
34651 int i, count = CPUIDLE_DRIVER_STATE_START;
34652 struct acpi_processor_cx *cx;
34653 - struct cpuidle_state *state;
34654 + cpuidle_state_no_const *state;
34655 struct cpuidle_driver *drv = &acpi_idle_driver;
34656
34657 if (!pr->flags.power_setup_done)
34658 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34659 index 05306a5..733d1f0 100644
34660 --- a/drivers/acpi/sysfs.c
34661 +++ b/drivers/acpi/sysfs.c
34662 @@ -423,11 +423,11 @@ static u32 num_counters;
34663 static struct attribute **all_attrs;
34664 static u32 acpi_gpe_count;
34665
34666 -static struct attribute_group interrupt_stats_attr_group = {
34667 +static attribute_group_no_const interrupt_stats_attr_group = {
34668 .name = "interrupts",
34669 };
34670
34671 -static struct kobj_attribute *counter_attrs;
34672 +static kobj_attribute_no_const *counter_attrs;
34673
34674 static void delete_gpe_attr_array(void)
34675 {
34676 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34677 index acfd0f7..e5acb08 100644
34678 --- a/drivers/ata/libahci.c
34679 +++ b/drivers/ata/libahci.c
34680 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34681 }
34682 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34683
34684 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34685 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34686 struct ata_taskfile *tf, int is_cmd, u16 flags,
34687 unsigned long timeout_msec)
34688 {
34689 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34690 index c24354d..335c975 100644
34691 --- a/drivers/ata/libata-core.c
34692 +++ b/drivers/ata/libata-core.c
34693 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34694 static void ata_dev_xfermask(struct ata_device *dev);
34695 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34696
34697 -atomic_t ata_print_id = ATOMIC_INIT(0);
34698 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34699
34700 struct ata_force_param {
34701 const char *name;
34702 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34703 struct ata_port *ap;
34704 unsigned int tag;
34705
34706 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34707 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34708 ap = qc->ap;
34709
34710 qc->flags = 0;
34711 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34712 struct ata_port *ap;
34713 struct ata_link *link;
34714
34715 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34716 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34717 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34718 ap = qc->ap;
34719 link = qc->dev->link;
34720 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34721 return;
34722
34723 spin_lock(&lock);
34724 + pax_open_kernel();
34725
34726 for (cur = ops->inherits; cur; cur = cur->inherits) {
34727 void **inherit = (void **)cur;
34728 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34729 if (IS_ERR(*pp))
34730 *pp = NULL;
34731
34732 - ops->inherits = NULL;
34733 + *(struct ata_port_operations **)&ops->inherits = NULL;
34734
34735 + pax_close_kernel();
34736 spin_unlock(&lock);
34737 }
34738
34739 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34740
34741 /* give ports names and add SCSI hosts */
34742 for (i = 0; i < host->n_ports; i++) {
34743 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34744 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34745 host->ports[i]->local_port_no = i + 1;
34746 }
34747
34748 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34749 index b1e880a..8cf82e1 100644
34750 --- a/drivers/ata/libata-scsi.c
34751 +++ b/drivers/ata/libata-scsi.c
34752 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34753
34754 if (rc)
34755 return rc;
34756 - ap->print_id = atomic_inc_return(&ata_print_id);
34757 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34758 return 0;
34759 }
34760 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34761 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34762 index 577d902b..cb4781e 100644
34763 --- a/drivers/ata/libata.h
34764 +++ b/drivers/ata/libata.h
34765 @@ -53,7 +53,7 @@ enum {
34766 ATA_DNXFER_QUIET = (1 << 31),
34767 };
34768
34769 -extern atomic_t ata_print_id;
34770 +extern atomic_unchecked_t ata_print_id;
34771 extern int atapi_passthru16;
34772 extern int libata_fua;
34773 extern int libata_noacpi;
34774 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34775 index 848ed32..132f39d 100644
34776 --- a/drivers/ata/pata_arasan_cf.c
34777 +++ b/drivers/ata/pata_arasan_cf.c
34778 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34779 /* Handle platform specific quirks */
34780 if (quirk) {
34781 if (quirk & CF_BROKEN_PIO) {
34782 - ap->ops->set_piomode = NULL;
34783 + pax_open_kernel();
34784 + *(void **)&ap->ops->set_piomode = NULL;
34785 + pax_close_kernel();
34786 ap->pio_mask = 0;
34787 }
34788 if (quirk & CF_BROKEN_MWDMA)
34789 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34790 index f9b983a..887b9d8 100644
34791 --- a/drivers/atm/adummy.c
34792 +++ b/drivers/atm/adummy.c
34793 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34794 vcc->pop(vcc, skb);
34795 else
34796 dev_kfree_skb_any(skb);
34797 - atomic_inc(&vcc->stats->tx);
34798 + atomic_inc_unchecked(&vcc->stats->tx);
34799
34800 return 0;
34801 }
34802 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34803 index 62a7607..cc4be104 100644
34804 --- a/drivers/atm/ambassador.c
34805 +++ b/drivers/atm/ambassador.c
34806 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34807 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34808
34809 // VC layer stats
34810 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34811 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34812
34813 // free the descriptor
34814 kfree (tx_descr);
34815 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34816 dump_skb ("<<<", vc, skb);
34817
34818 // VC layer stats
34819 - atomic_inc(&atm_vcc->stats->rx);
34820 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34821 __net_timestamp(skb);
34822 // end of our responsibility
34823 atm_vcc->push (atm_vcc, skb);
34824 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34825 } else {
34826 PRINTK (KERN_INFO, "dropped over-size frame");
34827 // should we count this?
34828 - atomic_inc(&atm_vcc->stats->rx_drop);
34829 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34830 }
34831
34832 } else {
34833 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34834 }
34835
34836 if (check_area (skb->data, skb->len)) {
34837 - atomic_inc(&atm_vcc->stats->tx_err);
34838 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34839 return -ENOMEM; // ?
34840 }
34841
34842 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34843 index 0e3f8f9..765a7a5 100644
34844 --- a/drivers/atm/atmtcp.c
34845 +++ b/drivers/atm/atmtcp.c
34846 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34847 if (vcc->pop) vcc->pop(vcc,skb);
34848 else dev_kfree_skb(skb);
34849 if (dev_data) return 0;
34850 - atomic_inc(&vcc->stats->tx_err);
34851 + atomic_inc_unchecked(&vcc->stats->tx_err);
34852 return -ENOLINK;
34853 }
34854 size = skb->len+sizeof(struct atmtcp_hdr);
34855 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34856 if (!new_skb) {
34857 if (vcc->pop) vcc->pop(vcc,skb);
34858 else dev_kfree_skb(skb);
34859 - atomic_inc(&vcc->stats->tx_err);
34860 + atomic_inc_unchecked(&vcc->stats->tx_err);
34861 return -ENOBUFS;
34862 }
34863 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34864 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34865 if (vcc->pop) vcc->pop(vcc,skb);
34866 else dev_kfree_skb(skb);
34867 out_vcc->push(out_vcc,new_skb);
34868 - atomic_inc(&vcc->stats->tx);
34869 - atomic_inc(&out_vcc->stats->rx);
34870 + atomic_inc_unchecked(&vcc->stats->tx);
34871 + atomic_inc_unchecked(&out_vcc->stats->rx);
34872 return 0;
34873 }
34874
34875 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34876 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34877 read_unlock(&vcc_sklist_lock);
34878 if (!out_vcc) {
34879 - atomic_inc(&vcc->stats->tx_err);
34880 + atomic_inc_unchecked(&vcc->stats->tx_err);
34881 goto done;
34882 }
34883 skb_pull(skb,sizeof(struct atmtcp_hdr));
34884 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34885 __net_timestamp(new_skb);
34886 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34887 out_vcc->push(out_vcc,new_skb);
34888 - atomic_inc(&vcc->stats->tx);
34889 - atomic_inc(&out_vcc->stats->rx);
34890 + atomic_inc_unchecked(&vcc->stats->tx);
34891 + atomic_inc_unchecked(&out_vcc->stats->rx);
34892 done:
34893 if (vcc->pop) vcc->pop(vcc,skb);
34894 else dev_kfree_skb(skb);
34895 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34896 index b1955ba..b179940 100644
34897 --- a/drivers/atm/eni.c
34898 +++ b/drivers/atm/eni.c
34899 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34900 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34901 vcc->dev->number);
34902 length = 0;
34903 - atomic_inc(&vcc->stats->rx_err);
34904 + atomic_inc_unchecked(&vcc->stats->rx_err);
34905 }
34906 else {
34907 length = ATM_CELL_SIZE-1; /* no HEC */
34908 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34909 size);
34910 }
34911 eff = length = 0;
34912 - atomic_inc(&vcc->stats->rx_err);
34913 + atomic_inc_unchecked(&vcc->stats->rx_err);
34914 }
34915 else {
34916 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34917 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34918 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34919 vcc->dev->number,vcc->vci,length,size << 2,descr);
34920 length = eff = 0;
34921 - atomic_inc(&vcc->stats->rx_err);
34922 + atomic_inc_unchecked(&vcc->stats->rx_err);
34923 }
34924 }
34925 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34926 @@ -767,7 +767,7 @@ rx_dequeued++;
34927 vcc->push(vcc,skb);
34928 pushed++;
34929 }
34930 - atomic_inc(&vcc->stats->rx);
34931 + atomic_inc_unchecked(&vcc->stats->rx);
34932 }
34933 wake_up(&eni_dev->rx_wait);
34934 }
34935 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34936 PCI_DMA_TODEVICE);
34937 if (vcc->pop) vcc->pop(vcc,skb);
34938 else dev_kfree_skb_irq(skb);
34939 - atomic_inc(&vcc->stats->tx);
34940 + atomic_inc_unchecked(&vcc->stats->tx);
34941 wake_up(&eni_dev->tx_wait);
34942 dma_complete++;
34943 }
34944 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34945 index b41c948..a002b17 100644
34946 --- a/drivers/atm/firestream.c
34947 +++ b/drivers/atm/firestream.c
34948 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34949 }
34950 }
34951
34952 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34953 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34954
34955 fs_dprintk (FS_DEBUG_TXMEM, "i");
34956 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34957 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34958 #endif
34959 skb_put (skb, qe->p1 & 0xffff);
34960 ATM_SKB(skb)->vcc = atm_vcc;
34961 - atomic_inc(&atm_vcc->stats->rx);
34962 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34963 __net_timestamp(skb);
34964 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34965 atm_vcc->push (atm_vcc, skb);
34966 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34967 kfree (pe);
34968 }
34969 if (atm_vcc)
34970 - atomic_inc(&atm_vcc->stats->rx_drop);
34971 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34972 break;
34973 case 0x1f: /* Reassembly abort: no buffers. */
34974 /* Silently increment error counter. */
34975 if (atm_vcc)
34976 - atomic_inc(&atm_vcc->stats->rx_drop);
34977 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34978 break;
34979 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34980 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34981 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34982 index 204814e..cede831 100644
34983 --- a/drivers/atm/fore200e.c
34984 +++ b/drivers/atm/fore200e.c
34985 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34986 #endif
34987 /* check error condition */
34988 if (*entry->status & STATUS_ERROR)
34989 - atomic_inc(&vcc->stats->tx_err);
34990 + atomic_inc_unchecked(&vcc->stats->tx_err);
34991 else
34992 - atomic_inc(&vcc->stats->tx);
34993 + atomic_inc_unchecked(&vcc->stats->tx);
34994 }
34995 }
34996
34997 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34998 if (skb == NULL) {
34999 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35000
35001 - atomic_inc(&vcc->stats->rx_drop);
35002 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35003 return -ENOMEM;
35004 }
35005
35006 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35007
35008 dev_kfree_skb_any(skb);
35009
35010 - atomic_inc(&vcc->stats->rx_drop);
35011 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35012 return -ENOMEM;
35013 }
35014
35015 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35016
35017 vcc->push(vcc, skb);
35018 - atomic_inc(&vcc->stats->rx);
35019 + atomic_inc_unchecked(&vcc->stats->rx);
35020
35021 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35022
35023 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35024 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35025 fore200e->atm_dev->number,
35026 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35027 - atomic_inc(&vcc->stats->rx_err);
35028 + atomic_inc_unchecked(&vcc->stats->rx_err);
35029 }
35030 }
35031
35032 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35033 goto retry_here;
35034 }
35035
35036 - atomic_inc(&vcc->stats->tx_err);
35037 + atomic_inc_unchecked(&vcc->stats->tx_err);
35038
35039 fore200e->tx_sat++;
35040 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35041 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35042 index 507362a..a845e57 100644
35043 --- a/drivers/atm/he.c
35044 +++ b/drivers/atm/he.c
35045 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35046
35047 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35048 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35049 - atomic_inc(&vcc->stats->rx_drop);
35050 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35051 goto return_host_buffers;
35052 }
35053
35054 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35055 RBRQ_LEN_ERR(he_dev->rbrq_head)
35056 ? "LEN_ERR" : "",
35057 vcc->vpi, vcc->vci);
35058 - atomic_inc(&vcc->stats->rx_err);
35059 + atomic_inc_unchecked(&vcc->stats->rx_err);
35060 goto return_host_buffers;
35061 }
35062
35063 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35064 vcc->push(vcc, skb);
35065 spin_lock(&he_dev->global_lock);
35066
35067 - atomic_inc(&vcc->stats->rx);
35068 + atomic_inc_unchecked(&vcc->stats->rx);
35069
35070 return_host_buffers:
35071 ++pdus_assembled;
35072 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35073 tpd->vcc->pop(tpd->vcc, tpd->skb);
35074 else
35075 dev_kfree_skb_any(tpd->skb);
35076 - atomic_inc(&tpd->vcc->stats->tx_err);
35077 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35078 }
35079 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35080 return;
35081 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35082 vcc->pop(vcc, skb);
35083 else
35084 dev_kfree_skb_any(skb);
35085 - atomic_inc(&vcc->stats->tx_err);
35086 + atomic_inc_unchecked(&vcc->stats->tx_err);
35087 return -EINVAL;
35088 }
35089
35090 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35091 vcc->pop(vcc, skb);
35092 else
35093 dev_kfree_skb_any(skb);
35094 - atomic_inc(&vcc->stats->tx_err);
35095 + atomic_inc_unchecked(&vcc->stats->tx_err);
35096 return -EINVAL;
35097 }
35098 #endif
35099 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35100 vcc->pop(vcc, skb);
35101 else
35102 dev_kfree_skb_any(skb);
35103 - atomic_inc(&vcc->stats->tx_err);
35104 + atomic_inc_unchecked(&vcc->stats->tx_err);
35105 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35106 return -ENOMEM;
35107 }
35108 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35109 vcc->pop(vcc, skb);
35110 else
35111 dev_kfree_skb_any(skb);
35112 - atomic_inc(&vcc->stats->tx_err);
35113 + atomic_inc_unchecked(&vcc->stats->tx_err);
35114 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35115 return -ENOMEM;
35116 }
35117 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35118 __enqueue_tpd(he_dev, tpd, cid);
35119 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35120
35121 - atomic_inc(&vcc->stats->tx);
35122 + atomic_inc_unchecked(&vcc->stats->tx);
35123
35124 return 0;
35125 }
35126 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35127 index 1dc0519..1aadaf7 100644
35128 --- a/drivers/atm/horizon.c
35129 +++ b/drivers/atm/horizon.c
35130 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35131 {
35132 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35133 // VC layer stats
35134 - atomic_inc(&vcc->stats->rx);
35135 + atomic_inc_unchecked(&vcc->stats->rx);
35136 __net_timestamp(skb);
35137 // end of our responsibility
35138 vcc->push (vcc, skb);
35139 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35140 dev->tx_iovec = NULL;
35141
35142 // VC layer stats
35143 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35144 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35145
35146 // free the skb
35147 hrz_kfree_skb (skb);
35148 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35149 index 272f009..a18ba55 100644
35150 --- a/drivers/atm/idt77252.c
35151 +++ b/drivers/atm/idt77252.c
35152 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35153 else
35154 dev_kfree_skb(skb);
35155
35156 - atomic_inc(&vcc->stats->tx);
35157 + atomic_inc_unchecked(&vcc->stats->tx);
35158 }
35159
35160 atomic_dec(&scq->used);
35161 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35162 if ((sb = dev_alloc_skb(64)) == NULL) {
35163 printk("%s: Can't allocate buffers for aal0.\n",
35164 card->name);
35165 - atomic_add(i, &vcc->stats->rx_drop);
35166 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35167 break;
35168 }
35169 if (!atm_charge(vcc, sb->truesize)) {
35170 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35171 card->name);
35172 - atomic_add(i - 1, &vcc->stats->rx_drop);
35173 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35174 dev_kfree_skb(sb);
35175 break;
35176 }
35177 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35178 ATM_SKB(sb)->vcc = vcc;
35179 __net_timestamp(sb);
35180 vcc->push(vcc, sb);
35181 - atomic_inc(&vcc->stats->rx);
35182 + atomic_inc_unchecked(&vcc->stats->rx);
35183
35184 cell += ATM_CELL_PAYLOAD;
35185 }
35186 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35187 "(CDC: %08x)\n",
35188 card->name, len, rpp->len, readl(SAR_REG_CDC));
35189 recycle_rx_pool_skb(card, rpp);
35190 - atomic_inc(&vcc->stats->rx_err);
35191 + atomic_inc_unchecked(&vcc->stats->rx_err);
35192 return;
35193 }
35194 if (stat & SAR_RSQE_CRC) {
35195 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35196 recycle_rx_pool_skb(card, rpp);
35197 - atomic_inc(&vcc->stats->rx_err);
35198 + atomic_inc_unchecked(&vcc->stats->rx_err);
35199 return;
35200 }
35201 if (skb_queue_len(&rpp->queue) > 1) {
35202 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35203 RXPRINTK("%s: Can't alloc RX skb.\n",
35204 card->name);
35205 recycle_rx_pool_skb(card, rpp);
35206 - atomic_inc(&vcc->stats->rx_err);
35207 + atomic_inc_unchecked(&vcc->stats->rx_err);
35208 return;
35209 }
35210 if (!atm_charge(vcc, skb->truesize)) {
35211 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35212 __net_timestamp(skb);
35213
35214 vcc->push(vcc, skb);
35215 - atomic_inc(&vcc->stats->rx);
35216 + atomic_inc_unchecked(&vcc->stats->rx);
35217
35218 return;
35219 }
35220 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35221 __net_timestamp(skb);
35222
35223 vcc->push(vcc, skb);
35224 - atomic_inc(&vcc->stats->rx);
35225 + atomic_inc_unchecked(&vcc->stats->rx);
35226
35227 if (skb->truesize > SAR_FB_SIZE_3)
35228 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35229 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35230 if (vcc->qos.aal != ATM_AAL0) {
35231 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35232 card->name, vpi, vci);
35233 - atomic_inc(&vcc->stats->rx_drop);
35234 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35235 goto drop;
35236 }
35237
35238 if ((sb = dev_alloc_skb(64)) == NULL) {
35239 printk("%s: Can't allocate buffers for AAL0.\n",
35240 card->name);
35241 - atomic_inc(&vcc->stats->rx_err);
35242 + atomic_inc_unchecked(&vcc->stats->rx_err);
35243 goto drop;
35244 }
35245
35246 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35247 ATM_SKB(sb)->vcc = vcc;
35248 __net_timestamp(sb);
35249 vcc->push(vcc, sb);
35250 - atomic_inc(&vcc->stats->rx);
35251 + atomic_inc_unchecked(&vcc->stats->rx);
35252
35253 drop:
35254 skb_pull(queue, 64);
35255 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35256
35257 if (vc == NULL) {
35258 printk("%s: NULL connection in send().\n", card->name);
35259 - atomic_inc(&vcc->stats->tx_err);
35260 + atomic_inc_unchecked(&vcc->stats->tx_err);
35261 dev_kfree_skb(skb);
35262 return -EINVAL;
35263 }
35264 if (!test_bit(VCF_TX, &vc->flags)) {
35265 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35266 - atomic_inc(&vcc->stats->tx_err);
35267 + atomic_inc_unchecked(&vcc->stats->tx_err);
35268 dev_kfree_skb(skb);
35269 return -EINVAL;
35270 }
35271 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35272 break;
35273 default:
35274 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35275 - atomic_inc(&vcc->stats->tx_err);
35276 + atomic_inc_unchecked(&vcc->stats->tx_err);
35277 dev_kfree_skb(skb);
35278 return -EINVAL;
35279 }
35280
35281 if (skb_shinfo(skb)->nr_frags != 0) {
35282 printk("%s: No scatter-gather yet.\n", card->name);
35283 - atomic_inc(&vcc->stats->tx_err);
35284 + atomic_inc_unchecked(&vcc->stats->tx_err);
35285 dev_kfree_skb(skb);
35286 return -EINVAL;
35287 }
35288 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35289
35290 err = queue_skb(card, vc, skb, oam);
35291 if (err) {
35292 - atomic_inc(&vcc->stats->tx_err);
35293 + atomic_inc_unchecked(&vcc->stats->tx_err);
35294 dev_kfree_skb(skb);
35295 return err;
35296 }
35297 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35298 skb = dev_alloc_skb(64);
35299 if (!skb) {
35300 printk("%s: Out of memory in send_oam().\n", card->name);
35301 - atomic_inc(&vcc->stats->tx_err);
35302 + atomic_inc_unchecked(&vcc->stats->tx_err);
35303 return -ENOMEM;
35304 }
35305 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35306 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35307 index 4217f29..88f547a 100644
35308 --- a/drivers/atm/iphase.c
35309 +++ b/drivers/atm/iphase.c
35310 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35311 status = (u_short) (buf_desc_ptr->desc_mode);
35312 if (status & (RX_CER | RX_PTE | RX_OFL))
35313 {
35314 - atomic_inc(&vcc->stats->rx_err);
35315 + atomic_inc_unchecked(&vcc->stats->rx_err);
35316 IF_ERR(printk("IA: bad packet, dropping it");)
35317 if (status & RX_CER) {
35318 IF_ERR(printk(" cause: packet CRC error\n");)
35319 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35320 len = dma_addr - buf_addr;
35321 if (len > iadev->rx_buf_sz) {
35322 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35323 - atomic_inc(&vcc->stats->rx_err);
35324 + atomic_inc_unchecked(&vcc->stats->rx_err);
35325 goto out_free_desc;
35326 }
35327
35328 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35329 ia_vcc = INPH_IA_VCC(vcc);
35330 if (ia_vcc == NULL)
35331 {
35332 - atomic_inc(&vcc->stats->rx_err);
35333 + atomic_inc_unchecked(&vcc->stats->rx_err);
35334 atm_return(vcc, skb->truesize);
35335 dev_kfree_skb_any(skb);
35336 goto INCR_DLE;
35337 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35338 if ((length > iadev->rx_buf_sz) || (length >
35339 (skb->len - sizeof(struct cpcs_trailer))))
35340 {
35341 - atomic_inc(&vcc->stats->rx_err);
35342 + atomic_inc_unchecked(&vcc->stats->rx_err);
35343 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35344 length, skb->len);)
35345 atm_return(vcc, skb->truesize);
35346 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35347
35348 IF_RX(printk("rx_dle_intr: skb push");)
35349 vcc->push(vcc,skb);
35350 - atomic_inc(&vcc->stats->rx);
35351 + atomic_inc_unchecked(&vcc->stats->rx);
35352 iadev->rx_pkt_cnt++;
35353 }
35354 INCR_DLE:
35355 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35356 {
35357 struct k_sonet_stats *stats;
35358 stats = &PRIV(_ia_dev[board])->sonet_stats;
35359 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35360 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35361 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35362 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35363 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35364 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35365 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35366 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35367 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35368 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35369 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35370 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35371 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35372 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35373 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35374 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35375 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35376 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35377 }
35378 ia_cmds.status = 0;
35379 break;
35380 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35381 if ((desc == 0) || (desc > iadev->num_tx_desc))
35382 {
35383 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35384 - atomic_inc(&vcc->stats->tx);
35385 + atomic_inc_unchecked(&vcc->stats->tx);
35386 if (vcc->pop)
35387 vcc->pop(vcc, skb);
35388 else
35389 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35390 ATM_DESC(skb) = vcc->vci;
35391 skb_queue_tail(&iadev->tx_dma_q, skb);
35392
35393 - atomic_inc(&vcc->stats->tx);
35394 + atomic_inc_unchecked(&vcc->stats->tx);
35395 iadev->tx_pkt_cnt++;
35396 /* Increment transaction counter */
35397 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35398
35399 #if 0
35400 /* add flow control logic */
35401 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35402 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35403 if (iavcc->vc_desc_cnt > 10) {
35404 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35405 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35406 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35407 index fa7d701..1e404c7 100644
35408 --- a/drivers/atm/lanai.c
35409 +++ b/drivers/atm/lanai.c
35410 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35411 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35412 lanai_endtx(lanai, lvcc);
35413 lanai_free_skb(lvcc->tx.atmvcc, skb);
35414 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35415 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35416 }
35417
35418 /* Try to fill the buffer - don't call unless there is backlog */
35419 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35420 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35421 __net_timestamp(skb);
35422 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35423 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35424 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35425 out:
35426 lvcc->rx.buf.ptr = end;
35427 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35428 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35429 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35430 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35431 lanai->stats.service_rxnotaal5++;
35432 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35433 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35434 return 0;
35435 }
35436 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35437 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35438 int bytes;
35439 read_unlock(&vcc_sklist_lock);
35440 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35441 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35442 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35443 lvcc->stats.x.aal5.service_trash++;
35444 bytes = (SERVICE_GET_END(s) * 16) -
35445 (((unsigned long) lvcc->rx.buf.ptr) -
35446 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35447 }
35448 if (s & SERVICE_STREAM) {
35449 read_unlock(&vcc_sklist_lock);
35450 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35451 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35452 lvcc->stats.x.aal5.service_stream++;
35453 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35454 "PDU on VCI %d!\n", lanai->number, vci);
35455 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35456 return 0;
35457 }
35458 DPRINTK("got rx crc error on vci %d\n", vci);
35459 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35460 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35461 lvcc->stats.x.aal5.service_rxcrc++;
35462 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35463 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35464 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35465 index 6587dc2..149833d 100644
35466 --- a/drivers/atm/nicstar.c
35467 +++ b/drivers/atm/nicstar.c
35468 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35469 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35470 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35471 card->index);
35472 - atomic_inc(&vcc->stats->tx_err);
35473 + atomic_inc_unchecked(&vcc->stats->tx_err);
35474 dev_kfree_skb_any(skb);
35475 return -EINVAL;
35476 }
35477 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35478 if (!vc->tx) {
35479 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35480 card->index);
35481 - atomic_inc(&vcc->stats->tx_err);
35482 + atomic_inc_unchecked(&vcc->stats->tx_err);
35483 dev_kfree_skb_any(skb);
35484 return -EINVAL;
35485 }
35486 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35487 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35488 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35489 card->index);
35490 - atomic_inc(&vcc->stats->tx_err);
35491 + atomic_inc_unchecked(&vcc->stats->tx_err);
35492 dev_kfree_skb_any(skb);
35493 return -EINVAL;
35494 }
35495
35496 if (skb_shinfo(skb)->nr_frags != 0) {
35497 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35498 - atomic_inc(&vcc->stats->tx_err);
35499 + atomic_inc_unchecked(&vcc->stats->tx_err);
35500 dev_kfree_skb_any(skb);
35501 return -EINVAL;
35502 }
35503 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35504 }
35505
35506 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35507 - atomic_inc(&vcc->stats->tx_err);
35508 + atomic_inc_unchecked(&vcc->stats->tx_err);
35509 dev_kfree_skb_any(skb);
35510 return -EIO;
35511 }
35512 - atomic_inc(&vcc->stats->tx);
35513 + atomic_inc_unchecked(&vcc->stats->tx);
35514
35515 return 0;
35516 }
35517 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35518 printk
35519 ("nicstar%d: Can't allocate buffers for aal0.\n",
35520 card->index);
35521 - atomic_add(i, &vcc->stats->rx_drop);
35522 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35523 break;
35524 }
35525 if (!atm_charge(vcc, sb->truesize)) {
35526 RXPRINTK
35527 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35528 card->index);
35529 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35530 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35531 dev_kfree_skb_any(sb);
35532 break;
35533 }
35534 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35535 ATM_SKB(sb)->vcc = vcc;
35536 __net_timestamp(sb);
35537 vcc->push(vcc, sb);
35538 - atomic_inc(&vcc->stats->rx);
35539 + atomic_inc_unchecked(&vcc->stats->rx);
35540 cell += ATM_CELL_PAYLOAD;
35541 }
35542
35543 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35544 if (iovb == NULL) {
35545 printk("nicstar%d: Out of iovec buffers.\n",
35546 card->index);
35547 - atomic_inc(&vcc->stats->rx_drop);
35548 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35549 recycle_rx_buf(card, skb);
35550 return;
35551 }
35552 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35553 small or large buffer itself. */
35554 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35555 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35556 - atomic_inc(&vcc->stats->rx_err);
35557 + atomic_inc_unchecked(&vcc->stats->rx_err);
35558 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35559 NS_MAX_IOVECS);
35560 NS_PRV_IOVCNT(iovb) = 0;
35561 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35562 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35563 card->index);
35564 which_list(card, skb);
35565 - atomic_inc(&vcc->stats->rx_err);
35566 + atomic_inc_unchecked(&vcc->stats->rx_err);
35567 recycle_rx_buf(card, skb);
35568 vc->rx_iov = NULL;
35569 recycle_iov_buf(card, iovb);
35570 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35571 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35572 card->index);
35573 which_list(card, skb);
35574 - atomic_inc(&vcc->stats->rx_err);
35575 + atomic_inc_unchecked(&vcc->stats->rx_err);
35576 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35577 NS_PRV_IOVCNT(iovb));
35578 vc->rx_iov = NULL;
35579 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35580 printk(" - PDU size mismatch.\n");
35581 else
35582 printk(".\n");
35583 - atomic_inc(&vcc->stats->rx_err);
35584 + atomic_inc_unchecked(&vcc->stats->rx_err);
35585 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35586 NS_PRV_IOVCNT(iovb));
35587 vc->rx_iov = NULL;
35588 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35589 /* skb points to a small buffer */
35590 if (!atm_charge(vcc, skb->truesize)) {
35591 push_rxbufs(card, skb);
35592 - atomic_inc(&vcc->stats->rx_drop);
35593 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35594 } else {
35595 skb_put(skb, len);
35596 dequeue_sm_buf(card, skb);
35597 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35598 ATM_SKB(skb)->vcc = vcc;
35599 __net_timestamp(skb);
35600 vcc->push(vcc, skb);
35601 - atomic_inc(&vcc->stats->rx);
35602 + atomic_inc_unchecked(&vcc->stats->rx);
35603 }
35604 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35605 struct sk_buff *sb;
35606 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35607 if (len <= NS_SMBUFSIZE) {
35608 if (!atm_charge(vcc, sb->truesize)) {
35609 push_rxbufs(card, sb);
35610 - atomic_inc(&vcc->stats->rx_drop);
35611 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35612 } else {
35613 skb_put(sb, len);
35614 dequeue_sm_buf(card, sb);
35615 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35616 ATM_SKB(sb)->vcc = vcc;
35617 __net_timestamp(sb);
35618 vcc->push(vcc, sb);
35619 - atomic_inc(&vcc->stats->rx);
35620 + atomic_inc_unchecked(&vcc->stats->rx);
35621 }
35622
35623 push_rxbufs(card, skb);
35624 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35625
35626 if (!atm_charge(vcc, skb->truesize)) {
35627 push_rxbufs(card, skb);
35628 - atomic_inc(&vcc->stats->rx_drop);
35629 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35630 } else {
35631 dequeue_lg_buf(card, skb);
35632 #ifdef NS_USE_DESTRUCTORS
35633 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35634 ATM_SKB(skb)->vcc = vcc;
35635 __net_timestamp(skb);
35636 vcc->push(vcc, skb);
35637 - atomic_inc(&vcc->stats->rx);
35638 + atomic_inc_unchecked(&vcc->stats->rx);
35639 }
35640
35641 push_rxbufs(card, sb);
35642 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35643 printk
35644 ("nicstar%d: Out of huge buffers.\n",
35645 card->index);
35646 - atomic_inc(&vcc->stats->rx_drop);
35647 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35648 recycle_iovec_rx_bufs(card,
35649 (struct iovec *)
35650 iovb->data,
35651 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35652 card->hbpool.count++;
35653 } else
35654 dev_kfree_skb_any(hb);
35655 - atomic_inc(&vcc->stats->rx_drop);
35656 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35657 } else {
35658 /* Copy the small buffer to the huge buffer */
35659 sb = (struct sk_buff *)iov->iov_base;
35660 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35661 #endif /* NS_USE_DESTRUCTORS */
35662 __net_timestamp(hb);
35663 vcc->push(vcc, hb);
35664 - atomic_inc(&vcc->stats->rx);
35665 + atomic_inc_unchecked(&vcc->stats->rx);
35666 }
35667 }
35668
35669 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35670 index 32784d1..4a8434a 100644
35671 --- a/drivers/atm/solos-pci.c
35672 +++ b/drivers/atm/solos-pci.c
35673 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35674 }
35675 atm_charge(vcc, skb->truesize);
35676 vcc->push(vcc, skb);
35677 - atomic_inc(&vcc->stats->rx);
35678 + atomic_inc_unchecked(&vcc->stats->rx);
35679 break;
35680
35681 case PKT_STATUS:
35682 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35683 vcc = SKB_CB(oldskb)->vcc;
35684
35685 if (vcc) {
35686 - atomic_inc(&vcc->stats->tx);
35687 + atomic_inc_unchecked(&vcc->stats->tx);
35688 solos_pop(vcc, oldskb);
35689 } else {
35690 dev_kfree_skb_irq(oldskb);
35691 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35692 index 0215934..ce9f5b1 100644
35693 --- a/drivers/atm/suni.c
35694 +++ b/drivers/atm/suni.c
35695 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35696
35697
35698 #define ADD_LIMITED(s,v) \
35699 - atomic_add((v),&stats->s); \
35700 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35701 + atomic_add_unchecked((v),&stats->s); \
35702 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35703
35704
35705 static void suni_hz(unsigned long from_timer)
35706 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35707 index 5120a96..e2572bd 100644
35708 --- a/drivers/atm/uPD98402.c
35709 +++ b/drivers/atm/uPD98402.c
35710 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35711 struct sonet_stats tmp;
35712 int error = 0;
35713
35714 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35715 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35716 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35717 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35718 if (zero && !error) {
35719 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35720
35721
35722 #define ADD_LIMITED(s,v) \
35723 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35724 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35725 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35726 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35727 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35728 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35729
35730
35731 static void stat_event(struct atm_dev *dev)
35732 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35733 if (reason & uPD98402_INT_PFM) stat_event(dev);
35734 if (reason & uPD98402_INT_PCO) {
35735 (void) GET(PCOCR); /* clear interrupt cause */
35736 - atomic_add(GET(HECCT),
35737 + atomic_add_unchecked(GET(HECCT),
35738 &PRIV(dev)->sonet_stats.uncorr_hcs);
35739 }
35740 if ((reason & uPD98402_INT_RFO) &&
35741 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35742 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35743 uPD98402_INT_LOS),PIMR); /* enable them */
35744 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35745 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35746 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35747 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35748 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35749 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35750 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35751 return 0;
35752 }
35753
35754 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35755 index 969c3c2..9b72956 100644
35756 --- a/drivers/atm/zatm.c
35757 +++ b/drivers/atm/zatm.c
35758 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35759 }
35760 if (!size) {
35761 dev_kfree_skb_irq(skb);
35762 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35763 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35764 continue;
35765 }
35766 if (!atm_charge(vcc,skb->truesize)) {
35767 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35768 skb->len = size;
35769 ATM_SKB(skb)->vcc = vcc;
35770 vcc->push(vcc,skb);
35771 - atomic_inc(&vcc->stats->rx);
35772 + atomic_inc_unchecked(&vcc->stats->rx);
35773 }
35774 zout(pos & 0xffff,MTA(mbx));
35775 #if 0 /* probably a stupid idea */
35776 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35777 skb_queue_head(&zatm_vcc->backlog,skb);
35778 break;
35779 }
35780 - atomic_inc(&vcc->stats->tx);
35781 + atomic_inc_unchecked(&vcc->stats->tx);
35782 wake_up(&zatm_vcc->tx_wait);
35783 }
35784
35785 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35786 index d414331..b4dd4ba 100644
35787 --- a/drivers/base/bus.c
35788 +++ b/drivers/base/bus.c
35789 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35790 return -EINVAL;
35791
35792 mutex_lock(&subsys->p->mutex);
35793 - list_add_tail(&sif->node, &subsys->p->interfaces);
35794 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35795 if (sif->add_dev) {
35796 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35797 while ((dev = subsys_dev_iter_next(&iter)))
35798 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35799 subsys = sif->subsys;
35800
35801 mutex_lock(&subsys->p->mutex);
35802 - list_del_init(&sif->node);
35803 + pax_list_del_init((struct list_head *)&sif->node);
35804 if (sif->remove_dev) {
35805 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35806 while ((dev = subsys_dev_iter_next(&iter)))
35807 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35808 index 7413d06..79155fa 100644
35809 --- a/drivers/base/devtmpfs.c
35810 +++ b/drivers/base/devtmpfs.c
35811 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35812 if (!thread)
35813 return 0;
35814
35815 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35816 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35817 if (err)
35818 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35819 else
35820 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35821 *err = sys_unshare(CLONE_NEWNS);
35822 if (*err)
35823 goto out;
35824 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35825 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35826 if (*err)
35827 goto out;
35828 - sys_chdir("/.."); /* will traverse into overmounted root */
35829 - sys_chroot(".");
35830 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35831 + sys_chroot((char __force_user *)".");
35832 complete(&setup_done);
35833 while (1) {
35834 spin_lock(&req_lock);
35835 diff --git a/drivers/base/node.c b/drivers/base/node.c
35836 index 7616a77c..8f57f51 100644
35837 --- a/drivers/base/node.c
35838 +++ b/drivers/base/node.c
35839 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35840 struct node_attr {
35841 struct device_attribute attr;
35842 enum node_states state;
35843 -};
35844 +} __do_const;
35845
35846 static ssize_t show_node_state(struct device *dev,
35847 struct device_attribute *attr, char *buf)
35848 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35849 index bfb8955..42c9b9a 100644
35850 --- a/drivers/base/power/domain.c
35851 +++ b/drivers/base/power/domain.c
35852 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35853 {
35854 struct cpuidle_driver *cpuidle_drv;
35855 struct gpd_cpu_data *cpu_data;
35856 - struct cpuidle_state *idle_state;
35857 + cpuidle_state_no_const *idle_state;
35858 int ret = 0;
35859
35860 if (IS_ERR_OR_NULL(genpd) || state < 0)
35861 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35862 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35863 {
35864 struct gpd_cpu_data *cpu_data;
35865 - struct cpuidle_state *idle_state;
35866 + cpuidle_state_no_const *idle_state;
35867 int ret = 0;
35868
35869 if (IS_ERR_OR_NULL(genpd))
35870 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35871 index a53ebd2..8f73eeb 100644
35872 --- a/drivers/base/power/sysfs.c
35873 +++ b/drivers/base/power/sysfs.c
35874 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35875 return -EIO;
35876 }
35877 }
35878 - return sprintf(buf, p);
35879 + return sprintf(buf, "%s", p);
35880 }
35881
35882 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35883 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35884 index 2d56f41..8830f19 100644
35885 --- a/drivers/base/power/wakeup.c
35886 +++ b/drivers/base/power/wakeup.c
35887 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35888 * They need to be modified together atomically, so it's better to use one
35889 * atomic variable to hold them both.
35890 */
35891 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35892 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35893
35894 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35895 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35896
35897 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35898 {
35899 - unsigned int comb = atomic_read(&combined_event_count);
35900 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35901
35902 *cnt = (comb >> IN_PROGRESS_BITS);
35903 *inpr = comb & MAX_IN_PROGRESS;
35904 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35905 ws->start_prevent_time = ws->last_time;
35906
35907 /* Increment the counter of events in progress. */
35908 - cec = atomic_inc_return(&combined_event_count);
35909 + cec = atomic_inc_return_unchecked(&combined_event_count);
35910
35911 trace_wakeup_source_activate(ws->name, cec);
35912 }
35913 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35914 * Increment the counter of registered wakeup events and decrement the
35915 * couter of wakeup events in progress simultaneously.
35916 */
35917 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35918 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35919 trace_wakeup_source_deactivate(ws->name, cec);
35920
35921 split_counters(&cnt, &inpr);
35922 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35923 index e8d11b6..7b1b36f 100644
35924 --- a/drivers/base/syscore.c
35925 +++ b/drivers/base/syscore.c
35926 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35927 void register_syscore_ops(struct syscore_ops *ops)
35928 {
35929 mutex_lock(&syscore_ops_lock);
35930 - list_add_tail(&ops->node, &syscore_ops_list);
35931 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35932 mutex_unlock(&syscore_ops_lock);
35933 }
35934 EXPORT_SYMBOL_GPL(register_syscore_ops);
35935 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35936 void unregister_syscore_ops(struct syscore_ops *ops)
35937 {
35938 mutex_lock(&syscore_ops_lock);
35939 - list_del(&ops->node);
35940 + pax_list_del((struct list_head *)&ops->node);
35941 mutex_unlock(&syscore_ops_lock);
35942 }
35943 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35944 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35945 index 90a4e6b..002d10f 100644
35946 --- a/drivers/block/cciss.c
35947 +++ b/drivers/block/cciss.c
35948 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35949 while (!list_empty(&h->reqQ)) {
35950 c = list_entry(h->reqQ.next, CommandList_struct, list);
35951 /* can't do anything if fifo is full */
35952 - if ((h->access.fifo_full(h))) {
35953 + if ((h->access->fifo_full(h))) {
35954 dev_warn(&h->pdev->dev, "fifo full\n");
35955 break;
35956 }
35957 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35958 h->Qdepth--;
35959
35960 /* Tell the controller execute command */
35961 - h->access.submit_command(h, c);
35962 + h->access->submit_command(h, c);
35963
35964 /* Put job onto the completed Q */
35965 addQ(&h->cmpQ, c);
35966 @@ -3447,17 +3447,17 @@ startio:
35967
35968 static inline unsigned long get_next_completion(ctlr_info_t *h)
35969 {
35970 - return h->access.command_completed(h);
35971 + return h->access->command_completed(h);
35972 }
35973
35974 static inline int interrupt_pending(ctlr_info_t *h)
35975 {
35976 - return h->access.intr_pending(h);
35977 + return h->access->intr_pending(h);
35978 }
35979
35980 static inline long interrupt_not_for_us(ctlr_info_t *h)
35981 {
35982 - return ((h->access.intr_pending(h) == 0) ||
35983 + return ((h->access->intr_pending(h) == 0) ||
35984 (h->interrupts_enabled == 0));
35985 }
35986
35987 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
35988 u32 a;
35989
35990 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35991 - return h->access.command_completed(h);
35992 + return h->access->command_completed(h);
35993
35994 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35995 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35996 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35997 trans_support & CFGTBL_Trans_use_short_tags);
35998
35999 /* Change the access methods to the performant access methods */
36000 - h->access = SA5_performant_access;
36001 + h->access = &SA5_performant_access;
36002 h->transMethod = CFGTBL_Trans_Performant;
36003
36004 return;
36005 @@ -4320,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36006 if (prod_index < 0)
36007 return -ENODEV;
36008 h->product_name = products[prod_index].product_name;
36009 - h->access = *(products[prod_index].access);
36010 + h->access = products[prod_index].access;
36011
36012 if (cciss_board_disabled(h)) {
36013 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36014 @@ -5052,7 +5052,7 @@ reinit_after_soft_reset:
36015 }
36016
36017 /* make sure the board interrupts are off */
36018 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36019 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36020 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36021 if (rc)
36022 goto clean2;
36023 @@ -5102,7 +5102,7 @@ reinit_after_soft_reset:
36024 * fake ones to scoop up any residual completions.
36025 */
36026 spin_lock_irqsave(&h->lock, flags);
36027 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36028 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36029 spin_unlock_irqrestore(&h->lock, flags);
36030 free_irq(h->intr[h->intr_mode], h);
36031 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36032 @@ -5122,9 +5122,9 @@ reinit_after_soft_reset:
36033 dev_info(&h->pdev->dev, "Board READY.\n");
36034 dev_info(&h->pdev->dev,
36035 "Waiting for stale completions to drain.\n");
36036 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36037 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36038 msleep(10000);
36039 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36040 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36041
36042 rc = controller_reset_failed(h->cfgtable);
36043 if (rc)
36044 @@ -5147,7 +5147,7 @@ reinit_after_soft_reset:
36045 cciss_scsi_setup(h);
36046
36047 /* Turn the interrupts on so we can service requests */
36048 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36049 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36050
36051 /* Get the firmware version */
36052 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36053 @@ -5219,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36054 kfree(flush_buf);
36055 if (return_code != IO_OK)
36056 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36057 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36058 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36059 free_irq(h->intr[h->intr_mode], h);
36060 }
36061
36062 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36063 index 7fda30e..eb5dfe0 100644
36064 --- a/drivers/block/cciss.h
36065 +++ b/drivers/block/cciss.h
36066 @@ -101,7 +101,7 @@ struct ctlr_info
36067 /* information about each logical volume */
36068 drive_info_struct *drv[CISS_MAX_LUN];
36069
36070 - struct access_method access;
36071 + struct access_method *access;
36072
36073 /* queue and queue Info */
36074 struct list_head reqQ;
36075 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36076 index 2b94403..fd6ad1f 100644
36077 --- a/drivers/block/cpqarray.c
36078 +++ b/drivers/block/cpqarray.c
36079 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36080 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36081 goto Enomem4;
36082 }
36083 - hba[i]->access.set_intr_mask(hba[i], 0);
36084 + hba[i]->access->set_intr_mask(hba[i], 0);
36085 if (request_irq(hba[i]->intr, do_ida_intr,
36086 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36087 {
36088 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36089 add_timer(&hba[i]->timer);
36090
36091 /* Enable IRQ now that spinlock and rate limit timer are set up */
36092 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36093 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36094
36095 for(j=0; j<NWD; j++) {
36096 struct gendisk *disk = ida_gendisk[i][j];
36097 @@ -694,7 +694,7 @@ DBGINFO(
36098 for(i=0; i<NR_PRODUCTS; i++) {
36099 if (board_id == products[i].board_id) {
36100 c->product_name = products[i].product_name;
36101 - c->access = *(products[i].access);
36102 + c->access = products[i].access;
36103 break;
36104 }
36105 }
36106 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36107 hba[ctlr]->intr = intr;
36108 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36109 hba[ctlr]->product_name = products[j].product_name;
36110 - hba[ctlr]->access = *(products[j].access);
36111 + hba[ctlr]->access = products[j].access;
36112 hba[ctlr]->ctlr = ctlr;
36113 hba[ctlr]->board_id = board_id;
36114 hba[ctlr]->pci_dev = NULL; /* not PCI */
36115 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36116
36117 while((c = h->reqQ) != NULL) {
36118 /* Can't do anything if we're busy */
36119 - if (h->access.fifo_full(h) == 0)
36120 + if (h->access->fifo_full(h) == 0)
36121 return;
36122
36123 /* Get the first entry from the request Q */
36124 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36125 h->Qdepth--;
36126
36127 /* Tell the controller to do our bidding */
36128 - h->access.submit_command(h, c);
36129 + h->access->submit_command(h, c);
36130
36131 /* Get onto the completion Q */
36132 addQ(&h->cmpQ, c);
36133 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36134 unsigned long flags;
36135 __u32 a,a1;
36136
36137 - istat = h->access.intr_pending(h);
36138 + istat = h->access->intr_pending(h);
36139 /* Is this interrupt for us? */
36140 if (istat == 0)
36141 return IRQ_NONE;
36142 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36143 */
36144 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36145 if (istat & FIFO_NOT_EMPTY) {
36146 - while((a = h->access.command_completed(h))) {
36147 + while((a = h->access->command_completed(h))) {
36148 a1 = a; a &= ~3;
36149 if ((c = h->cmpQ) == NULL)
36150 {
36151 @@ -1448,11 +1448,11 @@ static int sendcmd(
36152 /*
36153 * Disable interrupt
36154 */
36155 - info_p->access.set_intr_mask(info_p, 0);
36156 + info_p->access->set_intr_mask(info_p, 0);
36157 /* Make sure there is room in the command FIFO */
36158 /* Actually it should be completely empty at this time. */
36159 for (i = 200000; i > 0; i--) {
36160 - temp = info_p->access.fifo_full(info_p);
36161 + temp = info_p->access->fifo_full(info_p);
36162 if (temp != 0) {
36163 break;
36164 }
36165 @@ -1465,7 +1465,7 @@ DBG(
36166 /*
36167 * Send the cmd
36168 */
36169 - info_p->access.submit_command(info_p, c);
36170 + info_p->access->submit_command(info_p, c);
36171 complete = pollcomplete(ctlr);
36172
36173 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36174 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36175 * we check the new geometry. Then turn interrupts back on when
36176 * we're done.
36177 */
36178 - host->access.set_intr_mask(host, 0);
36179 + host->access->set_intr_mask(host, 0);
36180 getgeometry(ctlr);
36181 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36182 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36183
36184 for(i=0; i<NWD; i++) {
36185 struct gendisk *disk = ida_gendisk[ctlr][i];
36186 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36187 /* Wait (up to 2 seconds) for a command to complete */
36188
36189 for (i = 200000; i > 0; i--) {
36190 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36191 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36192 if (done == 0) {
36193 udelay(10); /* a short fixed delay */
36194 } else
36195 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36196 index be73e9d..7fbf140 100644
36197 --- a/drivers/block/cpqarray.h
36198 +++ b/drivers/block/cpqarray.h
36199 @@ -99,7 +99,7 @@ struct ctlr_info {
36200 drv_info_t drv[NWD];
36201 struct proc_dir_entry *proc;
36202
36203 - struct access_method access;
36204 + struct access_method *access;
36205
36206 cmdlist_t *reqQ;
36207 cmdlist_t *cmpQ;
36208 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36209 index 2d7f608..11245fe 100644
36210 --- a/drivers/block/drbd/drbd_int.h
36211 +++ b/drivers/block/drbd/drbd_int.h
36212 @@ -582,7 +582,7 @@ struct drbd_epoch {
36213 struct drbd_tconn *tconn;
36214 struct list_head list;
36215 unsigned int barrier_nr;
36216 - atomic_t epoch_size; /* increased on every request added. */
36217 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36218 atomic_t active; /* increased on every req. added, and dec on every finished. */
36219 unsigned long flags;
36220 };
36221 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36222 unsigned int al_tr_number;
36223 int al_tr_cycle;
36224 wait_queue_head_t seq_wait;
36225 - atomic_t packet_seq;
36226 + atomic_unchecked_t packet_seq;
36227 unsigned int peer_seq;
36228 spinlock_t peer_seq_lock;
36229 unsigned int minor;
36230 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36231 char __user *uoptval;
36232 int err;
36233
36234 - uoptval = (char __user __force *)optval;
36235 + uoptval = (char __force_user *)optval;
36236
36237 set_fs(KERNEL_DS);
36238 if (level == SOL_SOCKET)
36239 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36240 index 55635ed..40e837c 100644
36241 --- a/drivers/block/drbd/drbd_main.c
36242 +++ b/drivers/block/drbd/drbd_main.c
36243 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36244 p->sector = sector;
36245 p->block_id = block_id;
36246 p->blksize = blksize;
36247 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36248 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36249 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36250 }
36251
36252 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36253 return -EIO;
36254 p->sector = cpu_to_be64(req->i.sector);
36255 p->block_id = (unsigned long)req;
36256 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36257 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36258 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36259 if (mdev->state.conn >= C_SYNC_SOURCE &&
36260 mdev->state.conn <= C_PAUSED_SYNC_T)
36261 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36262 {
36263 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36264
36265 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36266 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36267 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36268 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36269 kfree(tconn->current_epoch);
36270
36271 idr_destroy(&tconn->volumes);
36272 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36273 index 8cc1e64..ba7ffa9 100644
36274 --- a/drivers/block/drbd/drbd_nl.c
36275 +++ b/drivers/block/drbd/drbd_nl.c
36276 @@ -3440,7 +3440,7 @@ out:
36277
36278 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36279 {
36280 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36281 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36282 struct sk_buff *msg;
36283 struct drbd_genlmsghdr *d_out;
36284 unsigned seq;
36285 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36286 return;
36287 }
36288
36289 - seq = atomic_inc_return(&drbd_genl_seq);
36290 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36291 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36292 if (!msg)
36293 goto failed;
36294 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36295 index cc29cd3..d4b058b 100644
36296 --- a/drivers/block/drbd/drbd_receiver.c
36297 +++ b/drivers/block/drbd/drbd_receiver.c
36298 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36299 {
36300 int err;
36301
36302 - atomic_set(&mdev->packet_seq, 0);
36303 + atomic_set_unchecked(&mdev->packet_seq, 0);
36304 mdev->peer_seq = 0;
36305
36306 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36307 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36308 do {
36309 next_epoch = NULL;
36310
36311 - epoch_size = atomic_read(&epoch->epoch_size);
36312 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36313
36314 switch (ev & ~EV_CLEANUP) {
36315 case EV_PUT:
36316 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36317 rv = FE_DESTROYED;
36318 } else {
36319 epoch->flags = 0;
36320 - atomic_set(&epoch->epoch_size, 0);
36321 + atomic_set_unchecked(&epoch->epoch_size, 0);
36322 /* atomic_set(&epoch->active, 0); is already zero */
36323 if (rv == FE_STILL_LIVE)
36324 rv = FE_RECYCLED;
36325 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36326 conn_wait_active_ee_empty(tconn);
36327 drbd_flush(tconn);
36328
36329 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36330 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36331 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36332 if (epoch)
36333 break;
36334 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36335 }
36336
36337 epoch->flags = 0;
36338 - atomic_set(&epoch->epoch_size, 0);
36339 + atomic_set_unchecked(&epoch->epoch_size, 0);
36340 atomic_set(&epoch->active, 0);
36341
36342 spin_lock(&tconn->epoch_lock);
36343 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36344 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36345 list_add(&epoch->list, &tconn->current_epoch->list);
36346 tconn->current_epoch = epoch;
36347 tconn->epochs++;
36348 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36349
36350 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36351 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36352 - atomic_inc(&tconn->current_epoch->epoch_size);
36353 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36354 err2 = drbd_drain_block(mdev, pi->size);
36355 if (!err)
36356 err = err2;
36357 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36358
36359 spin_lock(&tconn->epoch_lock);
36360 peer_req->epoch = tconn->current_epoch;
36361 - atomic_inc(&peer_req->epoch->epoch_size);
36362 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36363 atomic_inc(&peer_req->epoch->active);
36364 spin_unlock(&tconn->epoch_lock);
36365
36366 @@ -4347,7 +4347,7 @@ struct data_cmd {
36367 int expect_payload;
36368 size_t pkt_size;
36369 int (*fn)(struct drbd_tconn *, struct packet_info *);
36370 -};
36371 +} __do_const;
36372
36373 static struct data_cmd drbd_cmd_handler[] = {
36374 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36375 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36376 if (!list_empty(&tconn->current_epoch->list))
36377 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36378 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36379 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36380 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36381 tconn->send.seen_any_write_yet = false;
36382
36383 conn_info(tconn, "Connection closed\n");
36384 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36385 struct asender_cmd {
36386 size_t pkt_size;
36387 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36388 -};
36389 +} __do_const;
36390
36391 static struct asender_cmd asender_tbl[] = {
36392 [P_PING] = { 0, got_Ping },
36393 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36394 index 40e7155..df5c79a 100644
36395 --- a/drivers/block/loop.c
36396 +++ b/drivers/block/loop.c
36397 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36398
36399 file_start_write(file);
36400 set_fs(get_ds());
36401 - bw = file->f_op->write(file, buf, len, &pos);
36402 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36403 set_fs(old_fs);
36404 file_end_write(file);
36405 if (likely(bw == len))
36406 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36407 index f5d0ea1..c62380a 100644
36408 --- a/drivers/block/pktcdvd.c
36409 +++ b/drivers/block/pktcdvd.c
36410 @@ -84,7 +84,7 @@
36411 #define MAX_SPEED 0xffff
36412
36413 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36414 - ~(sector_t)((pd)->settings.size - 1))
36415 + ~(sector_t)((pd)->settings.size - 1UL))
36416
36417 static DEFINE_MUTEX(pktcdvd_mutex);
36418 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36419 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36420 index 60abf59..80789e1 100644
36421 --- a/drivers/bluetooth/btwilink.c
36422 +++ b/drivers/bluetooth/btwilink.c
36423 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36424
36425 static int bt_ti_probe(struct platform_device *pdev)
36426 {
36427 - static struct ti_st *hst;
36428 + struct ti_st *hst;
36429 struct hci_dev *hdev;
36430 int err;
36431
36432 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36433 index 7332889..9ece19e 100644
36434 --- a/drivers/bus/arm-cci.c
36435 +++ b/drivers/bus/arm-cci.c
36436 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36437
36438 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36439
36440 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36441 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36442 if (!ports)
36443 return -ENOMEM;
36444
36445 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36446 index 8a3aff7..d7538c2 100644
36447 --- a/drivers/cdrom/cdrom.c
36448 +++ b/drivers/cdrom/cdrom.c
36449 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36450 ENSURE(reset, CDC_RESET);
36451 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36452 cdi->mc_flags = 0;
36453 - cdo->n_minors = 0;
36454 cdi->options = CDO_USE_FFLAGS;
36455
36456 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36457 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36458 else
36459 cdi->cdda_method = CDDA_OLD;
36460
36461 - if (!cdo->generic_packet)
36462 - cdo->generic_packet = cdrom_dummy_generic_packet;
36463 + if (!cdo->generic_packet) {
36464 + pax_open_kernel();
36465 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36466 + pax_close_kernel();
36467 + }
36468
36469 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36470 mutex_lock(&cdrom_mutex);
36471 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36472 if (cdi->exit)
36473 cdi->exit(cdi);
36474
36475 - cdi->ops->n_minors--;
36476 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36477 }
36478
36479 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36480 */
36481 nr = nframes;
36482 do {
36483 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36484 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36485 if (cgc.buffer)
36486 break;
36487
36488 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36489 struct cdrom_device_info *cdi;
36490 int ret;
36491
36492 - ret = scnprintf(info + *pos, max_size - *pos, header);
36493 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36494 if (!ret)
36495 return 1;
36496
36497 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36498 index 5980cb9..6d7bd7e 100644
36499 --- a/drivers/cdrom/gdrom.c
36500 +++ b/drivers/cdrom/gdrom.c
36501 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36502 .audio_ioctl = gdrom_audio_ioctl,
36503 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36504 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36505 - .n_minors = 1,
36506 };
36507
36508 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36509 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36510 index 1421997..33f5d6d 100644
36511 --- a/drivers/char/Kconfig
36512 +++ b/drivers/char/Kconfig
36513 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36514
36515 config DEVKMEM
36516 bool "/dev/kmem virtual device support"
36517 - default y
36518 + default n
36519 + depends on !GRKERNSEC_KMEM
36520 help
36521 Say Y here if you want to support the /dev/kmem device. The
36522 /dev/kmem device is rarely used, but can be used for certain
36523 @@ -570,6 +571,7 @@ config DEVPORT
36524 bool
36525 depends on !M68K
36526 depends on ISA || PCI
36527 + depends on !GRKERNSEC_KMEM
36528 default y
36529
36530 source "drivers/s390/char/Kconfig"
36531 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36532 index a48e05b..6bac831 100644
36533 --- a/drivers/char/agp/compat_ioctl.c
36534 +++ b/drivers/char/agp/compat_ioctl.c
36535 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36536 return -ENOMEM;
36537 }
36538
36539 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36540 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36541 sizeof(*usegment) * ureserve.seg_count)) {
36542 kfree(usegment);
36543 kfree(ksegment);
36544 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36545 index 1b19239..b87b143 100644
36546 --- a/drivers/char/agp/frontend.c
36547 +++ b/drivers/char/agp/frontend.c
36548 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36549 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36550 return -EFAULT;
36551
36552 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36553 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36554 return -EFAULT;
36555
36556 client = agp_find_client_by_pid(reserve.pid);
36557 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36558 if (segment == NULL)
36559 return -ENOMEM;
36560
36561 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36562 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36563 sizeof(struct agp_segment) * reserve.seg_count)) {
36564 kfree(segment);
36565 return -EFAULT;
36566 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36567 index 4f94375..413694e 100644
36568 --- a/drivers/char/genrtc.c
36569 +++ b/drivers/char/genrtc.c
36570 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36571 switch (cmd) {
36572
36573 case RTC_PLL_GET:
36574 + memset(&pll, 0, sizeof(pll));
36575 if (get_rtc_pll(&pll))
36576 return -EINVAL;
36577 else
36578 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36579 index 448ce5e..3a76625 100644
36580 --- a/drivers/char/hpet.c
36581 +++ b/drivers/char/hpet.c
36582 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36583 }
36584
36585 static int
36586 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36587 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36588 struct hpet_info *info)
36589 {
36590 struct hpet_timer __iomem *timer;
36591 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36592 index 86fe45c..c0ea948 100644
36593 --- a/drivers/char/hw_random/intel-rng.c
36594 +++ b/drivers/char/hw_random/intel-rng.c
36595 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36596
36597 if (no_fwh_detect)
36598 return -ENODEV;
36599 - printk(warning);
36600 + printk("%s", warning);
36601 return -EBUSY;
36602 }
36603
36604 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36605 index 4445fa1..7c6de37 100644
36606 --- a/drivers/char/ipmi/ipmi_msghandler.c
36607 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36608 @@ -420,7 +420,7 @@ struct ipmi_smi {
36609 struct proc_dir_entry *proc_dir;
36610 char proc_dir_name[10];
36611
36612 - atomic_t stats[IPMI_NUM_STATS];
36613 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36614
36615 /*
36616 * run_to_completion duplicate of smb_info, smi_info
36617 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36618
36619
36620 #define ipmi_inc_stat(intf, stat) \
36621 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36622 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36623 #define ipmi_get_stat(intf, stat) \
36624 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36625 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36626
36627 static int is_lan_addr(struct ipmi_addr *addr)
36628 {
36629 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36630 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36631 init_waitqueue_head(&intf->waitq);
36632 for (i = 0; i < IPMI_NUM_STATS; i++)
36633 - atomic_set(&intf->stats[i], 0);
36634 + atomic_set_unchecked(&intf->stats[i], 0);
36635
36636 intf->proc_dir = NULL;
36637
36638 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36639 index af4b23f..79806fc 100644
36640 --- a/drivers/char/ipmi/ipmi_si_intf.c
36641 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36642 @@ -275,7 +275,7 @@ struct smi_info {
36643 unsigned char slave_addr;
36644
36645 /* Counters and things for the proc filesystem. */
36646 - atomic_t stats[SI_NUM_STATS];
36647 + atomic_unchecked_t stats[SI_NUM_STATS];
36648
36649 struct task_struct *thread;
36650
36651 @@ -284,9 +284,9 @@ struct smi_info {
36652 };
36653
36654 #define smi_inc_stat(smi, stat) \
36655 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36656 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36657 #define smi_get_stat(smi, stat) \
36658 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36659 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36660
36661 #define SI_MAX_PARMS 4
36662
36663 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36664 atomic_set(&new_smi->req_events, 0);
36665 new_smi->run_to_completion = 0;
36666 for (i = 0; i < SI_NUM_STATS; i++)
36667 - atomic_set(&new_smi->stats[i], 0);
36668 + atomic_set_unchecked(&new_smi->stats[i], 0);
36669
36670 new_smi->interrupt_disabled = 1;
36671 atomic_set(&new_smi->stop_operation, 0);
36672 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36673 index f895a8c..2bc9147 100644
36674 --- a/drivers/char/mem.c
36675 +++ b/drivers/char/mem.c
36676 @@ -18,6 +18,7 @@
36677 #include <linux/raw.h>
36678 #include <linux/tty.h>
36679 #include <linux/capability.h>
36680 +#include <linux/security.h>
36681 #include <linux/ptrace.h>
36682 #include <linux/device.h>
36683 #include <linux/highmem.h>
36684 @@ -37,6 +38,10 @@
36685
36686 #define DEVPORT_MINOR 4
36687
36688 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36689 +extern const struct file_operations grsec_fops;
36690 +#endif
36691 +
36692 static inline unsigned long size_inside_page(unsigned long start,
36693 unsigned long size)
36694 {
36695 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36696
36697 while (cursor < to) {
36698 if (!devmem_is_allowed(pfn)) {
36699 +#ifdef CONFIG_GRKERNSEC_KMEM
36700 + gr_handle_mem_readwrite(from, to);
36701 +#else
36702 printk(KERN_INFO
36703 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36704 current->comm, from, to);
36705 +#endif
36706 return 0;
36707 }
36708 cursor += PAGE_SIZE;
36709 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36710 }
36711 return 1;
36712 }
36713 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36714 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36715 +{
36716 + return 0;
36717 +}
36718 #else
36719 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36720 {
36721 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36722
36723 while (count > 0) {
36724 unsigned long remaining;
36725 + char *temp;
36726
36727 sz = size_inside_page(p, count);
36728
36729 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36730 if (!ptr)
36731 return -EFAULT;
36732
36733 - remaining = copy_to_user(buf, ptr, sz);
36734 +#ifdef CONFIG_PAX_USERCOPY
36735 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36736 + if (!temp) {
36737 + unxlate_dev_mem_ptr(p, ptr);
36738 + return -ENOMEM;
36739 + }
36740 + memcpy(temp, ptr, sz);
36741 +#else
36742 + temp = ptr;
36743 +#endif
36744 +
36745 + remaining = copy_to_user(buf, temp, sz);
36746 +
36747 +#ifdef CONFIG_PAX_USERCOPY
36748 + kfree(temp);
36749 +#endif
36750 +
36751 unxlate_dev_mem_ptr(p, ptr);
36752 if (remaining)
36753 return -EFAULT;
36754 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36755 size_t count, loff_t *ppos)
36756 {
36757 unsigned long p = *ppos;
36758 - ssize_t low_count, read, sz;
36759 + ssize_t low_count, read, sz, err = 0;
36760 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36761 - int err = 0;
36762
36763 read = 0;
36764 if (p < (unsigned long) high_memory) {
36765 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36766 }
36767 #endif
36768 while (low_count > 0) {
36769 + char *temp;
36770 +
36771 sz = size_inside_page(p, low_count);
36772
36773 /*
36774 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36775 */
36776 kbuf = xlate_dev_kmem_ptr((char *)p);
36777
36778 - if (copy_to_user(buf, kbuf, sz))
36779 +#ifdef CONFIG_PAX_USERCOPY
36780 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36781 + if (!temp)
36782 + return -ENOMEM;
36783 + memcpy(temp, kbuf, sz);
36784 +#else
36785 + temp = kbuf;
36786 +#endif
36787 +
36788 + err = copy_to_user(buf, temp, sz);
36789 +
36790 +#ifdef CONFIG_PAX_USERCOPY
36791 + kfree(temp);
36792 +#endif
36793 +
36794 + if (err)
36795 return -EFAULT;
36796 buf += sz;
36797 p += sz;
36798 @@ -822,6 +869,9 @@ static const struct memdev {
36799 #ifdef CONFIG_PRINTK
36800 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36801 #endif
36802 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36803 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36804 +#endif
36805 };
36806
36807 static int memory_open(struct inode *inode, struct file *filp)
36808 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36809 continue;
36810
36811 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36812 - NULL, devlist[minor].name);
36813 + NULL, "%s", devlist[minor].name);
36814 }
36815
36816 return tty_init();
36817 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36818 index 9df78e2..01ba9ae 100644
36819 --- a/drivers/char/nvram.c
36820 +++ b/drivers/char/nvram.c
36821 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36822
36823 spin_unlock_irq(&rtc_lock);
36824
36825 - if (copy_to_user(buf, contents, tmp - contents))
36826 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36827 return -EFAULT;
36828
36829 *ppos = i;
36830 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36831 index 5c5cc00..ac9edb7 100644
36832 --- a/drivers/char/pcmcia/synclink_cs.c
36833 +++ b/drivers/char/pcmcia/synclink_cs.c
36834 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36835
36836 if (debug_level >= DEBUG_LEVEL_INFO)
36837 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36838 - __FILE__, __LINE__, info->device_name, port->count);
36839 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36840
36841 - WARN_ON(!port->count);
36842 + WARN_ON(!atomic_read(&port->count));
36843
36844 if (tty_port_close_start(port, tty, filp) == 0)
36845 goto cleanup;
36846 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36847 cleanup:
36848 if (debug_level >= DEBUG_LEVEL_INFO)
36849 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36850 - tty->driver->name, port->count);
36851 + tty->driver->name, atomic_read(&port->count));
36852 }
36853
36854 /* Wait until the transmitter is empty.
36855 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36856
36857 if (debug_level >= DEBUG_LEVEL_INFO)
36858 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36859 - __FILE__, __LINE__, tty->driver->name, port->count);
36860 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36861
36862 /* If port is closing, signal caller to try again */
36863 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36864 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36865 goto cleanup;
36866 }
36867 spin_lock(&port->lock);
36868 - port->count++;
36869 + atomic_inc(&port->count);
36870 spin_unlock(&port->lock);
36871 spin_unlock_irqrestore(&info->netlock, flags);
36872
36873 - if (port->count == 1) {
36874 + if (atomic_read(&port->count) == 1) {
36875 /* 1st open on this device, init hardware */
36876 retval = startup(info, tty);
36877 if (retval < 0)
36878 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36879 unsigned short new_crctype;
36880
36881 /* return error if TTY interface open */
36882 - if (info->port.count)
36883 + if (atomic_read(&info->port.count))
36884 return -EBUSY;
36885
36886 switch (encoding)
36887 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36888
36889 /* arbitrate between network and tty opens */
36890 spin_lock_irqsave(&info->netlock, flags);
36891 - if (info->port.count != 0 || info->netcount != 0) {
36892 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36893 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36894 spin_unlock_irqrestore(&info->netlock, flags);
36895 return -EBUSY;
36896 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36897 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36898
36899 /* return error if TTY interface open */
36900 - if (info->port.count)
36901 + if (atomic_read(&info->port.count))
36902 return -EBUSY;
36903
36904 if (cmd != SIOCWANDEV)
36905 diff --git a/drivers/char/random.c b/drivers/char/random.c
36906 index 92e6c67..c640ec3 100644
36907 --- a/drivers/char/random.c
36908 +++ b/drivers/char/random.c
36909 @@ -272,8 +272,13 @@
36910 /*
36911 * Configuration information
36912 */
36913 +#ifdef CONFIG_GRKERNSEC_RANDNET
36914 +#define INPUT_POOL_WORDS 512
36915 +#define OUTPUT_POOL_WORDS 128
36916 +#else
36917 #define INPUT_POOL_WORDS 128
36918 #define OUTPUT_POOL_WORDS 32
36919 +#endif
36920 #define SEC_XFER_SIZE 512
36921 #define EXTRACT_SIZE 10
36922
36923 @@ -313,10 +318,17 @@ static struct poolinfo {
36924 int poolwords;
36925 int tap1, tap2, tap3, tap4, tap5;
36926 } poolinfo_table[] = {
36927 +#ifdef CONFIG_GRKERNSEC_RANDNET
36928 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36929 + { 512, 411, 308, 208, 104, 1 },
36930 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36931 + { 128, 103, 76, 51, 25, 1 },
36932 +#else
36933 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36934 { 128, 103, 76, 51, 25, 1 },
36935 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36936 { 32, 26, 20, 14, 7, 1 },
36937 +#endif
36938 #if 0
36939 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36940 { 2048, 1638, 1231, 819, 411, 1 },
36941 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36942 input_rotate += i ? 7 : 14;
36943 }
36944
36945 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36946 - ACCESS_ONCE(r->add_ptr) = i;
36947 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36948 + ACCESS_ONCE_RW(r->add_ptr) = i;
36949 smp_wmb();
36950
36951 if (out)
36952 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36953
36954 extract_buf(r, tmp);
36955 i = min_t(int, nbytes, EXTRACT_SIZE);
36956 - if (copy_to_user(buf, tmp, i)) {
36957 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36958 ret = -EFAULT;
36959 break;
36960 }
36961 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36962 #include <linux/sysctl.h>
36963
36964 static int min_read_thresh = 8, min_write_thresh;
36965 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36966 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36967 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36968 static char sysctl_bootid[16];
36969
36970 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36971 static int proc_do_uuid(struct ctl_table *table, int write,
36972 void __user *buffer, size_t *lenp, loff_t *ppos)
36973 {
36974 - struct ctl_table fake_table;
36975 + ctl_table_no_const fake_table;
36976 unsigned char buf[64], tmp_uuid[16], *uuid;
36977
36978 uuid = table->data;
36979 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36980 index bf2349db..5456d53 100644
36981 --- a/drivers/char/sonypi.c
36982 +++ b/drivers/char/sonypi.c
36983 @@ -54,6 +54,7 @@
36984
36985 #include <asm/uaccess.h>
36986 #include <asm/io.h>
36987 +#include <asm/local.h>
36988
36989 #include <linux/sonypi.h>
36990
36991 @@ -490,7 +491,7 @@ static struct sonypi_device {
36992 spinlock_t fifo_lock;
36993 wait_queue_head_t fifo_proc_list;
36994 struct fasync_struct *fifo_async;
36995 - int open_count;
36996 + local_t open_count;
36997 int model;
36998 struct input_dev *input_jog_dev;
36999 struct input_dev *input_key_dev;
37000 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37001 static int sonypi_misc_release(struct inode *inode, struct file *file)
37002 {
37003 mutex_lock(&sonypi_device.lock);
37004 - sonypi_device.open_count--;
37005 + local_dec(&sonypi_device.open_count);
37006 mutex_unlock(&sonypi_device.lock);
37007 return 0;
37008 }
37009 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37010 {
37011 mutex_lock(&sonypi_device.lock);
37012 /* Flush input queue on first open */
37013 - if (!sonypi_device.open_count)
37014 + if (!local_read(&sonypi_device.open_count))
37015 kfifo_reset(&sonypi_device.fifo);
37016 - sonypi_device.open_count++;
37017 + local_inc(&sonypi_device.open_count);
37018 mutex_unlock(&sonypi_device.lock);
37019
37020 return 0;
37021 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37022 index 64420b3..5c40b56 100644
37023 --- a/drivers/char/tpm/tpm_acpi.c
37024 +++ b/drivers/char/tpm/tpm_acpi.c
37025 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37026 virt = acpi_os_map_memory(start, len);
37027 if (!virt) {
37028 kfree(log->bios_event_log);
37029 + log->bios_event_log = NULL;
37030 printk("%s: ERROR - Unable to map memory\n", __func__);
37031 return -EIO;
37032 }
37033
37034 - memcpy_fromio(log->bios_event_log, virt, len);
37035 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37036
37037 acpi_os_unmap_memory(virt, len);
37038 return 0;
37039 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37040 index 84ddc55..1d32f1e 100644
37041 --- a/drivers/char/tpm/tpm_eventlog.c
37042 +++ b/drivers/char/tpm/tpm_eventlog.c
37043 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37044 event = addr;
37045
37046 if ((event->event_type == 0 && event->event_size == 0) ||
37047 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37048 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37049 return NULL;
37050
37051 return addr;
37052 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37053 return NULL;
37054
37055 if ((event->event_type == 0 && event->event_size == 0) ||
37056 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37057 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37058 return NULL;
37059
37060 (*pos)++;
37061 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37062 int i;
37063
37064 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37065 - seq_putc(m, data[i]);
37066 + if (!seq_putc(m, data[i]))
37067 + return -EFAULT;
37068
37069 return 0;
37070 }
37071 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37072 index fc45567..fa2a590 100644
37073 --- a/drivers/char/virtio_console.c
37074 +++ b/drivers/char/virtio_console.c
37075 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37076 if (to_user) {
37077 ssize_t ret;
37078
37079 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37080 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37081 if (ret)
37082 return -EFAULT;
37083 } else {
37084 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37085 if (!port_has_data(port) && !port->host_connected)
37086 return 0;
37087
37088 - return fill_readbuf(port, ubuf, count, true);
37089 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37090 }
37091
37092 static int wait_port_writable(struct port *port, bool nonblock)
37093 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37094 index a33f46f..a720eed 100644
37095 --- a/drivers/clk/clk-composite.c
37096 +++ b/drivers/clk/clk-composite.c
37097 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37098 struct clk *clk;
37099 struct clk_init_data init;
37100 struct clk_composite *composite;
37101 - struct clk_ops *clk_composite_ops;
37102 + clk_ops_no_const *clk_composite_ops;
37103
37104 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37105 if (!composite) {
37106 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37107 index 5bb848c..f1d4fc9 100644
37108 --- a/drivers/clk/socfpga/clk.c
37109 +++ b/drivers/clk/socfpga/clk.c
37110 @@ -22,6 +22,7 @@
37111 #include <linux/clk-provider.h>
37112 #include <linux/io.h>
37113 #include <linux/of.h>
37114 +#include <asm/pgtable.h>
37115
37116 /* Clock Manager offsets */
37117 #define CLKMGR_CTRL 0x0
37118 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37119 streq(clk_name, "periph_pll") ||
37120 streq(clk_name, "sdram_pll")) {
37121 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37122 - clk_pll_ops.enable = clk_gate_ops.enable;
37123 - clk_pll_ops.disable = clk_gate_ops.disable;
37124 + pax_open_kernel();
37125 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37126 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37127 + pax_close_kernel();
37128 }
37129
37130 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37131 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37132 return parent_rate / div;
37133 }
37134
37135 -static struct clk_ops gateclk_ops = {
37136 +static clk_ops_no_const gateclk_ops __read_only = {
37137 .recalc_rate = socfpga_clk_recalc_rate,
37138 .get_parent = socfpga_clk_get_parent,
37139 .set_parent = socfpga_clk_set_parent,
37140 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37141 index 3926402..37b580d 100644
37142 --- a/drivers/cpufreq/acpi-cpufreq.c
37143 +++ b/drivers/cpufreq/acpi-cpufreq.c
37144 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37145 return sprintf(buf, "%u\n", boost_enabled);
37146 }
37147
37148 -static struct global_attr global_boost = __ATTR(boost, 0644,
37149 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37150 show_global_boost,
37151 store_global_boost);
37152
37153 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37154 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37155 per_cpu(acfreq_data, cpu) = data;
37156
37157 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37158 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37159 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37160 + pax_open_kernel();
37161 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37162 + pax_close_kernel();
37163 + }
37164
37165 result = acpi_processor_register_performance(data->acpi_data, cpu);
37166 if (result)
37167 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37168 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37169 break;
37170 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37171 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37172 + pax_open_kernel();
37173 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37174 + pax_close_kernel();
37175 policy->cur = get_cur_freq_on_cpu(cpu);
37176 break;
37177 default:
37178 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37179 acpi_processor_notify_smm(THIS_MODULE);
37180
37181 /* Check for APERF/MPERF support in hardware */
37182 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37183 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37184 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37185 + pax_open_kernel();
37186 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37187 + pax_close_kernel();
37188 + }
37189
37190 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37191 for (i = 0; i < perf->state_count; i++)
37192 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37193 index f0a5e2b..0a7ee46 100644
37194 --- a/drivers/cpufreq/cpufreq.c
37195 +++ b/drivers/cpufreq/cpufreq.c
37196 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37197 return NOTIFY_OK;
37198 }
37199
37200 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37201 +static struct notifier_block cpufreq_cpu_notifier = {
37202 .notifier_call = cpufreq_cpu_callback,
37203 };
37204
37205 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37206
37207 pr_debug("trying to register driver %s\n", driver_data->name);
37208
37209 - if (driver_data->setpolicy)
37210 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37211 + if (driver_data->setpolicy) {
37212 + pax_open_kernel();
37213 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37214 + pax_close_kernel();
37215 + }
37216
37217 write_lock_irqsave(&cpufreq_driver_lock, flags);
37218 if (cpufreq_driver) {
37219 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37220 index e59afaa..a53a3ff 100644
37221 --- a/drivers/cpufreq/cpufreq_governor.c
37222 +++ b/drivers/cpufreq/cpufreq_governor.c
37223 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37224 struct dbs_data *dbs_data;
37225 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37226 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37227 - struct od_ops *od_ops = NULL;
37228 + const struct od_ops *od_ops = NULL;
37229 struct od_dbs_tuners *od_tuners = NULL;
37230 struct cs_dbs_tuners *cs_tuners = NULL;
37231 struct cpu_dbs_common_info *cpu_cdbs;
37232 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37233
37234 if ((cdata->governor == GOV_CONSERVATIVE) &&
37235 (!policy->governor->initialized)) {
37236 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37237 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37238
37239 cpufreq_register_notifier(cs_ops->notifier_block,
37240 CPUFREQ_TRANSITION_NOTIFIER);
37241 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37242
37243 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37244 (policy->governor->initialized == 1)) {
37245 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37246 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37247
37248 cpufreq_unregister_notifier(cs_ops->notifier_block,
37249 CPUFREQ_TRANSITION_NOTIFIER);
37250 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37251 index d5f12b4..eb30af1 100644
37252 --- a/drivers/cpufreq/cpufreq_governor.h
37253 +++ b/drivers/cpufreq/cpufreq_governor.h
37254 @@ -204,7 +204,7 @@ struct common_dbs_data {
37255 void (*exit)(struct dbs_data *dbs_data);
37256
37257 /* Governor specific ops, see below */
37258 - void *gov_ops;
37259 + const void *gov_ops;
37260 };
37261
37262 /* Governer Per policy data */
37263 @@ -224,7 +224,7 @@ struct od_ops {
37264 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37265 unsigned int freq_next, unsigned int relation);
37266 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37267 -};
37268 +} __no_const;
37269
37270 struct cs_ops {
37271 struct notifier_block *notifier_block;
37272 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37273 index c087347..989aa2e 100644
37274 --- a/drivers/cpufreq/cpufreq_ondemand.c
37275 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37276 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37277
37278 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37279
37280 -static struct od_ops od_ops = {
37281 +static struct od_ops od_ops __read_only = {
37282 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37283 .powersave_bias_target = generic_powersave_bias_target,
37284 .freq_increase = dbs_freq_increase,
37285 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37286 (struct cpufreq_policy *, unsigned int, unsigned int),
37287 unsigned int powersave_bias)
37288 {
37289 - od_ops.powersave_bias_target = f;
37290 + pax_open_kernel();
37291 + *(void **)&od_ops.powersave_bias_target = f;
37292 + pax_close_kernel();
37293 od_set_powersave_bias(powersave_bias);
37294 }
37295 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37296
37297 void od_unregister_powersave_bias_handler(void)
37298 {
37299 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37300 + pax_open_kernel();
37301 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37302 + pax_close_kernel();
37303 od_set_powersave_bias(0);
37304 }
37305 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37306 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37307 index d37568c..fbb19a1 100644
37308 --- a/drivers/cpufreq/cpufreq_stats.c
37309 +++ b/drivers/cpufreq/cpufreq_stats.c
37310 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37311 }
37312
37313 /* priority=1 so this will get called before cpufreq_remove_dev */
37314 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37315 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37316 .notifier_call = cpufreq_stat_cpu_callback,
37317 .priority = 1,
37318 };
37319 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37320 index 9ee7817..17b658e 100644
37321 --- a/drivers/cpufreq/p4-clockmod.c
37322 +++ b/drivers/cpufreq/p4-clockmod.c
37323 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37324 case 0x0F: /* Core Duo */
37325 case 0x16: /* Celeron Core */
37326 case 0x1C: /* Atom */
37327 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37328 + pax_open_kernel();
37329 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37330 + pax_close_kernel();
37331 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37332 case 0x0D: /* Pentium M (Dothan) */
37333 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37334 + pax_open_kernel();
37335 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37336 + pax_close_kernel();
37337 /* fall through */
37338 case 0x09: /* Pentium M (Banias) */
37339 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37340 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37341
37342 /* on P-4s, the TSC runs with constant frequency independent whether
37343 * throttling is active or not. */
37344 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37345 + pax_open_kernel();
37346 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37347 + pax_close_kernel();
37348
37349 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37350 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37351 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37352 index 880ee29..2445bc6 100644
37353 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37354 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37355 @@ -18,14 +18,12 @@
37356 #include <asm/head.h>
37357 #include <asm/timer.h>
37358
37359 -static struct cpufreq_driver *cpufreq_us3_driver;
37360 -
37361 struct us3_freq_percpu_info {
37362 struct cpufreq_frequency_table table[4];
37363 };
37364
37365 /* Indexed by cpu number. */
37366 -static struct us3_freq_percpu_info *us3_freq_table;
37367 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37368
37369 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37370 * in the Safari config register.
37371 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37372
37373 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37374 {
37375 - if (cpufreq_us3_driver)
37376 - us3_set_cpu_divider_index(policy, 0);
37377 + us3_set_cpu_divider_index(policy->cpu, 0);
37378
37379 return 0;
37380 }
37381
37382 +static int __init us3_freq_init(void);
37383 +static void __exit us3_freq_exit(void);
37384 +
37385 +static struct cpufreq_driver cpufreq_us3_driver = {
37386 + .init = us3_freq_cpu_init,
37387 + .verify = us3_freq_verify,
37388 + .target = us3_freq_target,
37389 + .get = us3_freq_get,
37390 + .exit = us3_freq_cpu_exit,
37391 + .owner = THIS_MODULE,
37392 + .name = "UltraSPARC-III",
37393 +
37394 +};
37395 +
37396 static int __init us3_freq_init(void)
37397 {
37398 unsigned long manuf, impl, ver;
37399 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37400 (impl == CHEETAH_IMPL ||
37401 impl == CHEETAH_PLUS_IMPL ||
37402 impl == JAGUAR_IMPL ||
37403 - impl == PANTHER_IMPL)) {
37404 - struct cpufreq_driver *driver;
37405 -
37406 - ret = -ENOMEM;
37407 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37408 - if (!driver)
37409 - goto err_out;
37410 -
37411 - us3_freq_table = kzalloc(
37412 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37413 - GFP_KERNEL);
37414 - if (!us3_freq_table)
37415 - goto err_out;
37416 -
37417 - driver->init = us3_freq_cpu_init;
37418 - driver->verify = us3_freq_verify;
37419 - driver->target = us3_freq_target;
37420 - driver->get = us3_freq_get;
37421 - driver->exit = us3_freq_cpu_exit;
37422 - driver->owner = THIS_MODULE,
37423 - strcpy(driver->name, "UltraSPARC-III");
37424 -
37425 - cpufreq_us3_driver = driver;
37426 - ret = cpufreq_register_driver(driver);
37427 - if (ret)
37428 - goto err_out;
37429 -
37430 - return 0;
37431 -
37432 -err_out:
37433 - if (driver) {
37434 - kfree(driver);
37435 - cpufreq_us3_driver = NULL;
37436 - }
37437 - kfree(us3_freq_table);
37438 - us3_freq_table = NULL;
37439 - return ret;
37440 - }
37441 + impl == PANTHER_IMPL))
37442 + return cpufreq_register_driver(&cpufreq_us3_driver);
37443
37444 return -ENODEV;
37445 }
37446
37447 static void __exit us3_freq_exit(void)
37448 {
37449 - if (cpufreq_us3_driver) {
37450 - cpufreq_unregister_driver(cpufreq_us3_driver);
37451 - kfree(cpufreq_us3_driver);
37452 - cpufreq_us3_driver = NULL;
37453 - kfree(us3_freq_table);
37454 - us3_freq_table = NULL;
37455 - }
37456 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37457 }
37458
37459 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37460 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37461 index 0915e71..53376ed 100644
37462 --- a/drivers/cpufreq/speedstep-centrino.c
37463 +++ b/drivers/cpufreq/speedstep-centrino.c
37464 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37465 !cpu_has(cpu, X86_FEATURE_EST))
37466 return -ENODEV;
37467
37468 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37469 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37470 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37471 + pax_open_kernel();
37472 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37473 + pax_close_kernel();
37474 + }
37475
37476 if (policy->cpu != 0)
37477 return -ENODEV;
37478 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37479 index fdc432f..98e64e2 100644
37480 --- a/drivers/cpuidle/cpuidle.c
37481 +++ b/drivers/cpuidle/cpuidle.c
37482 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37483
37484 static void poll_idle_init(struct cpuidle_driver *drv)
37485 {
37486 - struct cpuidle_state *state = &drv->states[0];
37487 + cpuidle_state_no_const *state = &drv->states[0];
37488
37489 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37490 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37491 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37492 index ea2f8e7..70ac501 100644
37493 --- a/drivers/cpuidle/governor.c
37494 +++ b/drivers/cpuidle/governor.c
37495 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37496 mutex_lock(&cpuidle_lock);
37497 if (__cpuidle_find_governor(gov->name) == NULL) {
37498 ret = 0;
37499 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37500 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37501 if (!cpuidle_curr_governor ||
37502 cpuidle_curr_governor->rating < gov->rating)
37503 cpuidle_switch_governor(gov);
37504 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37505 new_gov = cpuidle_replace_governor(gov->rating);
37506 cpuidle_switch_governor(new_gov);
37507 }
37508 - list_del(&gov->governor_list);
37509 + pax_list_del((struct list_head *)&gov->governor_list);
37510 mutex_unlock(&cpuidle_lock);
37511 }
37512
37513 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37514 index 428754a..8bdf9cc 100644
37515 --- a/drivers/cpuidle/sysfs.c
37516 +++ b/drivers/cpuidle/sysfs.c
37517 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37518 NULL
37519 };
37520
37521 -static struct attribute_group cpuidle_attr_group = {
37522 +static attribute_group_no_const cpuidle_attr_group = {
37523 .attrs = cpuidle_default_attrs,
37524 .name = "cpuidle",
37525 };
37526 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37527 index 12fea3e..1e28f47 100644
37528 --- a/drivers/crypto/hifn_795x.c
37529 +++ b/drivers/crypto/hifn_795x.c
37530 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37531 MODULE_PARM_DESC(hifn_pll_ref,
37532 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37533
37534 -static atomic_t hifn_dev_number;
37535 +static atomic_unchecked_t hifn_dev_number;
37536
37537 #define ACRYPTO_OP_DECRYPT 0
37538 #define ACRYPTO_OP_ENCRYPT 1
37539 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37540 goto err_out_disable_pci_device;
37541
37542 snprintf(name, sizeof(name), "hifn%d",
37543 - atomic_inc_return(&hifn_dev_number)-1);
37544 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37545
37546 err = pci_request_regions(pdev, name);
37547 if (err)
37548 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37549 index e94e619..f7e249c 100644
37550 --- a/drivers/devfreq/devfreq.c
37551 +++ b/drivers/devfreq/devfreq.c
37552 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37553 goto err_out;
37554 }
37555
37556 - list_add(&governor->node, &devfreq_governor_list);
37557 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37558
37559 list_for_each_entry(devfreq, &devfreq_list, node) {
37560 int ret = 0;
37561 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37562 }
37563 }
37564
37565 - list_del(&governor->node);
37566 + pax_list_del((struct list_head *)&governor->node);
37567 err_out:
37568 mutex_unlock(&devfreq_list_lock);
37569
37570 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37571 index 5039fbc..841169f 100644
37572 --- a/drivers/dma/sh/shdma.c
37573 +++ b/drivers/dma/sh/shdma.c
37574 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37575 return ret;
37576 }
37577
37578 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37579 +static struct notifier_block sh_dmae_nmi_notifier = {
37580 .notifier_call = sh_dmae_nmi_handler,
37581
37582 /* Run before NMI debug handler and KGDB */
37583 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37584 index 211021d..201d47f 100644
37585 --- a/drivers/edac/edac_device.c
37586 +++ b/drivers/edac/edac_device.c
37587 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37588 */
37589 int edac_device_alloc_index(void)
37590 {
37591 - static atomic_t device_indexes = ATOMIC_INIT(0);
37592 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37593
37594 - return atomic_inc_return(&device_indexes) - 1;
37595 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37596 }
37597 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37598
37599 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37600 index e7c32c4..6397af1 100644
37601 --- a/drivers/edac/edac_mc_sysfs.c
37602 +++ b/drivers/edac/edac_mc_sysfs.c
37603 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37604 struct dev_ch_attribute {
37605 struct device_attribute attr;
37606 int channel;
37607 -};
37608 +} __do_const;
37609
37610 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37611 struct dev_ch_attribute dev_attr_legacy_##_name = \
37612 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37613 }
37614
37615 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37616 + pax_open_kernel();
37617 if (mci->get_sdram_scrub_rate) {
37618 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37619 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37620 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37621 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37622 }
37623 if (mci->set_sdram_scrub_rate) {
37624 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37625 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37626 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37627 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37628 }
37629 + pax_close_kernel();
37630 err = device_create_file(&mci->dev,
37631 &dev_attr_sdram_scrub_rate);
37632 if (err) {
37633 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37634 index dd370f9..0281629 100644
37635 --- a/drivers/edac/edac_pci.c
37636 +++ b/drivers/edac/edac_pci.c
37637 @@ -29,7 +29,7 @@
37638
37639 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37640 static LIST_HEAD(edac_pci_list);
37641 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37642 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37643
37644 /*
37645 * edac_pci_alloc_ctl_info
37646 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37647 */
37648 int edac_pci_alloc_index(void)
37649 {
37650 - return atomic_inc_return(&pci_indexes) - 1;
37651 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37652 }
37653 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37654
37655 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37656 index e8658e4..22746d6 100644
37657 --- a/drivers/edac/edac_pci_sysfs.c
37658 +++ b/drivers/edac/edac_pci_sysfs.c
37659 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37660 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37661 static int edac_pci_poll_msec = 1000; /* one second workq period */
37662
37663 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37664 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37665 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37666 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37667
37668 static struct kobject *edac_pci_top_main_kobj;
37669 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37670 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37671 void *value;
37672 ssize_t(*show) (void *, char *);
37673 ssize_t(*store) (void *, const char *, size_t);
37674 -};
37675 +} __do_const;
37676
37677 /* Set of show/store abstract level functions for PCI Parity object */
37678 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37679 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37680 edac_printk(KERN_CRIT, EDAC_PCI,
37681 "Signaled System Error on %s\n",
37682 pci_name(dev));
37683 - atomic_inc(&pci_nonparity_count);
37684 + atomic_inc_unchecked(&pci_nonparity_count);
37685 }
37686
37687 if (status & (PCI_STATUS_PARITY)) {
37688 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37689 "Master Data Parity Error on %s\n",
37690 pci_name(dev));
37691
37692 - atomic_inc(&pci_parity_count);
37693 + atomic_inc_unchecked(&pci_parity_count);
37694 }
37695
37696 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37697 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37698 "Detected Parity Error on %s\n",
37699 pci_name(dev));
37700
37701 - atomic_inc(&pci_parity_count);
37702 + atomic_inc_unchecked(&pci_parity_count);
37703 }
37704 }
37705
37706 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37707 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37708 "Signaled System Error on %s\n",
37709 pci_name(dev));
37710 - atomic_inc(&pci_nonparity_count);
37711 + atomic_inc_unchecked(&pci_nonparity_count);
37712 }
37713
37714 if (status & (PCI_STATUS_PARITY)) {
37715 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37716 "Master Data Parity Error on "
37717 "%s\n", pci_name(dev));
37718
37719 - atomic_inc(&pci_parity_count);
37720 + atomic_inc_unchecked(&pci_parity_count);
37721 }
37722
37723 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37724 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37725 "Detected Parity Error on %s\n",
37726 pci_name(dev));
37727
37728 - atomic_inc(&pci_parity_count);
37729 + atomic_inc_unchecked(&pci_parity_count);
37730 }
37731 }
37732 }
37733 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37734 if (!check_pci_errors)
37735 return;
37736
37737 - before_count = atomic_read(&pci_parity_count);
37738 + before_count = atomic_read_unchecked(&pci_parity_count);
37739
37740 /* scan all PCI devices looking for a Parity Error on devices and
37741 * bridges.
37742 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37743 /* Only if operator has selected panic on PCI Error */
37744 if (edac_pci_get_panic_on_pe()) {
37745 /* If the count is different 'after' from 'before' */
37746 - if (before_count != atomic_read(&pci_parity_count))
37747 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37748 panic("EDAC: PCI Parity Error");
37749 }
37750 }
37751 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37752 index 51b7e3a..aa8a3e8 100644
37753 --- a/drivers/edac/mce_amd.h
37754 +++ b/drivers/edac/mce_amd.h
37755 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37756 bool (*mc0_mce)(u16, u8);
37757 bool (*mc1_mce)(u16, u8);
37758 bool (*mc2_mce)(u16, u8);
37759 -};
37760 +} __no_const;
37761
37762 void amd_report_gart_errors(bool);
37763 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37764 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37765 index 57ea7f4..af06b76 100644
37766 --- a/drivers/firewire/core-card.c
37767 +++ b/drivers/firewire/core-card.c
37768 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37769 const struct fw_card_driver *driver,
37770 struct device *device)
37771 {
37772 - static atomic_t index = ATOMIC_INIT(-1);
37773 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37774
37775 - card->index = atomic_inc_return(&index);
37776 + card->index = atomic_inc_return_unchecked(&index);
37777 card->driver = driver;
37778 card->device = device;
37779 card->current_tlabel = 0;
37780 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37781
37782 void fw_core_remove_card(struct fw_card *card)
37783 {
37784 - struct fw_card_driver dummy_driver = dummy_driver_template;
37785 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37786
37787 card->driver->update_phy_reg(card, 4,
37788 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37789 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37790 index de4aa40..49ab1f2 100644
37791 --- a/drivers/firewire/core-device.c
37792 +++ b/drivers/firewire/core-device.c
37793 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37794 struct config_rom_attribute {
37795 struct device_attribute attr;
37796 u32 key;
37797 -};
37798 +} __do_const;
37799
37800 static ssize_t show_immediate(struct device *dev,
37801 struct device_attribute *dattr, char *buf)
37802 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37803 index 28a94c7..58da63a 100644
37804 --- a/drivers/firewire/core-transaction.c
37805 +++ b/drivers/firewire/core-transaction.c
37806 @@ -38,6 +38,7 @@
37807 #include <linux/timer.h>
37808 #include <linux/types.h>
37809 #include <linux/workqueue.h>
37810 +#include <linux/sched.h>
37811
37812 #include <asm/byteorder.h>
37813
37814 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37815 index 515a42c..5ecf3ba 100644
37816 --- a/drivers/firewire/core.h
37817 +++ b/drivers/firewire/core.h
37818 @@ -111,6 +111,7 @@ struct fw_card_driver {
37819
37820 int (*stop_iso)(struct fw_iso_context *ctx);
37821 };
37822 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37823
37824 void fw_card_initialize(struct fw_card *card,
37825 const struct fw_card_driver *driver, struct device *device);
37826 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37827 index 94a58a0..f5eba42 100644
37828 --- a/drivers/firmware/dmi-id.c
37829 +++ b/drivers/firmware/dmi-id.c
37830 @@ -16,7 +16,7 @@
37831 struct dmi_device_attribute{
37832 struct device_attribute dev_attr;
37833 int field;
37834 -};
37835 +} __do_const;
37836 #define to_dmi_dev_attr(_dev_attr) \
37837 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37838
37839 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37840 index 232fa8f..386c255 100644
37841 --- a/drivers/firmware/dmi_scan.c
37842 +++ b/drivers/firmware/dmi_scan.c
37843 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
37844 }
37845 }
37846 else {
37847 - /*
37848 - * no iounmap() for that ioremap(); it would be a no-op, but
37849 - * it's so early in setup that sucker gets confused into doing
37850 - * what it shouldn't if we actually call it.
37851 - */
37852 p = dmi_ioremap(0xF0000, 0x10000);
37853 if (p == NULL)
37854 goto error;
37855 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37856 if (buf == NULL)
37857 return -1;
37858
37859 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37860 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37861
37862 iounmap(buf);
37863 return 0;
37864 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37865 index 5145fa3..0d3babd 100644
37866 --- a/drivers/firmware/efi/efi.c
37867 +++ b/drivers/firmware/efi/efi.c
37868 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37869 };
37870
37871 static struct efivars generic_efivars;
37872 -static struct efivar_operations generic_ops;
37873 +static efivar_operations_no_const generic_ops __read_only;
37874
37875 static int generic_ops_register(void)
37876 {
37877 - generic_ops.get_variable = efi.get_variable;
37878 - generic_ops.set_variable = efi.set_variable;
37879 - generic_ops.get_next_variable = efi.get_next_variable;
37880 - generic_ops.query_variable_store = efi_query_variable_store;
37881 + pax_open_kernel();
37882 + *(void **)&generic_ops.get_variable = efi.get_variable;
37883 + *(void **)&generic_ops.set_variable = efi.set_variable;
37884 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37885 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37886 + pax_close_kernel();
37887
37888 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37889 }
37890 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37891 index 8a7432a..28fb839 100644
37892 --- a/drivers/firmware/efi/efivars.c
37893 +++ b/drivers/firmware/efi/efivars.c
37894 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37895 static int
37896 create_efivars_bin_attributes(void)
37897 {
37898 - struct bin_attribute *attr;
37899 + bin_attribute_no_const *attr;
37900 int error;
37901
37902 /* new_var */
37903 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37904 index 2a90ba6..07f3733 100644
37905 --- a/drivers/firmware/google/memconsole.c
37906 +++ b/drivers/firmware/google/memconsole.c
37907 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37908 if (!found_memconsole())
37909 return -ENODEV;
37910
37911 - memconsole_bin_attr.size = memconsole_length;
37912 + pax_open_kernel();
37913 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37914 + pax_close_kernel();
37915
37916 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37917
37918 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37919 index 2729e3d..f9deca1 100644
37920 --- a/drivers/gpio/gpio-ich.c
37921 +++ b/drivers/gpio/gpio-ich.c
37922 @@ -71,7 +71,7 @@ struct ichx_desc {
37923 /* Some chipsets have quirks, let these use their own request/get */
37924 int (*request)(struct gpio_chip *chip, unsigned offset);
37925 int (*get)(struct gpio_chip *chip, unsigned offset);
37926 -};
37927 +} __do_const;
37928
37929 static struct {
37930 spinlock_t lock;
37931 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37932 index 9902732..64b62dd 100644
37933 --- a/drivers/gpio/gpio-vr41xx.c
37934 +++ b/drivers/gpio/gpio-vr41xx.c
37935 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37936 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37937 maskl, pendl, maskh, pendh);
37938
37939 - atomic_inc(&irq_err_count);
37940 + atomic_inc_unchecked(&irq_err_count);
37941
37942 return -EINVAL;
37943 }
37944 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37945 index 6a64749..0767a9f 100644
37946 --- a/drivers/gpu/drm/drm_crtc_helper.c
37947 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37948 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37949 struct drm_crtc *tmp;
37950 int crtc_mask = 1;
37951
37952 - WARN(!crtc, "checking null crtc?\n");
37953 + BUG_ON(!crtc);
37954
37955 dev = crtc->dev;
37956
37957 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37958 index 6dd7173..32d755c 100644
37959 --- a/drivers/gpu/drm/drm_drv.c
37960 +++ b/drivers/gpu/drm/drm_drv.c
37961 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
37962 /**
37963 * Copy and IOCTL return string to user space
37964 */
37965 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37966 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37967 {
37968 int len;
37969
37970 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
37971 struct drm_file *file_priv = filp->private_data;
37972 struct drm_device *dev;
37973 const struct drm_ioctl_desc *ioctl = NULL;
37974 - drm_ioctl_t *func;
37975 + drm_ioctl_no_const_t func;
37976 unsigned int nr = DRM_IOCTL_NR(cmd);
37977 int retcode = -EINVAL;
37978 char stack_kdata[128];
37979 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
37980 return -ENODEV;
37981
37982 atomic_inc(&dev->ioctl_count);
37983 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37984 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37985 ++file_priv->ioctl_count;
37986
37987 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37988 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37989 index 3a24385..4e426e0 100644
37990 --- a/drivers/gpu/drm/drm_fops.c
37991 +++ b/drivers/gpu/drm/drm_fops.c
37992 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37993 }
37994
37995 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37996 - atomic_set(&dev->counts[i], 0);
37997 + atomic_set_unchecked(&dev->counts[i], 0);
37998
37999 dev->sigdata.lock = NULL;
38000
38001 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
38002 if (drm_device_is_unplugged(dev))
38003 return -ENODEV;
38004
38005 - if (!dev->open_count++)
38006 + if (local_inc_return(&dev->open_count) == 1)
38007 need_setup = 1;
38008 mutex_lock(&dev->struct_mutex);
38009 old_imapping = inode->i_mapping;
38010 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38011 retcode = drm_open_helper(inode, filp, dev);
38012 if (retcode)
38013 goto err_undo;
38014 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38015 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38016 if (need_setup) {
38017 retcode = drm_setup(dev);
38018 if (retcode)
38019 @@ -166,7 +166,7 @@ err_undo:
38020 iput(container_of(dev->dev_mapping, struct inode, i_data));
38021 dev->dev_mapping = old_mapping;
38022 mutex_unlock(&dev->struct_mutex);
38023 - dev->open_count--;
38024 + local_dec(&dev->open_count);
38025 return retcode;
38026 }
38027 EXPORT_SYMBOL(drm_open);
38028 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38029
38030 mutex_lock(&drm_global_mutex);
38031
38032 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38033 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38034
38035 if (dev->driver->preclose)
38036 dev->driver->preclose(dev, file_priv);
38037 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38038 * Begin inline drm_release
38039 */
38040
38041 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38042 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38043 task_pid_nr(current),
38044 (long)old_encode_dev(file_priv->minor->device),
38045 - dev->open_count);
38046 + local_read(&dev->open_count));
38047
38048 /* Release any auth tokens that might point to this file_priv,
38049 (do that under the drm_global_mutex) */
38050 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38051 * End inline drm_release
38052 */
38053
38054 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38055 - if (!--dev->open_count) {
38056 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38057 + if (local_dec_and_test(&dev->open_count)) {
38058 if (atomic_read(&dev->ioctl_count)) {
38059 DRM_ERROR("Device busy: %d\n",
38060 atomic_read(&dev->ioctl_count));
38061 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38062 index f731116..629842c 100644
38063 --- a/drivers/gpu/drm/drm_global.c
38064 +++ b/drivers/gpu/drm/drm_global.c
38065 @@ -36,7 +36,7 @@
38066 struct drm_global_item {
38067 struct mutex mutex;
38068 void *object;
38069 - int refcount;
38070 + atomic_t refcount;
38071 };
38072
38073 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38074 @@ -49,7 +49,7 @@ void drm_global_init(void)
38075 struct drm_global_item *item = &glob[i];
38076 mutex_init(&item->mutex);
38077 item->object = NULL;
38078 - item->refcount = 0;
38079 + atomic_set(&item->refcount, 0);
38080 }
38081 }
38082
38083 @@ -59,7 +59,7 @@ void drm_global_release(void)
38084 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38085 struct drm_global_item *item = &glob[i];
38086 BUG_ON(item->object != NULL);
38087 - BUG_ON(item->refcount != 0);
38088 + BUG_ON(atomic_read(&item->refcount) != 0);
38089 }
38090 }
38091
38092 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38093 void *object;
38094
38095 mutex_lock(&item->mutex);
38096 - if (item->refcount == 0) {
38097 + if (atomic_read(&item->refcount) == 0) {
38098 item->object = kzalloc(ref->size, GFP_KERNEL);
38099 if (unlikely(item->object == NULL)) {
38100 ret = -ENOMEM;
38101 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38102 goto out_err;
38103
38104 }
38105 - ++item->refcount;
38106 + atomic_inc(&item->refcount);
38107 ref->object = item->object;
38108 object = item->object;
38109 mutex_unlock(&item->mutex);
38110 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38111 struct drm_global_item *item = &glob[ref->global_type];
38112
38113 mutex_lock(&item->mutex);
38114 - BUG_ON(item->refcount == 0);
38115 + BUG_ON(atomic_read(&item->refcount) == 0);
38116 BUG_ON(ref->object != item->object);
38117 - if (--item->refcount == 0) {
38118 + if (atomic_dec_and_test(&item->refcount)) {
38119 ref->release(ref);
38120 item->object = NULL;
38121 }
38122 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38123 index d4b20ce..77a8d41 100644
38124 --- a/drivers/gpu/drm/drm_info.c
38125 +++ b/drivers/gpu/drm/drm_info.c
38126 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38127 struct drm_local_map *map;
38128 struct drm_map_list *r_list;
38129
38130 - /* Hardcoded from _DRM_FRAME_BUFFER,
38131 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38132 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38133 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38134 + static const char * const types[] = {
38135 + [_DRM_FRAME_BUFFER] = "FB",
38136 + [_DRM_REGISTERS] = "REG",
38137 + [_DRM_SHM] = "SHM",
38138 + [_DRM_AGP] = "AGP",
38139 + [_DRM_SCATTER_GATHER] = "SG",
38140 + [_DRM_CONSISTENT] = "PCI",
38141 + [_DRM_GEM] = "GEM" };
38142 const char *type;
38143 int i;
38144
38145 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38146 map = r_list->map;
38147 if (!map)
38148 continue;
38149 - if (map->type < 0 || map->type > 5)
38150 + if (map->type >= ARRAY_SIZE(types))
38151 type = "??";
38152 else
38153 type = types[map->type];
38154 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38155 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38156 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38157 vma->vm_flags & VM_IO ? 'i' : '-',
38158 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38159 + 0);
38160 +#else
38161 vma->vm_pgoff);
38162 +#endif
38163
38164 #if defined(__i386__)
38165 pgprot = pgprot_val(vma->vm_page_prot);
38166 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38167 index 2f4c434..dd12cd2 100644
38168 --- a/drivers/gpu/drm/drm_ioc32.c
38169 +++ b/drivers/gpu/drm/drm_ioc32.c
38170 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38171 request = compat_alloc_user_space(nbytes);
38172 if (!access_ok(VERIFY_WRITE, request, nbytes))
38173 return -EFAULT;
38174 - list = (struct drm_buf_desc *) (request + 1);
38175 + list = (struct drm_buf_desc __user *) (request + 1);
38176
38177 if (__put_user(count, &request->count)
38178 || __put_user(list, &request->list))
38179 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38180 request = compat_alloc_user_space(nbytes);
38181 if (!access_ok(VERIFY_WRITE, request, nbytes))
38182 return -EFAULT;
38183 - list = (struct drm_buf_pub *) (request + 1);
38184 + list = (struct drm_buf_pub __user *) (request + 1);
38185
38186 if (__put_user(count, &request->count)
38187 || __put_user(list, &request->list))
38188 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38189 return 0;
38190 }
38191
38192 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38193 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38194 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38195 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38196 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38197 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38198 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38199 {
38200 unsigned int nr = DRM_IOCTL_NR(cmd);
38201 - drm_ioctl_compat_t *fn;
38202 int ret;
38203
38204 /* Assume that ioctls without an explicit compat routine will just
38205 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38206 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38207 return drm_ioctl(filp, cmd, arg);
38208
38209 - fn = drm_compat_ioctls[nr];
38210 -
38211 - if (fn != NULL)
38212 - ret = (*fn) (filp, cmd, arg);
38213 + if (drm_compat_ioctls[nr] != NULL)
38214 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38215 else
38216 ret = drm_ioctl(filp, cmd, arg);
38217
38218 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38219 index ffd7a7b..a64643e 100644
38220 --- a/drivers/gpu/drm/drm_ioctl.c
38221 +++ b/drivers/gpu/drm/drm_ioctl.c
38222 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38223 stats->data[i].value =
38224 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38225 else
38226 - stats->data[i].value = atomic_read(&dev->counts[i]);
38227 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38228 stats->data[i].type = dev->types[i];
38229 }
38230
38231 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38232 index d752c96..fe08455 100644
38233 --- a/drivers/gpu/drm/drm_lock.c
38234 +++ b/drivers/gpu/drm/drm_lock.c
38235 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38236 if (drm_lock_take(&master->lock, lock->context)) {
38237 master->lock.file_priv = file_priv;
38238 master->lock.lock_time = jiffies;
38239 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38240 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38241 break; /* Got lock */
38242 }
38243
38244 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38245 return -EINVAL;
38246 }
38247
38248 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38249 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38250
38251 if (drm_lock_free(&master->lock, lock->context)) {
38252 /* FIXME: Should really bail out here. */
38253 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38254 index 327ca19..684d3c0 100644
38255 --- a/drivers/gpu/drm/drm_stub.c
38256 +++ b/drivers/gpu/drm/drm_stub.c
38257 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38258
38259 drm_device_set_unplugged(dev);
38260
38261 - if (dev->open_count == 0) {
38262 + if (local_read(&dev->open_count) == 0) {
38263 drm_put_dev(dev);
38264 }
38265 mutex_unlock(&drm_global_mutex);
38266 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38267 index 2290b3b..22056a1 100644
38268 --- a/drivers/gpu/drm/drm_sysfs.c
38269 +++ b/drivers/gpu/drm/drm_sysfs.c
38270 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38271 int drm_sysfs_device_add(struct drm_minor *minor)
38272 {
38273 int err;
38274 - char *minor_str;
38275 + const char *minor_str;
38276
38277 minor->kdev.parent = minor->dev->dev;
38278
38279 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38280 index ada49ed..29275a0 100644
38281 --- a/drivers/gpu/drm/i810/i810_dma.c
38282 +++ b/drivers/gpu/drm/i810/i810_dma.c
38283 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38284 dma->buflist[vertex->idx],
38285 vertex->discard, vertex->used);
38286
38287 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38288 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38289 + atomic_add_unchecked(vertex->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 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38295 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38296 mc->last_render);
38297
38298 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38299 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38300 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38301 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38302 sarea_priv->last_enqueue = dev_priv->counter - 1;
38303 sarea_priv->last_dispatch = (int)hw_status[5];
38304
38305 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38306 index 6e0acad..93c8289 100644
38307 --- a/drivers/gpu/drm/i810/i810_drv.h
38308 +++ b/drivers/gpu/drm/i810/i810_drv.h
38309 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38310 int page_flipping;
38311
38312 wait_queue_head_t irq_queue;
38313 - atomic_t irq_received;
38314 - atomic_t irq_emitted;
38315 + atomic_unchecked_t irq_received;
38316 + atomic_unchecked_t irq_emitted;
38317
38318 int front_offset;
38319 } drm_i810_private_t;
38320 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38321 index 47d6c74..279123f 100644
38322 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38323 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38324 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38325 I915_READ(GTIMR));
38326 }
38327 seq_printf(m, "Interrupts received: %d\n",
38328 - atomic_read(&dev_priv->irq_received));
38329 + atomic_read_unchecked(&dev_priv->irq_received));
38330 for_each_ring(ring, dev_priv, i) {
38331 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38332 seq_printf(m,
38333 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38334 index f466980..8f2883f 100644
38335 --- a/drivers/gpu/drm/i915/i915_dma.c
38336 +++ b/drivers/gpu/drm/i915/i915_dma.c
38337 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38338 bool can_switch;
38339
38340 spin_lock(&dev->count_lock);
38341 - can_switch = (dev->open_count == 0);
38342 + can_switch = (local_read(&dev->open_count) == 0);
38343 spin_unlock(&dev->count_lock);
38344 return can_switch;
38345 }
38346 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38347 index 2f09e80..077876d 100644
38348 --- a/drivers/gpu/drm/i915/i915_drv.h
38349 +++ b/drivers/gpu/drm/i915/i915_drv.h
38350 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38351 drm_dma_handle_t *status_page_dmah;
38352 struct resource mch_res;
38353
38354 - atomic_t irq_received;
38355 + atomic_unchecked_t irq_received;
38356
38357 /* protects the irq masks */
38358 spinlock_t irq_lock;
38359 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38360 index 87a3227..cd13d8f 100644
38361 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38362 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38363 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38364
38365 static int
38366 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38367 - int count)
38368 + unsigned int count)
38369 {
38370 - int i;
38371 + unsigned int i;
38372 int relocs_total = 0;
38373 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38374
38375 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38376 index 3c59584..500f2e9 100644
38377 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38378 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38379 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38380 (unsigned long)request);
38381 }
38382
38383 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38384 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38385 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38386 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38387 [DRM_I915_GETPARAM] = compat_i915_getparam,
38388 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38389 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38390 {
38391 unsigned int nr = DRM_IOCTL_NR(cmd);
38392 - drm_ioctl_compat_t *fn = NULL;
38393 int ret;
38394
38395 if (nr < DRM_COMMAND_BASE)
38396 return drm_compat_ioctl(filp, cmd, arg);
38397
38398 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38399 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38400 -
38401 - if (fn != NULL)
38402 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38403 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38404 ret = (*fn) (filp, cmd, arg);
38405 - else
38406 + } else
38407 ret = drm_ioctl(filp, cmd, arg);
38408
38409 return ret;
38410 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38411 index 46d46ba..6e49848 100644
38412 --- a/drivers/gpu/drm/i915/i915_irq.c
38413 +++ b/drivers/gpu/drm/i915/i915_irq.c
38414 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38415 int pipe;
38416 u32 pipe_stats[I915_MAX_PIPES];
38417
38418 - atomic_inc(&dev_priv->irq_received);
38419 + atomic_inc_unchecked(&dev_priv->irq_received);
38420
38421 while (true) {
38422 iir = I915_READ(VLV_IIR);
38423 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38424 irqreturn_t ret = IRQ_NONE;
38425 int i;
38426
38427 - atomic_inc(&dev_priv->irq_received);
38428 + atomic_inc_unchecked(&dev_priv->irq_received);
38429
38430 /* We get interrupts on unclaimed registers, so check for this before we
38431 * do any I915_{READ,WRITE}. */
38432 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38433 int ret = IRQ_NONE;
38434 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38435
38436 - atomic_inc(&dev_priv->irq_received);
38437 + atomic_inc_unchecked(&dev_priv->irq_received);
38438
38439 /* disable master interrupt before clearing iir */
38440 de_ier = I915_READ(DEIER);
38441 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38442 {
38443 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38444
38445 - atomic_set(&dev_priv->irq_received, 0);
38446 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38447
38448 I915_WRITE(HWSTAM, 0xeffe);
38449
38450 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38451 {
38452 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38453
38454 - atomic_set(&dev_priv->irq_received, 0);
38455 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38456
38457 I915_WRITE(HWSTAM, 0xeffe);
38458
38459 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38460 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38461 int pipe;
38462
38463 - atomic_set(&dev_priv->irq_received, 0);
38464 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38465
38466 /* VLV magic */
38467 I915_WRITE(VLV_IMR, 0);
38468 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38469 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38470 int pipe;
38471
38472 - atomic_set(&dev_priv->irq_received, 0);
38473 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38474
38475 for_each_pipe(pipe)
38476 I915_WRITE(PIPESTAT(pipe), 0);
38477 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38478 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38479 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38480
38481 - atomic_inc(&dev_priv->irq_received);
38482 + atomic_inc_unchecked(&dev_priv->irq_received);
38483
38484 iir = I915_READ16(IIR);
38485 if (iir == 0)
38486 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38487 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38488 int pipe;
38489
38490 - atomic_set(&dev_priv->irq_received, 0);
38491 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38492
38493 if (I915_HAS_HOTPLUG(dev)) {
38494 I915_WRITE(PORT_HOTPLUG_EN, 0);
38495 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38496 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38497 int pipe, ret = IRQ_NONE;
38498
38499 - atomic_inc(&dev_priv->irq_received);
38500 + atomic_inc_unchecked(&dev_priv->irq_received);
38501
38502 iir = I915_READ(IIR);
38503 do {
38504 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38505 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38506 int pipe;
38507
38508 - atomic_set(&dev_priv->irq_received, 0);
38509 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38510
38511 I915_WRITE(PORT_HOTPLUG_EN, 0);
38512 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38513 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38514 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38515 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38516
38517 - atomic_inc(&dev_priv->irq_received);
38518 + atomic_inc_unchecked(&dev_priv->irq_received);
38519
38520 iir = I915_READ(IIR);
38521
38522 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38523 index ad2a258..684e615 100644
38524 --- a/drivers/gpu/drm/i915/intel_display.c
38525 +++ b/drivers/gpu/drm/i915/intel_display.c
38526 @@ -9461,13 +9461,13 @@ struct intel_quirk {
38527 int subsystem_vendor;
38528 int subsystem_device;
38529 void (*hook)(struct drm_device *dev);
38530 -};
38531 +} __do_const;
38532
38533 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38534 struct intel_dmi_quirk {
38535 void (*hook)(struct drm_device *dev);
38536 const struct dmi_system_id (*dmi_id_list)[];
38537 -};
38538 +} __do_const;
38539
38540 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38541 {
38542 @@ -9475,18 +9475,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38543 return 1;
38544 }
38545
38546 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38547 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38548 {
38549 - .dmi_id_list = &(const struct dmi_system_id[]) {
38550 - {
38551 - .callback = intel_dmi_reverse_brightness,
38552 - .ident = "NCR Corporation",
38553 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38554 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38555 - },
38556 - },
38557 - { } /* terminating entry */
38558 + .callback = intel_dmi_reverse_brightness,
38559 + .ident = "NCR Corporation",
38560 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38561 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38562 },
38563 + },
38564 + { } /* terminating entry */
38565 +};
38566 +
38567 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38568 + {
38569 + .dmi_id_list = &intel_dmi_quirks_table,
38570 .hook = quirk_invert_brightness,
38571 },
38572 };
38573 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38574 index 54558a0..2d97005 100644
38575 --- a/drivers/gpu/drm/mga/mga_drv.h
38576 +++ b/drivers/gpu/drm/mga/mga_drv.h
38577 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38578 u32 clear_cmd;
38579 u32 maccess;
38580
38581 - atomic_t vbl_received; /**< Number of vblanks received. */
38582 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38583 wait_queue_head_t fence_queue;
38584 - atomic_t last_fence_retired;
38585 + atomic_unchecked_t last_fence_retired;
38586 u32 next_fence_to_post;
38587
38588 unsigned int fb_cpp;
38589 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38590 index 709e90d..89a1c0d 100644
38591 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38592 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38593 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38594 return 0;
38595 }
38596
38597 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38598 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38599 [DRM_MGA_INIT] = compat_mga_init,
38600 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38601 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38602 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38603 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38604 {
38605 unsigned int nr = DRM_IOCTL_NR(cmd);
38606 - drm_ioctl_compat_t *fn = NULL;
38607 int ret;
38608
38609 if (nr < DRM_COMMAND_BASE)
38610 return drm_compat_ioctl(filp, cmd, arg);
38611
38612 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38613 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38614 -
38615 - if (fn != NULL)
38616 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38617 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38618 ret = (*fn) (filp, cmd, arg);
38619 - else
38620 + } else
38621 ret = drm_ioctl(filp, cmd, arg);
38622
38623 return ret;
38624 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38625 index 598c281..60d590e 100644
38626 --- a/drivers/gpu/drm/mga/mga_irq.c
38627 +++ b/drivers/gpu/drm/mga/mga_irq.c
38628 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38629 if (crtc != 0)
38630 return 0;
38631
38632 - return atomic_read(&dev_priv->vbl_received);
38633 + return atomic_read_unchecked(&dev_priv->vbl_received);
38634 }
38635
38636
38637 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38638 /* VBLANK interrupt */
38639 if (status & MGA_VLINEPEN) {
38640 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38641 - atomic_inc(&dev_priv->vbl_received);
38642 + atomic_inc_unchecked(&dev_priv->vbl_received);
38643 drm_handle_vblank(dev, 0);
38644 handled = 1;
38645 }
38646 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38647 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38648 MGA_WRITE(MGA_PRIMEND, prim_end);
38649
38650 - atomic_inc(&dev_priv->last_fence_retired);
38651 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38652 DRM_WAKEUP(&dev_priv->fence_queue);
38653 handled = 1;
38654 }
38655 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38656 * using fences.
38657 */
38658 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38659 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38660 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38661 - *sequence) <= (1 << 23)));
38662
38663 *sequence = cur_fence;
38664 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38665 index 3e72876..d1c15ad 100644
38666 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38667 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38668 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38669 struct bit_table {
38670 const char id;
38671 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38672 -};
38673 +} __no_const;
38674
38675 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38676
38677 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38678 index 41ff7e0..fa854ef 100644
38679 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38680 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38681 @@ -92,7 +92,6 @@ struct nouveau_drm {
38682 struct drm_global_reference mem_global_ref;
38683 struct ttm_bo_global_ref bo_global_ref;
38684 struct ttm_bo_device bdev;
38685 - atomic_t validate_sequence;
38686 int (*move)(struct nouveau_channel *,
38687 struct ttm_buffer_object *,
38688 struct ttm_mem_reg *, struct ttm_mem_reg *);
38689 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38690 index 08214bc..9208577 100644
38691 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38692 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38693 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38694 unsigned long arg)
38695 {
38696 unsigned int nr = DRM_IOCTL_NR(cmd);
38697 - drm_ioctl_compat_t *fn = NULL;
38698 + drm_ioctl_compat_t fn = NULL;
38699 int ret;
38700
38701 if (nr < DRM_COMMAND_BASE)
38702 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38703 index 25d3495..d81aaf6 100644
38704 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38705 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38706 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38707 bool can_switch;
38708
38709 spin_lock(&dev->count_lock);
38710 - can_switch = (dev->open_count == 0);
38711 + can_switch = (local_read(&dev->open_count) == 0);
38712 spin_unlock(&dev->count_lock);
38713 return can_switch;
38714 }
38715 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38716 index 1dfd84c..104896c 100644
38717 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38718 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38719 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38720 }
38721 }
38722
38723 -static struct vm_operations_struct qxl_ttm_vm_ops;
38724 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38725 static const struct vm_operations_struct *ttm_vm_ops;
38726
38727 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38728 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38729 return r;
38730 if (unlikely(ttm_vm_ops == NULL)) {
38731 ttm_vm_ops = vma->vm_ops;
38732 + pax_open_kernel();
38733 qxl_ttm_vm_ops = *ttm_vm_ops;
38734 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38735 + pax_close_kernel();
38736 }
38737 vma->vm_ops = &qxl_ttm_vm_ops;
38738 return 0;
38739 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38740 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38741 {
38742 #if defined(CONFIG_DEBUG_FS)
38743 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38744 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38745 - unsigned i;
38746 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38747 + {
38748 + .name = "qxl_mem_mm",
38749 + .show = &qxl_mm_dump_table,
38750 + },
38751 + {
38752 + .name = "qxl_surf_mm",
38753 + .show = &qxl_mm_dump_table,
38754 + }
38755 + };
38756
38757 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38758 - if (i == 0)
38759 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38760 - else
38761 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38762 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38763 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38764 - qxl_mem_types_list[i].driver_features = 0;
38765 - if (i == 0)
38766 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38767 - else
38768 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38769 + pax_open_kernel();
38770 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38771 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38772 + pax_close_kernel();
38773
38774 - }
38775 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38776 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38777 #else
38778 return 0;
38779 #endif
38780 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38781 index d4660cf..70dbe65 100644
38782 --- a/drivers/gpu/drm/r128/r128_cce.c
38783 +++ b/drivers/gpu/drm/r128/r128_cce.c
38784 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38785
38786 /* GH: Simple idle check.
38787 */
38788 - atomic_set(&dev_priv->idle_count, 0);
38789 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38790
38791 /* We don't support anything other than bus-mastering ring mode,
38792 * but the ring can be in either AGP or PCI space for the ring
38793 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38794 index 930c71b..499aded 100644
38795 --- a/drivers/gpu/drm/r128/r128_drv.h
38796 +++ b/drivers/gpu/drm/r128/r128_drv.h
38797 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38798 int is_pci;
38799 unsigned long cce_buffers_offset;
38800
38801 - atomic_t idle_count;
38802 + atomic_unchecked_t idle_count;
38803
38804 int page_flipping;
38805 int current_page;
38806 u32 crtc_offset;
38807 u32 crtc_offset_cntl;
38808
38809 - atomic_t vbl_received;
38810 + atomic_unchecked_t vbl_received;
38811
38812 u32 color_fmt;
38813 unsigned int front_offset;
38814 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38815 index a954c54..9cc595c 100644
38816 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38817 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38818 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38819 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38820 }
38821
38822 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38823 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38824 [DRM_R128_INIT] = compat_r128_init,
38825 [DRM_R128_DEPTH] = compat_r128_depth,
38826 [DRM_R128_STIPPLE] = compat_r128_stipple,
38827 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38828 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38829 {
38830 unsigned int nr = DRM_IOCTL_NR(cmd);
38831 - drm_ioctl_compat_t *fn = NULL;
38832 int ret;
38833
38834 if (nr < DRM_COMMAND_BASE)
38835 return drm_compat_ioctl(filp, cmd, arg);
38836
38837 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38838 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38839 -
38840 - if (fn != NULL)
38841 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38842 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38843 ret = (*fn) (filp, cmd, arg);
38844 - else
38845 + } else
38846 ret = drm_ioctl(filp, cmd, arg);
38847
38848 return ret;
38849 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38850 index 2ea4f09..d391371 100644
38851 --- a/drivers/gpu/drm/r128/r128_irq.c
38852 +++ b/drivers/gpu/drm/r128/r128_irq.c
38853 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38854 if (crtc != 0)
38855 return 0;
38856
38857 - return atomic_read(&dev_priv->vbl_received);
38858 + return atomic_read_unchecked(&dev_priv->vbl_received);
38859 }
38860
38861 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38862 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38863 /* VBLANK interrupt */
38864 if (status & R128_CRTC_VBLANK_INT) {
38865 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38866 - atomic_inc(&dev_priv->vbl_received);
38867 + atomic_inc_unchecked(&dev_priv->vbl_received);
38868 drm_handle_vblank(dev, 0);
38869 return IRQ_HANDLED;
38870 }
38871 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38872 index 19bb7e6..de7e2a2 100644
38873 --- a/drivers/gpu/drm/r128/r128_state.c
38874 +++ b/drivers/gpu/drm/r128/r128_state.c
38875 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38876
38877 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38878 {
38879 - if (atomic_read(&dev_priv->idle_count) == 0)
38880 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38881 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38882 else
38883 - atomic_set(&dev_priv->idle_count, 0);
38884 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38885 }
38886
38887 #endif
38888 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38889 index af85299..ed9ac8d 100644
38890 --- a/drivers/gpu/drm/radeon/mkregtable.c
38891 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38892 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38893 regex_t mask_rex;
38894 regmatch_t match[4];
38895 char buf[1024];
38896 - size_t end;
38897 + long end;
38898 int len;
38899 int done = 0;
38900 int r;
38901 unsigned o;
38902 struct offset *offset;
38903 char last_reg_s[10];
38904 - int last_reg;
38905 + unsigned long last_reg;
38906
38907 if (regcomp
38908 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38909 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38910 index d15f27e..ef11ffc 100644
38911 --- a/drivers/gpu/drm/radeon/radeon_device.c
38912 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38913 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38914 bool can_switch;
38915
38916 spin_lock(&dev->count_lock);
38917 - can_switch = (dev->open_count == 0);
38918 + can_switch = (local_read(&dev->open_count) == 0);
38919 spin_unlock(&dev->count_lock);
38920 return can_switch;
38921 }
38922 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38923 index b369d42..8dd04eb 100644
38924 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38925 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38926 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38927
38928 /* SW interrupt */
38929 wait_queue_head_t swi_queue;
38930 - atomic_t swi_emitted;
38931 + atomic_unchecked_t swi_emitted;
38932 int vblank_crtc;
38933 uint32_t irq_enable_reg;
38934 uint32_t r500_disp_irq_reg;
38935 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38936 index c180df8..5fd8186 100644
38937 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38938 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38939 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38940 request = compat_alloc_user_space(sizeof(*request));
38941 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38942 || __put_user(req32.param, &request->param)
38943 - || __put_user((void __user *)(unsigned long)req32.value,
38944 + || __put_user((unsigned long)req32.value,
38945 &request->value))
38946 return -EFAULT;
38947
38948 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38949 #define compat_radeon_cp_setparam NULL
38950 #endif /* X86_64 || IA64 */
38951
38952 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38953 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38954 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38955 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38956 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38957 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38958 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38959 {
38960 unsigned int nr = DRM_IOCTL_NR(cmd);
38961 - drm_ioctl_compat_t *fn = NULL;
38962 int ret;
38963
38964 if (nr < DRM_COMMAND_BASE)
38965 return drm_compat_ioctl(filp, cmd, arg);
38966
38967 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38968 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38969 -
38970 - if (fn != NULL)
38971 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38972 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38973 ret = (*fn) (filp, cmd, arg);
38974 - else
38975 + } else
38976 ret = drm_ioctl(filp, cmd, arg);
38977
38978 return ret;
38979 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38980 index 8d68e97..9dcfed8 100644
38981 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38982 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38983 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38984 unsigned int ret;
38985 RING_LOCALS;
38986
38987 - atomic_inc(&dev_priv->swi_emitted);
38988 - ret = atomic_read(&dev_priv->swi_emitted);
38989 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38990 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38991
38992 BEGIN_RING(4);
38993 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38994 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38995 drm_radeon_private_t *dev_priv =
38996 (drm_radeon_private_t *) dev->dev_private;
38997
38998 - atomic_set(&dev_priv->swi_emitted, 0);
38999 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39000 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39001
39002 dev->max_vblank_count = 0x001fffff;
39003 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39004 index 4d20910..6726b6d 100644
39005 --- a/drivers/gpu/drm/radeon/radeon_state.c
39006 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39007 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39008 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39009 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39010
39011 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39012 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39013 sarea_priv->nbox * sizeof(depth_boxes[0])))
39014 return -EFAULT;
39015
39016 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39017 {
39018 drm_radeon_private_t *dev_priv = dev->dev_private;
39019 drm_radeon_getparam_t *param = data;
39020 - int value;
39021 + int value = 0;
39022
39023 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39024
39025 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39026 index 6c0ce89..57a2529 100644
39027 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39028 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39029 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39030 man->size = size >> PAGE_SHIFT;
39031 }
39032
39033 -static struct vm_operations_struct radeon_ttm_vm_ops;
39034 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39035 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39036
39037 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39038 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39039 }
39040 if (unlikely(ttm_vm_ops == NULL)) {
39041 ttm_vm_ops = vma->vm_ops;
39042 + pax_open_kernel();
39043 radeon_ttm_vm_ops = *ttm_vm_ops;
39044 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39045 + pax_close_kernel();
39046 }
39047 vma->vm_ops = &radeon_ttm_vm_ops;
39048 return 0;
39049 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39050 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39051 {
39052 #if defined(CONFIG_DEBUG_FS)
39053 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39054 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39055 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39056 + {
39057 + .name = "radeon_vram_mm",
39058 + .show = &radeon_mm_dump_table,
39059 + },
39060 + {
39061 + .name = "radeon_gtt_mm",
39062 + .show = &radeon_mm_dump_table,
39063 + },
39064 + {
39065 + .name = "ttm_page_pool",
39066 + .show = &ttm_page_alloc_debugfs,
39067 + },
39068 + {
39069 + .name = "ttm_dma_page_pool",
39070 + .show = &ttm_dma_page_alloc_debugfs,
39071 + },
39072 + };
39073 unsigned i;
39074
39075 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39076 - if (i == 0)
39077 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39078 - else
39079 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39080 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39081 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39082 - radeon_mem_types_list[i].driver_features = 0;
39083 - if (i == 0)
39084 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39085 - else
39086 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39087 -
39088 - }
39089 - /* Add ttm page pool to debugfs */
39090 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39091 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39092 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39093 - radeon_mem_types_list[i].driver_features = 0;
39094 - radeon_mem_types_list[i++].data = NULL;
39095 + pax_open_kernel();
39096 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39097 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39098 + pax_close_kernel();
39099 #ifdef CONFIG_SWIOTLB
39100 - if (swiotlb_nr_tbl()) {
39101 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39102 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39103 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39104 - radeon_mem_types_list[i].driver_features = 0;
39105 - radeon_mem_types_list[i++].data = NULL;
39106 - }
39107 + if (swiotlb_nr_tbl())
39108 + i++;
39109 #endif
39110 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39111
39112 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39113 index d8ddfb3..609de1d 100644
39114 --- a/drivers/gpu/drm/radeon/rs690.c
39115 +++ b/drivers/gpu/drm/radeon/rs690.c
39116 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39117 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39118 rdev->pm.sideport_bandwidth.full)
39119 max_bandwidth = rdev->pm.sideport_bandwidth;
39120 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39121 + read_delay_latency.full = dfixed_const(800 * 1000);
39122 read_delay_latency.full = dfixed_div(read_delay_latency,
39123 rdev->pm.igp_sideport_mclk);
39124 + a.full = dfixed_const(370);
39125 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39126 } else {
39127 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39128 rdev->pm.k8_bandwidth.full)
39129 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39130 index dbc2def..0a9f710 100644
39131 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39132 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39133 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39134 zone->glob = glob;
39135 glob->zone_kernel = zone;
39136 ret = kobject_init_and_add(
39137 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39138 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39139 if (unlikely(ret != 0)) {
39140 kobject_put(&zone->kobj);
39141 return ret;
39142 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39143 zone->glob = glob;
39144 glob->zone_dma32 = zone;
39145 ret = kobject_init_and_add(
39146 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39147 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39148 if (unlikely(ret != 0)) {
39149 kobject_put(&zone->kobj);
39150 return ret;
39151 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39152 index bd2a3b4..122d9ad 100644
39153 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39154 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39155 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39156 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39157 struct shrink_control *sc)
39158 {
39159 - static atomic_t start_pool = ATOMIC_INIT(0);
39160 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39161 unsigned i;
39162 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39163 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39164 struct ttm_page_pool *pool;
39165 int shrink_pages = sc->nr_to_scan;
39166
39167 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39168 index 97e9d61..bf23c461 100644
39169 --- a/drivers/gpu/drm/udl/udl_fb.c
39170 +++ b/drivers/gpu/drm/udl/udl_fb.c
39171 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39172 fb_deferred_io_cleanup(info);
39173 kfree(info->fbdefio);
39174 info->fbdefio = NULL;
39175 - info->fbops->fb_mmap = udl_fb_mmap;
39176 }
39177
39178 pr_warn("released /dev/fb%d user=%d count=%d\n",
39179 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39180 index 893a650..6190d3b 100644
39181 --- a/drivers/gpu/drm/via/via_drv.h
39182 +++ b/drivers/gpu/drm/via/via_drv.h
39183 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39184 typedef uint32_t maskarray_t[5];
39185
39186 typedef struct drm_via_irq {
39187 - atomic_t irq_received;
39188 + atomic_unchecked_t irq_received;
39189 uint32_t pending_mask;
39190 uint32_t enable_mask;
39191 wait_queue_head_t irq_queue;
39192 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39193 struct timeval last_vblank;
39194 int last_vblank_valid;
39195 unsigned usec_per_vblank;
39196 - atomic_t vbl_received;
39197 + atomic_unchecked_t vbl_received;
39198 drm_via_state_t hc_state;
39199 char pci_buf[VIA_PCI_BUF_SIZE];
39200 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39201 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39202 index ac98964..5dbf512 100644
39203 --- a/drivers/gpu/drm/via/via_irq.c
39204 +++ b/drivers/gpu/drm/via/via_irq.c
39205 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39206 if (crtc != 0)
39207 return 0;
39208
39209 - return atomic_read(&dev_priv->vbl_received);
39210 + return atomic_read_unchecked(&dev_priv->vbl_received);
39211 }
39212
39213 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39214 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39215
39216 status = VIA_READ(VIA_REG_INTERRUPT);
39217 if (status & VIA_IRQ_VBLANK_PENDING) {
39218 - atomic_inc(&dev_priv->vbl_received);
39219 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39220 + atomic_inc_unchecked(&dev_priv->vbl_received);
39221 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39222 do_gettimeofday(&cur_vblank);
39223 if (dev_priv->last_vblank_valid) {
39224 dev_priv->usec_per_vblank =
39225 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39226 dev_priv->last_vblank = cur_vblank;
39227 dev_priv->last_vblank_valid = 1;
39228 }
39229 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39230 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39231 DRM_DEBUG("US per vblank is: %u\n",
39232 dev_priv->usec_per_vblank);
39233 }
39234 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39235
39236 for (i = 0; i < dev_priv->num_irqs; ++i) {
39237 if (status & cur_irq->pending_mask) {
39238 - atomic_inc(&cur_irq->irq_received);
39239 + atomic_inc_unchecked(&cur_irq->irq_received);
39240 DRM_WAKEUP(&cur_irq->irq_queue);
39241 handled = 1;
39242 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39243 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39244 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39245 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39246 masks[irq][4]));
39247 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39248 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39249 } else {
39250 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39251 (((cur_irq_sequence =
39252 - atomic_read(&cur_irq->irq_received)) -
39253 + atomic_read_unchecked(&cur_irq->irq_received)) -
39254 *sequence) <= (1 << 23)));
39255 }
39256 *sequence = cur_irq_sequence;
39257 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39258 }
39259
39260 for (i = 0; i < dev_priv->num_irqs; ++i) {
39261 - atomic_set(&cur_irq->irq_received, 0);
39262 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39263 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39264 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39265 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39266 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39267 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39268 case VIA_IRQ_RELATIVE:
39269 irqwait->request.sequence +=
39270 - atomic_read(&cur_irq->irq_received);
39271 + atomic_read_unchecked(&cur_irq->irq_received);
39272 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39273 case VIA_IRQ_ABSOLUTE:
39274 break;
39275 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39276 index 13aeda7..4a952d1 100644
39277 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39278 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39279 @@ -290,7 +290,7 @@ struct vmw_private {
39280 * Fencing and IRQs.
39281 */
39282
39283 - atomic_t marker_seq;
39284 + atomic_unchecked_t marker_seq;
39285 wait_queue_head_t fence_queue;
39286 wait_queue_head_t fifo_queue;
39287 int fence_queue_waiters; /* Protected by hw_mutex */
39288 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39289 index 3eb1486..0a47ee9 100644
39290 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39291 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39292 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39293 (unsigned int) min,
39294 (unsigned int) fifo->capabilities);
39295
39296 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39297 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39298 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39299 vmw_marker_queue_init(&fifo->marker_queue);
39300 return vmw_fifo_send_fence(dev_priv, &dummy);
39301 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39302 if (reserveable)
39303 iowrite32(bytes, fifo_mem +
39304 SVGA_FIFO_RESERVED);
39305 - return fifo_mem + (next_cmd >> 2);
39306 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39307 } else {
39308 need_bounce = true;
39309 }
39310 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39311
39312 fm = vmw_fifo_reserve(dev_priv, bytes);
39313 if (unlikely(fm == NULL)) {
39314 - *seqno = atomic_read(&dev_priv->marker_seq);
39315 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39316 ret = -ENOMEM;
39317 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39318 false, 3*HZ);
39319 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39320 }
39321
39322 do {
39323 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39324 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39325 } while (*seqno == 0);
39326
39327 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39328 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39329 index c509d40..3b640c3 100644
39330 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39331 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39332 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39333 int ret;
39334
39335 num_clips = arg->num_clips;
39336 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39337 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39338
39339 if (unlikely(num_clips == 0))
39340 return 0;
39341 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39342 int ret;
39343
39344 num_clips = arg->num_clips;
39345 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39346 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39347
39348 if (unlikely(num_clips == 0))
39349 return 0;
39350 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39351 index 4640adb..e1384ed 100644
39352 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39353 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39354 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39355 * emitted. Then the fence is stale and signaled.
39356 */
39357
39358 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39359 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39360 > VMW_FENCE_WRAP);
39361
39362 return ret;
39363 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39364
39365 if (fifo_idle)
39366 down_read(&fifo_state->rwsem);
39367 - signal_seq = atomic_read(&dev_priv->marker_seq);
39368 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39369 ret = 0;
39370
39371 for (;;) {
39372 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39373 index 8a8725c2..afed796 100644
39374 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39375 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39376 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39377 while (!vmw_lag_lt(queue, us)) {
39378 spin_lock(&queue->lock);
39379 if (list_empty(&queue->head))
39380 - seqno = atomic_read(&dev_priv->marker_seq);
39381 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39382 else {
39383 marker = list_first_entry(&queue->head,
39384 struct vmw_marker, head);
39385 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39386 index 5360e5a..c2c0d26 100644
39387 --- a/drivers/gpu/host1x/drm/dc.c
39388 +++ b/drivers/gpu/host1x/drm/dc.c
39389 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39390 }
39391
39392 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39393 - dc->debugfs_files[i].data = dc;
39394 + *(void **)&dc->debugfs_files[i].data = dc;
39395
39396 err = drm_debugfs_create_files(dc->debugfs_files,
39397 ARRAY_SIZE(debugfs_files),
39398 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39399 index 15323da..8431ce9 100644
39400 --- a/drivers/hid/hid-core.c
39401 +++ b/drivers/hid/hid-core.c
39402 @@ -2371,7 +2371,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39403
39404 int hid_add_device(struct hid_device *hdev)
39405 {
39406 - static atomic_t id = ATOMIC_INIT(0);
39407 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39408 int ret;
39409
39410 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39411 @@ -2405,7 +2405,7 @@ int hid_add_device(struct hid_device *hdev)
39412 /* XXX hack, any other cleaner solution after the driver core
39413 * is converted to allow more than 20 bytes as the device name? */
39414 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39415 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39416 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39417
39418 hid_debug_register(hdev, dev_name(&hdev->dev));
39419 ret = device_add(&hdev->dev);
39420 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39421 index c13fb5b..55a3802 100644
39422 --- a/drivers/hid/hid-wiimote-debug.c
39423 +++ b/drivers/hid/hid-wiimote-debug.c
39424 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39425 else if (size == 0)
39426 return -EIO;
39427
39428 - if (copy_to_user(u, buf, size))
39429 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39430 return -EFAULT;
39431
39432 *off += size;
39433 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39434 index 145a4cb..2353a3e 100644
39435 --- a/drivers/hid/uhid.c
39436 +++ b/drivers/hid/uhid.c
39437 @@ -47,7 +47,7 @@ struct uhid_device {
39438 struct mutex report_lock;
39439 wait_queue_head_t report_wait;
39440 atomic_t report_done;
39441 - atomic_t report_id;
39442 + atomic_unchecked_t report_id;
39443 struct uhid_event report_buf;
39444 };
39445
39446 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39447
39448 spin_lock_irqsave(&uhid->qlock, flags);
39449 ev->type = UHID_FEATURE;
39450 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39451 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39452 ev->u.feature.rnum = rnum;
39453 ev->u.feature.rtype = report_type;
39454
39455 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39456 spin_lock_irqsave(&uhid->qlock, flags);
39457
39458 /* id for old report; drop it silently */
39459 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39460 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39461 goto unlock;
39462 if (atomic_read(&uhid->report_done))
39463 goto unlock;
39464 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39465 index 6de6c98..18319e9 100644
39466 --- a/drivers/hv/channel.c
39467 +++ b/drivers/hv/channel.c
39468 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39469 int ret = 0;
39470 int t;
39471
39472 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39473 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39474 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39475 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39476
39477 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39478 if (ret)
39479 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39480 index 88f4096..e50452e 100644
39481 --- a/drivers/hv/hv.c
39482 +++ b/drivers/hv/hv.c
39483 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39484 u64 output_address = (output) ? virt_to_phys(output) : 0;
39485 u32 output_address_hi = output_address >> 32;
39486 u32 output_address_lo = output_address & 0xFFFFFFFF;
39487 - void *hypercall_page = hv_context.hypercall_page;
39488 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39489
39490 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39491 "=a"(hv_status_lo) : "d" (control_hi),
39492 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39493 index deb5c25..ed2d4fd 100644
39494 --- a/drivers/hv/hv_balloon.c
39495 +++ b/drivers/hv/hv_balloon.c
39496 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39497
39498 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39499 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39500 -static atomic_t trans_id = ATOMIC_INIT(0);
39501 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39502
39503 static int dm_ring_size = (5 * PAGE_SIZE);
39504
39505 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39506 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39507 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39508 resp.hdr.size = sizeof(struct dm_hot_add_response);
39509 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39510 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39511
39512 #ifdef CONFIG_MEMORY_HOTPLUG
39513 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39514 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39515 memset(&status, 0, sizeof(struct dm_status));
39516 status.hdr.type = DM_STATUS_REPORT;
39517 status.hdr.size = sizeof(struct dm_status);
39518 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39519 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39520
39521 /*
39522 * The host expects the guest to report free memory.
39523 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39524 * send the status. This can happen if we were interrupted
39525 * after we picked our transaction ID.
39526 */
39527 - if (status.hdr.trans_id != atomic_read(&trans_id))
39528 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39529 return;
39530
39531 vmbus_sendpacket(dm->dev->channel, &status,
39532 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39533 bl_resp = (struct dm_balloon_response *)send_buffer;
39534 memset(send_buffer, 0, PAGE_SIZE);
39535 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39536 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39537 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39538 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39539 bl_resp->more_pages = 1;
39540
39541 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39542
39543 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39544 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39545 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39546 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39547 resp.hdr.size = sizeof(struct dm_unballoon_response);
39548
39549 vmbus_sendpacket(dm_device.dev->channel, &resp,
39550 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39551 memset(&version_req, 0, sizeof(struct dm_version_request));
39552 version_req.hdr.type = DM_VERSION_REQUEST;
39553 version_req.hdr.size = sizeof(struct dm_version_request);
39554 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39555 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39556 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39557 version_req.is_last_attempt = 1;
39558
39559 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39560 memset(&version_req, 0, sizeof(struct dm_version_request));
39561 version_req.hdr.type = DM_VERSION_REQUEST;
39562 version_req.hdr.size = sizeof(struct dm_version_request);
39563 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39564 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39565 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39566 version_req.is_last_attempt = 0;
39567
39568 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39569 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39570 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39571 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39572 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39573 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39574
39575 cap_msg.caps.cap_bits.balloon = 1;
39576 cap_msg.caps.cap_bits.hot_add = 1;
39577 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39578 index d84918f..7f38f9f 100644
39579 --- a/drivers/hv/hyperv_vmbus.h
39580 +++ b/drivers/hv/hyperv_vmbus.h
39581 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39582 struct vmbus_connection {
39583 enum vmbus_connect_state conn_state;
39584
39585 - atomic_t next_gpadl_handle;
39586 + atomic_unchecked_t next_gpadl_handle;
39587
39588 /*
39589 * Represents channel interrupts. Each bit position represents a
39590 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39591 index e8e071fc1..5b4b245 100644
39592 --- a/drivers/hv/vmbus_drv.c
39593 +++ b/drivers/hv/vmbus_drv.c
39594 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39595 {
39596 int ret = 0;
39597
39598 - static atomic_t device_num = ATOMIC_INIT(0);
39599 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39600
39601 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39602 - atomic_inc_return(&device_num));
39603 + atomic_inc_return_unchecked(&device_num));
39604
39605 child_device_obj->device.bus = &hv_bus;
39606 child_device_obj->device.parent = &hv_acpi_dev->dev;
39607 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39608 index 6351aba..dc4aaf4 100644
39609 --- a/drivers/hwmon/acpi_power_meter.c
39610 +++ b/drivers/hwmon/acpi_power_meter.c
39611 @@ -117,7 +117,7 @@ struct sensor_template {
39612 struct device_attribute *devattr,
39613 const char *buf, size_t count);
39614 int index;
39615 -};
39616 +} __do_const;
39617
39618 /* Averaging interval */
39619 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39620 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39621 struct sensor_template *attrs)
39622 {
39623 struct device *dev = &resource->acpi_dev->dev;
39624 - struct sensor_device_attribute *sensors =
39625 + sensor_device_attribute_no_const *sensors =
39626 &resource->sensors[resource->num_sensors];
39627 int res = 0;
39628
39629 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39630 index 3288f13..71cfb4e 100644
39631 --- a/drivers/hwmon/applesmc.c
39632 +++ b/drivers/hwmon/applesmc.c
39633 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39634 {
39635 struct applesmc_node_group *grp;
39636 struct applesmc_dev_attr *node;
39637 - struct attribute *attr;
39638 + attribute_no_const *attr;
39639 int ret, i;
39640
39641 for (grp = groups; grp->format; grp++) {
39642 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39643 index b25c643..a13460d 100644
39644 --- a/drivers/hwmon/asus_atk0110.c
39645 +++ b/drivers/hwmon/asus_atk0110.c
39646 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39647 struct atk_sensor_data {
39648 struct list_head list;
39649 struct atk_data *data;
39650 - struct device_attribute label_attr;
39651 - struct device_attribute input_attr;
39652 - struct device_attribute limit1_attr;
39653 - struct device_attribute limit2_attr;
39654 + device_attribute_no_const label_attr;
39655 + device_attribute_no_const input_attr;
39656 + device_attribute_no_const limit1_attr;
39657 + device_attribute_no_const limit2_attr;
39658 char label_attr_name[ATTR_NAME_SIZE];
39659 char input_attr_name[ATTR_NAME_SIZE];
39660 char limit1_attr_name[ATTR_NAME_SIZE];
39661 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39662 static struct device_attribute atk_name_attr =
39663 __ATTR(name, 0444, atk_name_show, NULL);
39664
39665 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39666 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39667 sysfs_show_func show)
39668 {
39669 sysfs_attr_init(&attr->attr);
39670 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39671 index 2e5e2dc..5208b31 100644
39672 --- a/drivers/hwmon/coretemp.c
39673 +++ b/drivers/hwmon/coretemp.c
39674 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39675 return NOTIFY_OK;
39676 }
39677
39678 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39679 +static struct notifier_block coretemp_cpu_notifier = {
39680 .notifier_call = coretemp_cpu_callback,
39681 };
39682
39683 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39684 index 1429f6e..ee03d59 100644
39685 --- a/drivers/hwmon/ibmaem.c
39686 +++ b/drivers/hwmon/ibmaem.c
39687 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39688 struct aem_rw_sensor_template *rw)
39689 {
39690 struct device *dev = &data->pdev->dev;
39691 - struct sensor_device_attribute *sensors = data->sensors;
39692 + sensor_device_attribute_no_const *sensors = data->sensors;
39693 int err;
39694
39695 /* Set up read-only sensors */
39696 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39697 index 708081b..fe2d4ab 100644
39698 --- a/drivers/hwmon/iio_hwmon.c
39699 +++ b/drivers/hwmon/iio_hwmon.c
39700 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39701 {
39702 struct device *dev = &pdev->dev;
39703 struct iio_hwmon_state *st;
39704 - struct sensor_device_attribute *a;
39705 + sensor_device_attribute_no_const *a;
39706 int ret, i;
39707 int in_i = 1, temp_i = 1, curr_i = 1;
39708 enum iio_chan_type type;
39709 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39710 index 9add6092..ee7ba3f 100644
39711 --- a/drivers/hwmon/pmbus/pmbus_core.c
39712 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39713 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39714 return 0;
39715 }
39716
39717 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39718 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39719 const char *name,
39720 umode_t mode,
39721 ssize_t (*show)(struct device *dev,
39722 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39723 dev_attr->store = store;
39724 }
39725
39726 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39727 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39728 const char *name,
39729 umode_t mode,
39730 ssize_t (*show)(struct device *dev,
39731 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39732 u16 reg, u8 mask)
39733 {
39734 struct pmbus_boolean *boolean;
39735 - struct sensor_device_attribute *a;
39736 + sensor_device_attribute_no_const *a;
39737
39738 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39739 if (!boolean)
39740 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39741 bool update, bool readonly)
39742 {
39743 struct pmbus_sensor *sensor;
39744 - struct device_attribute *a;
39745 + device_attribute_no_const *a;
39746
39747 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39748 if (!sensor)
39749 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39750 const char *lstring, int index)
39751 {
39752 struct pmbus_label *label;
39753 - struct device_attribute *a;
39754 + device_attribute_no_const *a;
39755
39756 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39757 if (!label)
39758 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39759 index 2507f90..1645765 100644
39760 --- a/drivers/hwmon/sht15.c
39761 +++ b/drivers/hwmon/sht15.c
39762 @@ -169,7 +169,7 @@ struct sht15_data {
39763 int supply_uv;
39764 bool supply_uv_valid;
39765 struct work_struct update_supply_work;
39766 - atomic_t interrupt_handled;
39767 + atomic_unchecked_t interrupt_handled;
39768 };
39769
39770 /**
39771 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39772 ret = gpio_direction_input(data->pdata->gpio_data);
39773 if (ret)
39774 return ret;
39775 - atomic_set(&data->interrupt_handled, 0);
39776 + atomic_set_unchecked(&data->interrupt_handled, 0);
39777
39778 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39779 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39780 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39781 /* Only relevant if the interrupt hasn't occurred. */
39782 - if (!atomic_read(&data->interrupt_handled))
39783 + if (!atomic_read_unchecked(&data->interrupt_handled))
39784 schedule_work(&data->read_work);
39785 }
39786 ret = wait_event_timeout(data->wait_queue,
39787 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39788
39789 /* First disable the interrupt */
39790 disable_irq_nosync(irq);
39791 - atomic_inc(&data->interrupt_handled);
39792 + atomic_inc_unchecked(&data->interrupt_handled);
39793 /* Then schedule a reading work struct */
39794 if (data->state != SHT15_READING_NOTHING)
39795 schedule_work(&data->read_work);
39796 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39797 * If not, then start the interrupt again - care here as could
39798 * have gone low in meantime so verify it hasn't!
39799 */
39800 - atomic_set(&data->interrupt_handled, 0);
39801 + atomic_set_unchecked(&data->interrupt_handled, 0);
39802 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39803 /* If still not occurred or another handler was scheduled */
39804 if (gpio_get_value(data->pdata->gpio_data)
39805 - || atomic_read(&data->interrupt_handled))
39806 + || atomic_read_unchecked(&data->interrupt_handled))
39807 return;
39808 }
39809
39810 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39811 index 38944e9..ae9e5ed 100644
39812 --- a/drivers/hwmon/via-cputemp.c
39813 +++ b/drivers/hwmon/via-cputemp.c
39814 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39815 return NOTIFY_OK;
39816 }
39817
39818 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39819 +static struct notifier_block via_cputemp_cpu_notifier = {
39820 .notifier_call = via_cputemp_cpu_callback,
39821 };
39822
39823 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39824 index 07f01ac..d79ad3d 100644
39825 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39826 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39827 @@ -43,7 +43,7 @@
39828 extern struct i2c_adapter amd756_smbus;
39829
39830 static struct i2c_adapter *s4882_adapter;
39831 -static struct i2c_algorithm *s4882_algo;
39832 +static i2c_algorithm_no_const *s4882_algo;
39833
39834 /* Wrapper access functions for multiplexed SMBus */
39835 static DEFINE_MUTEX(amd756_lock);
39836 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39837 index 2ca268d..c6acbdf 100644
39838 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39839 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39840 @@ -41,7 +41,7 @@
39841 extern struct i2c_adapter *nforce2_smbus;
39842
39843 static struct i2c_adapter *s4985_adapter;
39844 -static struct i2c_algorithm *s4985_algo;
39845 +static i2c_algorithm_no_const *s4985_algo;
39846
39847 /* Wrapper access functions for multiplexed SMBus */
39848 static DEFINE_MUTEX(nforce2_lock);
39849 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39850 index c3ccdea..5b3dc1a 100644
39851 --- a/drivers/i2c/i2c-dev.c
39852 +++ b/drivers/i2c/i2c-dev.c
39853 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39854 break;
39855 }
39856
39857 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39858 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39859 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39860 if (IS_ERR(rdwr_pa[i].buf)) {
39861 res = PTR_ERR(rdwr_pa[i].buf);
39862 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
39863 index 0b510ba..4fbb5085 100644
39864 --- a/drivers/ide/ide-cd.c
39865 +++ b/drivers/ide/ide-cd.c
39866 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
39867 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
39868 if ((unsigned long)buf & alignment
39869 || blk_rq_bytes(rq) & q->dma_pad_mask
39870 - || object_is_on_stack(buf))
39871 + || object_starts_on_stack(buf))
39872 drive->dma = 0;
39873 }
39874 }
39875 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
39876 index e145931..08bfc59 100644
39877 --- a/drivers/iio/industrialio-core.c
39878 +++ b/drivers/iio/industrialio-core.c
39879 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
39880 }
39881
39882 static
39883 -int __iio_device_attr_init(struct device_attribute *dev_attr,
39884 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
39885 const char *postfix,
39886 struct iio_chan_spec const *chan,
39887 ssize_t (*readfunc)(struct device *dev,
39888 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
39889 index 784b97c..c9ceadf 100644
39890 --- a/drivers/infiniband/core/cm.c
39891 +++ b/drivers/infiniband/core/cm.c
39892 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
39893
39894 struct cm_counter_group {
39895 struct kobject obj;
39896 - atomic_long_t counter[CM_ATTR_COUNT];
39897 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
39898 };
39899
39900 struct cm_counter_attribute {
39901 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
39902 struct ib_mad_send_buf *msg = NULL;
39903 int ret;
39904
39905 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39906 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39907 counter[CM_REQ_COUNTER]);
39908
39909 /* Quick state check to discard duplicate REQs. */
39910 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
39911 if (!cm_id_priv)
39912 return;
39913
39914 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39915 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39916 counter[CM_REP_COUNTER]);
39917 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
39918 if (ret)
39919 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
39920 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
39921 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
39922 spin_unlock_irq(&cm_id_priv->lock);
39923 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39924 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39925 counter[CM_RTU_COUNTER]);
39926 goto out;
39927 }
39928 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
39929 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
39930 dreq_msg->local_comm_id);
39931 if (!cm_id_priv) {
39932 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39933 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39934 counter[CM_DREQ_COUNTER]);
39935 cm_issue_drep(work->port, work->mad_recv_wc);
39936 return -EINVAL;
39937 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
39938 case IB_CM_MRA_REP_RCVD:
39939 break;
39940 case IB_CM_TIMEWAIT:
39941 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39942 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39943 counter[CM_DREQ_COUNTER]);
39944 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39945 goto unlock;
39946 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
39947 cm_free_msg(msg);
39948 goto deref;
39949 case IB_CM_DREQ_RCVD:
39950 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39951 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39952 counter[CM_DREQ_COUNTER]);
39953 goto unlock;
39954 default:
39955 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
39956 ib_modify_mad(cm_id_priv->av.port->mad_agent,
39957 cm_id_priv->msg, timeout)) {
39958 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
39959 - atomic_long_inc(&work->port->
39960 + atomic_long_inc_unchecked(&work->port->
39961 counter_group[CM_RECV_DUPLICATES].
39962 counter[CM_MRA_COUNTER]);
39963 goto out;
39964 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
39965 break;
39966 case IB_CM_MRA_REQ_RCVD:
39967 case IB_CM_MRA_REP_RCVD:
39968 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39969 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39970 counter[CM_MRA_COUNTER]);
39971 /* fall through */
39972 default:
39973 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
39974 case IB_CM_LAP_IDLE:
39975 break;
39976 case IB_CM_MRA_LAP_SENT:
39977 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39978 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39979 counter[CM_LAP_COUNTER]);
39980 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39981 goto unlock;
39982 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
39983 cm_free_msg(msg);
39984 goto deref;
39985 case IB_CM_LAP_RCVD:
39986 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39987 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39988 counter[CM_LAP_COUNTER]);
39989 goto unlock;
39990 default:
39991 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
39992 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
39993 if (cur_cm_id_priv) {
39994 spin_unlock_irq(&cm.lock);
39995 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39996 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39997 counter[CM_SIDR_REQ_COUNTER]);
39998 goto out; /* Duplicate message. */
39999 }
40000 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40001 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40002 msg->retries = 1;
40003
40004 - atomic_long_add(1 + msg->retries,
40005 + atomic_long_add_unchecked(1 + msg->retries,
40006 &port->counter_group[CM_XMIT].counter[attr_index]);
40007 if (msg->retries)
40008 - atomic_long_add(msg->retries,
40009 + atomic_long_add_unchecked(msg->retries,
40010 &port->counter_group[CM_XMIT_RETRIES].
40011 counter[attr_index]);
40012
40013 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40014 }
40015
40016 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40017 - atomic_long_inc(&port->counter_group[CM_RECV].
40018 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40019 counter[attr_id - CM_ATTR_ID_OFFSET]);
40020
40021 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40022 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40023 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40024
40025 return sprintf(buf, "%ld\n",
40026 - atomic_long_read(&group->counter[cm_attr->index]));
40027 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40028 }
40029
40030 static const struct sysfs_ops cm_counter_ops = {
40031 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40032 index 9f5ad7c..588cd84 100644
40033 --- a/drivers/infiniband/core/fmr_pool.c
40034 +++ b/drivers/infiniband/core/fmr_pool.c
40035 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40036
40037 struct task_struct *thread;
40038
40039 - atomic_t req_ser;
40040 - atomic_t flush_ser;
40041 + atomic_unchecked_t req_ser;
40042 + atomic_unchecked_t flush_ser;
40043
40044 wait_queue_head_t force_wait;
40045 };
40046 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40047 struct ib_fmr_pool *pool = pool_ptr;
40048
40049 do {
40050 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40051 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40052 ib_fmr_batch_release(pool);
40053
40054 - atomic_inc(&pool->flush_ser);
40055 + atomic_inc_unchecked(&pool->flush_ser);
40056 wake_up_interruptible(&pool->force_wait);
40057
40058 if (pool->flush_function)
40059 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40060 }
40061
40062 set_current_state(TASK_INTERRUPTIBLE);
40063 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40064 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40065 !kthread_should_stop())
40066 schedule();
40067 __set_current_state(TASK_RUNNING);
40068 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40069 pool->dirty_watermark = params->dirty_watermark;
40070 pool->dirty_len = 0;
40071 spin_lock_init(&pool->pool_lock);
40072 - atomic_set(&pool->req_ser, 0);
40073 - atomic_set(&pool->flush_ser, 0);
40074 + atomic_set_unchecked(&pool->req_ser, 0);
40075 + atomic_set_unchecked(&pool->flush_ser, 0);
40076 init_waitqueue_head(&pool->force_wait);
40077
40078 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40079 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40080 }
40081 spin_unlock_irq(&pool->pool_lock);
40082
40083 - serial = atomic_inc_return(&pool->req_ser);
40084 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40085 wake_up_process(pool->thread);
40086
40087 if (wait_event_interruptible(pool->force_wait,
40088 - atomic_read(&pool->flush_ser) - serial >= 0))
40089 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40090 return -EINTR;
40091
40092 return 0;
40093 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40094 } else {
40095 list_add_tail(&fmr->list, &pool->dirty_list);
40096 if (++pool->dirty_len >= pool->dirty_watermark) {
40097 - atomic_inc(&pool->req_ser);
40098 + atomic_inc_unchecked(&pool->req_ser);
40099 wake_up_process(pool->thread);
40100 }
40101 }
40102 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40103 index 4cb8eb2..146bf60 100644
40104 --- a/drivers/infiniband/hw/cxgb4/mem.c
40105 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40106 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40107 int err;
40108 struct fw_ri_tpte tpt;
40109 u32 stag_idx;
40110 - static atomic_t key;
40111 + static atomic_unchecked_t key;
40112
40113 if (c4iw_fatal_error(rdev))
40114 return -EIO;
40115 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40116 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40117 rdev->stats.stag.max = rdev->stats.stag.cur;
40118 mutex_unlock(&rdev->stats.lock);
40119 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40120 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40121 }
40122 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40123 __func__, stag_state, type, pdid, stag_idx);
40124 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40125 index 79b3dbc..96e5fcc 100644
40126 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40127 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40128 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40129 struct ib_atomic_eth *ateth;
40130 struct ipath_ack_entry *e;
40131 u64 vaddr;
40132 - atomic64_t *maddr;
40133 + atomic64_unchecked_t *maddr;
40134 u64 sdata;
40135 u32 rkey;
40136 u8 next;
40137 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40138 IB_ACCESS_REMOTE_ATOMIC)))
40139 goto nack_acc_unlck;
40140 /* Perform atomic OP and save result. */
40141 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40142 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40143 sdata = be64_to_cpu(ateth->swap_data);
40144 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40145 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40146 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40147 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40148 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40149 be64_to_cpu(ateth->compare_data),
40150 sdata);
40151 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40152 index 1f95bba..9530f87 100644
40153 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40154 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40155 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40156 unsigned long flags;
40157 struct ib_wc wc;
40158 u64 sdata;
40159 - atomic64_t *maddr;
40160 + atomic64_unchecked_t *maddr;
40161 enum ib_wc_status send_status;
40162
40163 /*
40164 @@ -382,11 +382,11 @@ again:
40165 IB_ACCESS_REMOTE_ATOMIC)))
40166 goto acc_err;
40167 /* Perform atomic OP and save result. */
40168 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40169 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40170 sdata = wqe->wr.wr.atomic.compare_add;
40171 *(u64 *) sqp->s_sge.sge.vaddr =
40172 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40173 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40174 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40175 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40176 sdata, wqe->wr.wr.atomic.swap);
40177 goto send_comp;
40178 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40179 index f2a3f48..673ec79 100644
40180 --- a/drivers/infiniband/hw/mlx4/mad.c
40181 +++ b/drivers/infiniband/hw/mlx4/mad.c
40182 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40183
40184 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40185 {
40186 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40187 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40188 cpu_to_be64(0xff00000000000000LL);
40189 }
40190
40191 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40192 index 25b2cdf..099ff97 100644
40193 --- a/drivers/infiniband/hw/mlx4/mcg.c
40194 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40195 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40196 {
40197 char name[20];
40198
40199 - atomic_set(&ctx->tid, 0);
40200 + atomic_set_unchecked(&ctx->tid, 0);
40201 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40202 ctx->mcg_wq = create_singlethread_workqueue(name);
40203 if (!ctx->mcg_wq)
40204 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40205 index f61ec26..ebf72cf 100644
40206 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40207 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40208 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40209 struct list_head mcg_mgid0_list;
40210 struct workqueue_struct *mcg_wq;
40211 struct mlx4_ib_demux_pv_ctx **tun;
40212 - atomic_t tid;
40213 + atomic_unchecked_t tid;
40214 int flushing; /* flushing the work queue */
40215 };
40216
40217 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40218 index 9d3e5c1..d9afe4a 100644
40219 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40220 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40221 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40222 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40223 }
40224
40225 -int mthca_QUERY_FW(struct mthca_dev *dev)
40226 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40227 {
40228 struct mthca_mailbox *mailbox;
40229 u32 *outbox;
40230 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40231 index ed9a989..e0c5871 100644
40232 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40233 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40234 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40235 return key;
40236 }
40237
40238 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40239 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40240 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40241 {
40242 struct mthca_mailbox *mailbox;
40243 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40244 index 4291410..d2ab1fb 100644
40245 --- a/drivers/infiniband/hw/nes/nes.c
40246 +++ b/drivers/infiniband/hw/nes/nes.c
40247 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40248 LIST_HEAD(nes_adapter_list);
40249 static LIST_HEAD(nes_dev_list);
40250
40251 -atomic_t qps_destroyed;
40252 +atomic_unchecked_t qps_destroyed;
40253
40254 static unsigned int ee_flsh_adapter;
40255 static unsigned int sysfs_nonidx_addr;
40256 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40257 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40258 struct nes_adapter *nesadapter = nesdev->nesadapter;
40259
40260 - atomic_inc(&qps_destroyed);
40261 + atomic_inc_unchecked(&qps_destroyed);
40262
40263 /* Free the control structures */
40264
40265 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40266 index 33cc589..3bd6538 100644
40267 --- a/drivers/infiniband/hw/nes/nes.h
40268 +++ b/drivers/infiniband/hw/nes/nes.h
40269 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40270 extern unsigned int wqm_quanta;
40271 extern struct list_head nes_adapter_list;
40272
40273 -extern atomic_t cm_connects;
40274 -extern atomic_t cm_accepts;
40275 -extern atomic_t cm_disconnects;
40276 -extern atomic_t cm_closes;
40277 -extern atomic_t cm_connecteds;
40278 -extern atomic_t cm_connect_reqs;
40279 -extern atomic_t cm_rejects;
40280 -extern atomic_t mod_qp_timouts;
40281 -extern atomic_t qps_created;
40282 -extern atomic_t qps_destroyed;
40283 -extern atomic_t sw_qps_destroyed;
40284 +extern atomic_unchecked_t cm_connects;
40285 +extern atomic_unchecked_t cm_accepts;
40286 +extern atomic_unchecked_t cm_disconnects;
40287 +extern atomic_unchecked_t cm_closes;
40288 +extern atomic_unchecked_t cm_connecteds;
40289 +extern atomic_unchecked_t cm_connect_reqs;
40290 +extern atomic_unchecked_t cm_rejects;
40291 +extern atomic_unchecked_t mod_qp_timouts;
40292 +extern atomic_unchecked_t qps_created;
40293 +extern atomic_unchecked_t qps_destroyed;
40294 +extern atomic_unchecked_t sw_qps_destroyed;
40295 extern u32 mh_detected;
40296 extern u32 mh_pauses_sent;
40297 extern u32 cm_packets_sent;
40298 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40299 extern u32 cm_packets_received;
40300 extern u32 cm_packets_dropped;
40301 extern u32 cm_packets_retrans;
40302 -extern atomic_t cm_listens_created;
40303 -extern atomic_t cm_listens_destroyed;
40304 +extern atomic_unchecked_t cm_listens_created;
40305 +extern atomic_unchecked_t cm_listens_destroyed;
40306 extern u32 cm_backlog_drops;
40307 -extern atomic_t cm_loopbacks;
40308 -extern atomic_t cm_nodes_created;
40309 -extern atomic_t cm_nodes_destroyed;
40310 -extern atomic_t cm_accel_dropped_pkts;
40311 -extern atomic_t cm_resets_recvd;
40312 -extern atomic_t pau_qps_created;
40313 -extern atomic_t pau_qps_destroyed;
40314 +extern atomic_unchecked_t cm_loopbacks;
40315 +extern atomic_unchecked_t cm_nodes_created;
40316 +extern atomic_unchecked_t cm_nodes_destroyed;
40317 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40318 +extern atomic_unchecked_t cm_resets_recvd;
40319 +extern atomic_unchecked_t pau_qps_created;
40320 +extern atomic_unchecked_t pau_qps_destroyed;
40321
40322 extern u32 int_mod_timer_init;
40323 extern u32 int_mod_cq_depth_256;
40324 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40325 index 24b9f1a..00fd004 100644
40326 --- a/drivers/infiniband/hw/nes/nes_cm.c
40327 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40328 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40329 u32 cm_packets_retrans;
40330 u32 cm_packets_created;
40331 u32 cm_packets_received;
40332 -atomic_t cm_listens_created;
40333 -atomic_t cm_listens_destroyed;
40334 +atomic_unchecked_t cm_listens_created;
40335 +atomic_unchecked_t cm_listens_destroyed;
40336 u32 cm_backlog_drops;
40337 -atomic_t cm_loopbacks;
40338 -atomic_t cm_nodes_created;
40339 -atomic_t cm_nodes_destroyed;
40340 -atomic_t cm_accel_dropped_pkts;
40341 -atomic_t cm_resets_recvd;
40342 +atomic_unchecked_t cm_loopbacks;
40343 +atomic_unchecked_t cm_nodes_created;
40344 +atomic_unchecked_t cm_nodes_destroyed;
40345 +atomic_unchecked_t cm_accel_dropped_pkts;
40346 +atomic_unchecked_t cm_resets_recvd;
40347
40348 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40349 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40350 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40351
40352 static struct nes_cm_core *g_cm_core;
40353
40354 -atomic_t cm_connects;
40355 -atomic_t cm_accepts;
40356 -atomic_t cm_disconnects;
40357 -atomic_t cm_closes;
40358 -atomic_t cm_connecteds;
40359 -atomic_t cm_connect_reqs;
40360 -atomic_t cm_rejects;
40361 +atomic_unchecked_t cm_connects;
40362 +atomic_unchecked_t cm_accepts;
40363 +atomic_unchecked_t cm_disconnects;
40364 +atomic_unchecked_t cm_closes;
40365 +atomic_unchecked_t cm_connecteds;
40366 +atomic_unchecked_t cm_connect_reqs;
40367 +atomic_unchecked_t cm_rejects;
40368
40369 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40370 {
40371 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40372 kfree(listener);
40373 listener = NULL;
40374 ret = 0;
40375 - atomic_inc(&cm_listens_destroyed);
40376 + atomic_inc_unchecked(&cm_listens_destroyed);
40377 } else {
40378 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40379 }
40380 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40381 cm_node->rem_mac);
40382
40383 add_hte_node(cm_core, cm_node);
40384 - atomic_inc(&cm_nodes_created);
40385 + atomic_inc_unchecked(&cm_nodes_created);
40386
40387 return cm_node;
40388 }
40389 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40390 }
40391
40392 atomic_dec(&cm_core->node_cnt);
40393 - atomic_inc(&cm_nodes_destroyed);
40394 + atomic_inc_unchecked(&cm_nodes_destroyed);
40395 nesqp = cm_node->nesqp;
40396 if (nesqp) {
40397 nesqp->cm_node = NULL;
40398 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40399
40400 static void drop_packet(struct sk_buff *skb)
40401 {
40402 - atomic_inc(&cm_accel_dropped_pkts);
40403 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40404 dev_kfree_skb_any(skb);
40405 }
40406
40407 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40408 {
40409
40410 int reset = 0; /* whether to send reset in case of err.. */
40411 - atomic_inc(&cm_resets_recvd);
40412 + atomic_inc_unchecked(&cm_resets_recvd);
40413 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40414 " refcnt=%d\n", cm_node, cm_node->state,
40415 atomic_read(&cm_node->ref_count));
40416 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40417 rem_ref_cm_node(cm_node->cm_core, cm_node);
40418 return NULL;
40419 }
40420 - atomic_inc(&cm_loopbacks);
40421 + atomic_inc_unchecked(&cm_loopbacks);
40422 loopbackremotenode->loopbackpartner = cm_node;
40423 loopbackremotenode->tcp_cntxt.rcv_wscale =
40424 NES_CM_DEFAULT_RCV_WND_SCALE;
40425 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40426 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40427 else {
40428 rem_ref_cm_node(cm_core, cm_node);
40429 - atomic_inc(&cm_accel_dropped_pkts);
40430 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40431 dev_kfree_skb_any(skb);
40432 }
40433 break;
40434 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40435
40436 if ((cm_id) && (cm_id->event_handler)) {
40437 if (issue_disconn) {
40438 - atomic_inc(&cm_disconnects);
40439 + atomic_inc_unchecked(&cm_disconnects);
40440 cm_event.event = IW_CM_EVENT_DISCONNECT;
40441 cm_event.status = disconn_status;
40442 cm_event.local_addr = cm_id->local_addr;
40443 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40444 }
40445
40446 if (issue_close) {
40447 - atomic_inc(&cm_closes);
40448 + atomic_inc_unchecked(&cm_closes);
40449 nes_disconnect(nesqp, 1);
40450
40451 cm_id->provider_data = nesqp;
40452 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40453
40454 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40455 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40456 - atomic_inc(&cm_accepts);
40457 + atomic_inc_unchecked(&cm_accepts);
40458
40459 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40460 netdev_refcnt_read(nesvnic->netdev));
40461 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40462 struct nes_cm_core *cm_core;
40463 u8 *start_buff;
40464
40465 - atomic_inc(&cm_rejects);
40466 + atomic_inc_unchecked(&cm_rejects);
40467 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40468 loopback = cm_node->loopbackpartner;
40469 cm_core = cm_node->cm_core;
40470 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40471 ntohl(cm_id->local_addr.sin_addr.s_addr),
40472 ntohs(cm_id->local_addr.sin_port));
40473
40474 - atomic_inc(&cm_connects);
40475 + atomic_inc_unchecked(&cm_connects);
40476 nesqp->active_conn = 1;
40477
40478 /* cache the cm_id in the qp */
40479 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40480 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40481 return err;
40482 }
40483 - atomic_inc(&cm_listens_created);
40484 + atomic_inc_unchecked(&cm_listens_created);
40485 }
40486
40487 cm_id->add_ref(cm_id);
40488 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40489
40490 if (nesqp->destroyed)
40491 return;
40492 - atomic_inc(&cm_connecteds);
40493 + atomic_inc_unchecked(&cm_connecteds);
40494 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40495 " local port 0x%04X. jiffies = %lu.\n",
40496 nesqp->hwqp.qp_id,
40497 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40498
40499 cm_id->add_ref(cm_id);
40500 ret = cm_id->event_handler(cm_id, &cm_event);
40501 - atomic_inc(&cm_closes);
40502 + atomic_inc_unchecked(&cm_closes);
40503 cm_event.event = IW_CM_EVENT_CLOSE;
40504 cm_event.status = 0;
40505 cm_event.provider_data = cm_id->provider_data;
40506 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40507 return;
40508 cm_id = cm_node->cm_id;
40509
40510 - atomic_inc(&cm_connect_reqs);
40511 + atomic_inc_unchecked(&cm_connect_reqs);
40512 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40513 cm_node, cm_id, jiffies);
40514
40515 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40516 return;
40517 cm_id = cm_node->cm_id;
40518
40519 - atomic_inc(&cm_connect_reqs);
40520 + atomic_inc_unchecked(&cm_connect_reqs);
40521 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40522 cm_node, cm_id, jiffies);
40523
40524 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40525 index 4166452..fc952c3 100644
40526 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40527 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40528 @@ -40,8 +40,8 @@
40529 #include "nes.h"
40530 #include "nes_mgt.h"
40531
40532 -atomic_t pau_qps_created;
40533 -atomic_t pau_qps_destroyed;
40534 +atomic_unchecked_t pau_qps_created;
40535 +atomic_unchecked_t pau_qps_destroyed;
40536
40537 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40538 {
40539 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40540 {
40541 struct sk_buff *skb;
40542 unsigned long flags;
40543 - atomic_inc(&pau_qps_destroyed);
40544 + atomic_inc_unchecked(&pau_qps_destroyed);
40545
40546 /* Free packets that have not yet been forwarded */
40547 /* Lock is acquired by skb_dequeue when removing the skb */
40548 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40549 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40550 skb_queue_head_init(&nesqp->pau_list);
40551 spin_lock_init(&nesqp->pau_lock);
40552 - atomic_inc(&pau_qps_created);
40553 + atomic_inc_unchecked(&pau_qps_created);
40554 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40555 }
40556
40557 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40558 index 49eb511..a774366 100644
40559 --- a/drivers/infiniband/hw/nes/nes_nic.c
40560 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40561 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40562 target_stat_values[++index] = mh_detected;
40563 target_stat_values[++index] = mh_pauses_sent;
40564 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40565 - target_stat_values[++index] = atomic_read(&cm_connects);
40566 - target_stat_values[++index] = atomic_read(&cm_accepts);
40567 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40568 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40569 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40570 - target_stat_values[++index] = atomic_read(&cm_rejects);
40571 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40572 - target_stat_values[++index] = atomic_read(&qps_created);
40573 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40574 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40575 - target_stat_values[++index] = atomic_read(&cm_closes);
40576 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40577 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40578 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40579 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40580 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40581 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40582 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40583 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40584 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40585 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40586 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40587 target_stat_values[++index] = cm_packets_sent;
40588 target_stat_values[++index] = cm_packets_bounced;
40589 target_stat_values[++index] = cm_packets_created;
40590 target_stat_values[++index] = cm_packets_received;
40591 target_stat_values[++index] = cm_packets_dropped;
40592 target_stat_values[++index] = cm_packets_retrans;
40593 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40594 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40595 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40596 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40597 target_stat_values[++index] = cm_backlog_drops;
40598 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40599 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40600 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40601 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40602 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40603 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40604 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40605 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40606 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40607 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40608 target_stat_values[++index] = nesadapter->free_4kpbl;
40609 target_stat_values[++index] = nesadapter->free_256pbl;
40610 target_stat_values[++index] = int_mod_timer_init;
40611 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40612 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40613 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40614 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40615 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40616 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40617 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40618 }
40619
40620 /**
40621 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40622 index 5b53ca5..443da3c 100644
40623 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40624 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40625 @@ -46,9 +46,9 @@
40626
40627 #include <rdma/ib_umem.h>
40628
40629 -atomic_t mod_qp_timouts;
40630 -atomic_t qps_created;
40631 -atomic_t sw_qps_destroyed;
40632 +atomic_unchecked_t mod_qp_timouts;
40633 +atomic_unchecked_t qps_created;
40634 +atomic_unchecked_t sw_qps_destroyed;
40635
40636 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40637
40638 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40639 if (init_attr->create_flags)
40640 return ERR_PTR(-EINVAL);
40641
40642 - atomic_inc(&qps_created);
40643 + atomic_inc_unchecked(&qps_created);
40644 switch (init_attr->qp_type) {
40645 case IB_QPT_RC:
40646 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40647 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40648 struct iw_cm_event cm_event;
40649 int ret = 0;
40650
40651 - atomic_inc(&sw_qps_destroyed);
40652 + atomic_inc_unchecked(&sw_qps_destroyed);
40653 nesqp->destroyed = 1;
40654
40655 /* Blow away the connection if it exists. */
40656 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40657 index 4a9af79..b993f75 100644
40658 --- a/drivers/infiniband/hw/qib/qib.h
40659 +++ b/drivers/infiniband/hw/qib/qib.h
40660 @@ -52,6 +52,7 @@
40661 #include <linux/kref.h>
40662 #include <linux/sched.h>
40663 #include <linux/kthread.h>
40664 +#include <linux/slab.h>
40665
40666 #include "qib_common.h"
40667 #include "qib_verbs.h"
40668 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40669 index da739d9..da1c7f4 100644
40670 --- a/drivers/input/gameport/gameport.c
40671 +++ b/drivers/input/gameport/gameport.c
40672 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40673 */
40674 static void gameport_init_port(struct gameport *gameport)
40675 {
40676 - static atomic_t gameport_no = ATOMIC_INIT(0);
40677 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40678
40679 __module_get(THIS_MODULE);
40680
40681 mutex_init(&gameport->drv_mutex);
40682 device_initialize(&gameport->dev);
40683 dev_set_name(&gameport->dev, "gameport%lu",
40684 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40685 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40686 gameport->dev.bus = &gameport_bus;
40687 gameport->dev.release = gameport_release_port;
40688 if (gameport->parent)
40689 diff --git a/drivers/input/input.c b/drivers/input/input.c
40690 index c044699..174d71a 100644
40691 --- a/drivers/input/input.c
40692 +++ b/drivers/input/input.c
40693 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40694 */
40695 int input_register_device(struct input_dev *dev)
40696 {
40697 - static atomic_t input_no = ATOMIC_INIT(0);
40698 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40699 struct input_devres *devres = NULL;
40700 struct input_handler *handler;
40701 unsigned int packet_size;
40702 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40703 dev->setkeycode = input_default_setkeycode;
40704
40705 dev_set_name(&dev->dev, "input%ld",
40706 - (unsigned long) atomic_inc_return(&input_no) - 1);
40707 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40708
40709 error = device_add(&dev->dev);
40710 if (error)
40711 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40712 index 04c69af..5f92d00 100644
40713 --- a/drivers/input/joystick/sidewinder.c
40714 +++ b/drivers/input/joystick/sidewinder.c
40715 @@ -30,6 +30,7 @@
40716 #include <linux/kernel.h>
40717 #include <linux/module.h>
40718 #include <linux/slab.h>
40719 +#include <linux/sched.h>
40720 #include <linux/init.h>
40721 #include <linux/input.h>
40722 #include <linux/gameport.h>
40723 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40724 index 75e3b10..fb390fd 100644
40725 --- a/drivers/input/joystick/xpad.c
40726 +++ b/drivers/input/joystick/xpad.c
40727 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40728
40729 static int xpad_led_probe(struct usb_xpad *xpad)
40730 {
40731 - static atomic_t led_seq = ATOMIC_INIT(0);
40732 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40733 long led_no;
40734 struct xpad_led *led;
40735 struct led_classdev *led_cdev;
40736 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40737 if (!led)
40738 return -ENOMEM;
40739
40740 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40741 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40742
40743 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40744 led->xpad = xpad;
40745 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40746 index e204f26..8459f15 100644
40747 --- a/drivers/input/misc/ims-pcu.c
40748 +++ b/drivers/input/misc/ims-pcu.c
40749 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40750
40751 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40752 {
40753 - static atomic_t device_no = ATOMIC_INIT(0);
40754 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40755
40756 const struct ims_pcu_device_info *info;
40757 u8 device_id;
40758 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40759 }
40760
40761 /* Device appears to be operable, complete initialization */
40762 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40763 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40764
40765 error = ims_pcu_setup_backlight(pcu);
40766 if (error)
40767 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40768 index 2f0b39d..7370f13 100644
40769 --- a/drivers/input/mouse/psmouse.h
40770 +++ b/drivers/input/mouse/psmouse.h
40771 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40772 ssize_t (*set)(struct psmouse *psmouse, void *data,
40773 const char *buf, size_t count);
40774 bool protect;
40775 -};
40776 +} __do_const;
40777 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40778
40779 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40780 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40781 index 4c842c3..590b0bf 100644
40782 --- a/drivers/input/mousedev.c
40783 +++ b/drivers/input/mousedev.c
40784 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40785
40786 spin_unlock_irq(&client->packet_lock);
40787
40788 - if (copy_to_user(buffer, data, count))
40789 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40790 return -EFAULT;
40791
40792 return count;
40793 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
40794 index 25fc597..558bf3b3 100644
40795 --- a/drivers/input/serio/serio.c
40796 +++ b/drivers/input/serio/serio.c
40797 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
40798 */
40799 static void serio_init_port(struct serio *serio)
40800 {
40801 - static atomic_t serio_no = ATOMIC_INIT(0);
40802 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
40803
40804 __module_get(THIS_MODULE);
40805
40806 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
40807 mutex_init(&serio->drv_mutex);
40808 device_initialize(&serio->dev);
40809 dev_set_name(&serio->dev, "serio%ld",
40810 - (long)atomic_inc_return(&serio_no) - 1);
40811 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
40812 serio->dev.bus = &serio_bus;
40813 serio->dev.release = serio_release_port;
40814 serio->dev.groups = serio_device_attr_groups;
40815 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
40816 index 59df2e7..8f1cafb 100644
40817 --- a/drivers/input/serio/serio_raw.c
40818 +++ b/drivers/input/serio/serio_raw.c
40819 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
40820
40821 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40822 {
40823 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
40824 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
40825 struct serio_raw *serio_raw;
40826 int err;
40827
40828 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40829 }
40830
40831 snprintf(serio_raw->name, sizeof(serio_raw->name),
40832 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
40833 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
40834 kref_init(&serio_raw->kref);
40835 INIT_LIST_HEAD(&serio_raw->client_list);
40836 init_waitqueue_head(&serio_raw->wait);
40837 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
40838 index fbe9ca7..dbee61d 100644
40839 --- a/drivers/iommu/iommu.c
40840 +++ b/drivers/iommu/iommu.c
40841 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
40842 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
40843 {
40844 bus_register_notifier(bus, &iommu_bus_nb);
40845 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
40846 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
40847 }
40848
40849 /**
40850 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
40851 index 39f81ae..2660096 100644
40852 --- a/drivers/iommu/irq_remapping.c
40853 +++ b/drivers/iommu/irq_remapping.c
40854 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
40855 void panic_if_irq_remap(const char *msg)
40856 {
40857 if (irq_remapping_enabled)
40858 - panic(msg);
40859 + panic("%s", msg);
40860 }
40861
40862 static void ir_ack_apic_edge(struct irq_data *data)
40863 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
40864
40865 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
40866 {
40867 - chip->irq_print_chip = ir_print_prefix;
40868 - chip->irq_ack = ir_ack_apic_edge;
40869 - chip->irq_eoi = ir_ack_apic_level;
40870 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40871 + pax_open_kernel();
40872 + *(void **)&chip->irq_print_chip = ir_print_prefix;
40873 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
40874 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
40875 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40876 + pax_close_kernel();
40877 }
40878
40879 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
40880 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
40881 index ee7c503..5d4ce08 100644
40882 --- a/drivers/irqchip/irq-gic.c
40883 +++ b/drivers/irqchip/irq-gic.c
40884 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
40885 * Supported arch specific GIC irq extension.
40886 * Default make them NULL.
40887 */
40888 -struct irq_chip gic_arch_extn = {
40889 +irq_chip_no_const gic_arch_extn = {
40890 .irq_eoi = NULL,
40891 .irq_mask = NULL,
40892 .irq_unmask = NULL,
40893 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
40894 chained_irq_exit(chip, desc);
40895 }
40896
40897 -static struct irq_chip gic_chip = {
40898 +static irq_chip_no_const gic_chip __read_only = {
40899 .name = "GIC",
40900 .irq_mask = gic_mask_irq,
40901 .irq_unmask = gic_unmask_irq,
40902 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
40903 index ac6f72b..81150f2 100644
40904 --- a/drivers/isdn/capi/capi.c
40905 +++ b/drivers/isdn/capi/capi.c
40906 @@ -81,8 +81,8 @@ struct capiminor {
40907
40908 struct capi20_appl *ap;
40909 u32 ncci;
40910 - atomic_t datahandle;
40911 - atomic_t msgid;
40912 + atomic_unchecked_t datahandle;
40913 + atomic_unchecked_t msgid;
40914
40915 struct tty_port port;
40916 int ttyinstop;
40917 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
40918 capimsg_setu16(s, 2, mp->ap->applid);
40919 capimsg_setu8 (s, 4, CAPI_DATA_B3);
40920 capimsg_setu8 (s, 5, CAPI_RESP);
40921 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
40922 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
40923 capimsg_setu32(s, 8, mp->ncci);
40924 capimsg_setu16(s, 12, datahandle);
40925 }
40926 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
40927 mp->outbytes -= len;
40928 spin_unlock_bh(&mp->outlock);
40929
40930 - datahandle = atomic_inc_return(&mp->datahandle);
40931 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
40932 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
40933 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40934 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40935 capimsg_setu16(skb->data, 2, mp->ap->applid);
40936 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
40937 capimsg_setu8 (skb->data, 5, CAPI_REQ);
40938 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
40939 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
40940 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
40941 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
40942 capimsg_setu16(skb->data, 16, len); /* Data length */
40943 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
40944 index 600c79b..3752bab 100644
40945 --- a/drivers/isdn/gigaset/interface.c
40946 +++ b/drivers/isdn/gigaset/interface.c
40947 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
40948 }
40949 tty->driver_data = cs;
40950
40951 - ++cs->port.count;
40952 + atomic_inc(&cs->port.count);
40953
40954 - if (cs->port.count == 1) {
40955 + if (atomic_read(&cs->port.count) == 1) {
40956 tty_port_tty_set(&cs->port, tty);
40957 cs->port.low_latency = 1;
40958 }
40959 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
40960
40961 if (!cs->connected)
40962 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
40963 - else if (!cs->port.count)
40964 + else if (!atomic_read(&cs->port.count))
40965 dev_warn(cs->dev, "%s: device not opened\n", __func__);
40966 - else if (!--cs->port.count)
40967 + else if (!atomic_dec_return(&cs->port.count))
40968 tty_port_tty_set(&cs->port, NULL);
40969
40970 mutex_unlock(&cs->mutex);
40971 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
40972 index d0a41cb..f0cdb8c 100644
40973 --- a/drivers/isdn/gigaset/usb-gigaset.c
40974 +++ b/drivers/isdn/gigaset/usb-gigaset.c
40975 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
40976 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
40977 memcpy(cs->hw.usb->bchars, buf, 6);
40978 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
40979 - 0, 0, &buf, 6, 2000);
40980 + 0, 0, buf, 6, 2000);
40981 }
40982
40983 static void gigaset_freebcshw(struct bc_state *bcs)
40984 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
40985 index 4d9b195..455075c 100644
40986 --- a/drivers/isdn/hardware/avm/b1.c
40987 +++ b/drivers/isdn/hardware/avm/b1.c
40988 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
40989 }
40990 if (left) {
40991 if (t4file->user) {
40992 - if (copy_from_user(buf, dp, left))
40993 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40994 return -EFAULT;
40995 } else {
40996 memcpy(buf, dp, left);
40997 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
40998 }
40999 if (left) {
41000 if (config->user) {
41001 - if (copy_from_user(buf, dp, left))
41002 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41003 return -EFAULT;
41004 } else {
41005 memcpy(buf, dp, left);
41006 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
41007 index 1063bab..36817e0 100644
41008 --- a/drivers/isdn/hisax/amd7930_fn.c
41009 +++ b/drivers/isdn/hisax/amd7930_fn.c
41010 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41011
41012 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41013 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41014 - debugl1(cs, cs->dlog);
41015 + debugl1(cs, "%s", cs->dlog);
41016 }
41017 /* moves received data in sk-buffer */
41018 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41019 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41020
41021 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41022 QuickHex(t, deb_ptr, count);
41023 - debugl1(cs, cs->dlog);
41024 + debugl1(cs, "%s", cs->dlog);
41025 }
41026 /* AMD interrupts on */
41027 AmdIrqOn(cs);
41028 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41029 index ee9b9a0..d1427bd 100644
41030 --- a/drivers/isdn/hisax/avm_pci.c
41031 +++ b/drivers/isdn/hisax/avm_pci.c
41032 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41033 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41034 bcs->channel ? 'B' : 'A', count);
41035 QuickHex(t, p, count);
41036 - debugl1(cs, bcs->blog);
41037 + debugl1(cs, "%s", bcs->blog);
41038 }
41039 }
41040
41041 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41042 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41043 bcs->channel ? 'B' : 'A', count);
41044 QuickHex(t, p, count);
41045 - debugl1(cs, bcs->blog);
41046 + debugl1(cs, "%s", bcs->blog);
41047 }
41048 }
41049
41050 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41051 index bf04d2a..b33f53b 100644
41052 --- a/drivers/isdn/hisax/config.c
41053 +++ b/drivers/isdn/hisax/config.c
41054 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41055 ptr--;
41056 *ptr++ = '\n';
41057 *ptr = 0;
41058 - HiSax_putstatus(cs, NULL, cs->dlog);
41059 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41060 } else
41061 HiSax_putstatus(cs, "LogEcho: ",
41062 "warning Frame too big (%d)",
41063 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41064 index 8d0cf6e..4fc90de 100644
41065 --- a/drivers/isdn/hisax/diva.c
41066 +++ b/drivers/isdn/hisax/diva.c
41067 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41068 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41069 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41070 QuickHex(t, ptr, count);
41071 - debugl1(cs, bcs->blog);
41072 + debugl1(cs, "%s", bcs->blog);
41073 }
41074 }
41075
41076 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41077 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41078 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41079 QuickHex(t, ptr, count);
41080 - debugl1(cs, bcs->blog);
41081 + debugl1(cs, "%s", bcs->blog);
41082 }
41083 }
41084
41085 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41086 index 1df6f9a..2be1c8a 100644
41087 --- a/drivers/isdn/hisax/elsa.c
41088 +++ b/drivers/isdn/hisax/elsa.c
41089 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41090 t = tmp;
41091 t += sprintf(tmp, "Arcofi data");
41092 QuickHex(t, p, cs->dc.isac.mon_rxp);
41093 - debugl1(cs, tmp);
41094 + debugl1(cs, "%s", tmp);
41095 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41096 switch (cs->dc.isac.mon_rx[1]) {
41097 case 0x80:
41098 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41099 index d4c98d3..3f84dd8 100644
41100 --- a/drivers/isdn/hisax/elsa_ser.c
41101 +++ b/drivers/isdn/hisax/elsa_ser.c
41102 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41103
41104 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41105 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41106 - debugl1(cs, tmp);
41107 + debugl1(cs, "%s", tmp);
41108 }
41109 cs->hw.elsa.rcvcnt = 0;
41110 }
41111 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41112 index 3ccd724..497bd02 100644
41113 --- a/drivers/isdn/hisax/hfc_pci.c
41114 +++ b/drivers/isdn/hisax/hfc_pci.c
41115 @@ -901,7 +901,7 @@ Begin:
41116 ptr--;
41117 *ptr++ = '\n';
41118 *ptr = 0;
41119 - HiSax_putstatus(cs, NULL, cs->dlog);
41120 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41121 } else
41122 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41123 }
41124 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41125 index dc4574f..fa1fefd 100644
41126 --- a/drivers/isdn/hisax/hfc_sx.c
41127 +++ b/drivers/isdn/hisax/hfc_sx.c
41128 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41129 ptr--;
41130 *ptr++ = '\n';
41131 *ptr = 0;
41132 - HiSax_putstatus(cs, NULL, cs->dlog);
41133 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41134 } else
41135 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41136 }
41137 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41138 index f398d48..a8d6188 100644
41139 --- a/drivers/isdn/hisax/hscx_irq.c
41140 +++ b/drivers/isdn/hisax/hscx_irq.c
41141 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41142 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41143 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41144 QuickHex(t, ptr, count);
41145 - debugl1(cs, bcs->blog);
41146 + debugl1(cs, "%s", bcs->blog);
41147 }
41148 }
41149
41150 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41151 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41152 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41153 QuickHex(t, ptr, count);
41154 - debugl1(cs, bcs->blog);
41155 + debugl1(cs, "%s", bcs->blog);
41156 }
41157 }
41158
41159 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41160 index db5321f..51dae91 100644
41161 --- a/drivers/isdn/hisax/icc.c
41162 +++ b/drivers/isdn/hisax/icc.c
41163 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41164
41165 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41166 QuickHex(t, ptr, count);
41167 - debugl1(cs, cs->dlog);
41168 + debugl1(cs, "%s", cs->dlog);
41169 }
41170 }
41171
41172 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41173
41174 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41175 QuickHex(t, ptr, count);
41176 - debugl1(cs, cs->dlog);
41177 + debugl1(cs, "%s", cs->dlog);
41178 }
41179 }
41180
41181 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41182 index 74feb5c..5faa5de 100644
41183 --- a/drivers/isdn/hisax/ipacx.c
41184 +++ b/drivers/isdn/hisax/ipacx.c
41185 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41186
41187 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41188 QuickHex(t, ptr, count);
41189 - debugl1(cs, cs->dlog);
41190 + debugl1(cs, "%s", cs->dlog);
41191 }
41192 }
41193
41194 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41195
41196 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41197 QuickHex(t, ptr, count);
41198 - debugl1(cs, cs->dlog);
41199 + debugl1(cs, "%s", cs->dlog);
41200 }
41201 }
41202
41203 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41204
41205 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41206 QuickHex(t, ptr, count);
41207 - debugl1(cs, bcs->blog);
41208 + debugl1(cs, "%s", bcs->blog);
41209 }
41210 }
41211
41212 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41213
41214 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41215 QuickHex(t, ptr, count);
41216 - debugl1(cs, bcs->blog);
41217 + debugl1(cs, "%s", bcs->blog);
41218 }
41219 }
41220
41221 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41222 index a365ccc..7fdf78f 100644
41223 --- a/drivers/isdn/hisax/isac.c
41224 +++ b/drivers/isdn/hisax/isac.c
41225 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41226
41227 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41228 QuickHex(t, ptr, count);
41229 - debugl1(cs, cs->dlog);
41230 + debugl1(cs, "%s", cs->dlog);
41231 }
41232 }
41233
41234 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41235
41236 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41237 QuickHex(t, ptr, count);
41238 - debugl1(cs, cs->dlog);
41239 + debugl1(cs, "%s", cs->dlog);
41240 }
41241 }
41242
41243 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41244 index 7fdf347..f4956c7 100644
41245 --- a/drivers/isdn/hisax/isar.c
41246 +++ b/drivers/isdn/hisax/isar.c
41247 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41248 t = tmp;
41249 t += sprintf(t, "sendmbox cnt %d", len);
41250 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41251 - debugl1(cs, tmp);
41252 + debugl1(cs, "%s", tmp);
41253 i -= 64;
41254 }
41255 }
41256 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41257 t = tmp;
41258 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41259 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41260 - debugl1(cs, tmp);
41261 + debugl1(cs, "%s", tmp);
41262 i -= 64;
41263 }
41264 }
41265 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41266 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41267 ireg->iis, ireg->cmsb);
41268 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41269 - debugl1(cs, debbuf);
41270 + debugl1(cs, "%s", debbuf);
41271 }
41272 break;
41273 case ISAR_IIS_INVMSG:
41274 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41275 index f946c58..e2ae787 100644
41276 --- a/drivers/isdn/hisax/jade.c
41277 +++ b/drivers/isdn/hisax/jade.c
41278 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41279 int jade = bcs->hw.hscx.hscx;
41280
41281 if (cs->debug & L1_DEB_HSCX) {
41282 - char tmp[40];
41283 - sprintf(tmp, "jade %c mode %d ichan %d",
41284 - 'A' + jade, mode, bc);
41285 - debugl1(cs, tmp);
41286 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41287 }
41288 bcs->mode = mode;
41289 bcs->channel = bc;
41290 @@ -257,23 +254,18 @@ void
41291 clear_pending_jade_ints(struct IsdnCardState *cs)
41292 {
41293 int val;
41294 - char tmp[64];
41295
41296 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41297 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41298
41299 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41300 - sprintf(tmp, "jade B ISTA %x", val);
41301 - debugl1(cs, tmp);
41302 + debugl1(cs, "jade B ISTA %x", val);
41303 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41304 - sprintf(tmp, "jade A ISTA %x", val);
41305 - debugl1(cs, tmp);
41306 + debugl1(cs, "jade A ISTA %x", val);
41307 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41308 - sprintf(tmp, "jade B STAR %x", val);
41309 - debugl1(cs, tmp);
41310 + debugl1(cs, "jade B STAR %x", val);
41311 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41312 - sprintf(tmp, "jade A STAR %x", val);
41313 - debugl1(cs, tmp);
41314 + debugl1(cs, "jade A STAR %x", val);
41315 /* Unmask ints */
41316 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41317 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41318 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41319 index f521fc8..b930da9 100644
41320 --- a/drivers/isdn/hisax/jade_irq.c
41321 +++ b/drivers/isdn/hisax/jade_irq.c
41322 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41323 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41324 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41325 QuickHex(t, ptr, count);
41326 - debugl1(cs, bcs->blog);
41327 + debugl1(cs, "%s", bcs->blog);
41328 }
41329 }
41330
41331 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41332 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41333 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41334 QuickHex(t, ptr, count);
41335 - debugl1(cs, bcs->blog);
41336 + debugl1(cs, "%s", bcs->blog);
41337 }
41338 }
41339
41340 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41341 index 4c1bca5..875402e 100644
41342 --- a/drivers/isdn/hisax/l3_1tr6.c
41343 +++ b/drivers/isdn/hisax/l3_1tr6.c
41344 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41345 {
41346 dev_kfree_skb(skb);
41347 if (pc->st->l3.debug & L3_DEB_WARN)
41348 - l3_debug(pc->st, msg);
41349 + l3_debug(pc->st, "%s", msg);
41350 l3_1tr6_release_req(pc, 0, NULL);
41351 }
41352
41353 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41354 {
41355 u_char *p;
41356 int bcfound = 0;
41357 - char tmp[80];
41358 struct sk_buff *skb = arg;
41359
41360 /* Channel Identification */
41361 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41362 /* Signal all services, linklevel takes care of Service-Indicator */
41363 if (bcfound) {
41364 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41365 - sprintf(tmp, "non-digital call: %s -> %s",
41366 + l3_debug(pc->st, "non-digital call: %s -> %s",
41367 pc->para.setup.phone,
41368 pc->para.setup.eazmsn);
41369 - l3_debug(pc->st, tmp);
41370 }
41371 newl3state(pc, 6);
41372 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41373 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41374 {
41375 u_char *p;
41376 int i, tmpcharge = 0;
41377 - char a_charge[8], tmp[32];
41378 + char a_charge[8];
41379 struct sk_buff *skb = arg;
41380
41381 p = skb->data;
41382 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41383 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41384 }
41385 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41386 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41387 - l3_debug(pc->st, tmp);
41388 + l3_debug(pc->st, "charging info %d",
41389 + pc->para.chargeinfo);
41390 }
41391 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41392 l3_debug(pc->st, "charging info not found");
41393 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41394 struct sk_buff *skb = arg;
41395 u_char *p;
41396 int i, tmpcharge = 0;
41397 - char a_charge[8], tmp[32];
41398 + char a_charge[8];
41399
41400 StopAllL3Timer(pc);
41401 p = skb->data;
41402 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41403 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41404 }
41405 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41406 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41407 - l3_debug(pc->st, tmp);
41408 + l3_debug(pc->st, "charging info %d",
41409 + pc->para.chargeinfo);
41410 }
41411 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41412 l3_debug(pc->st, "charging info not found");
41413 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41414 int i, mt, cr;
41415 struct l3_process *proc;
41416 struct sk_buff *skb = arg;
41417 - char tmp[80];
41418
41419 switch (pr) {
41420 case (DL_DATA | INDICATION):
41421 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41422 }
41423 if (skb->len < 4) {
41424 if (st->l3.debug & L3_DEB_PROTERR) {
41425 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41426 - l3_debug(st, tmp);
41427 + l3_debug(st, "up1tr6 len only %d", skb->len);
41428 }
41429 dev_kfree_skb(skb);
41430 return;
41431 }
41432 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41433 if (st->l3.debug & L3_DEB_PROTERR) {
41434 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41435 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41436 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41437 skb->data[0], skb->len);
41438 - l3_debug(st, tmp);
41439 }
41440 dev_kfree_skb(skb);
41441 return;
41442 }
41443 if (skb->data[1] != 1) {
41444 if (st->l3.debug & L3_DEB_PROTERR) {
41445 - sprintf(tmp, "up1tr6 CR len not 1");
41446 - l3_debug(st, tmp);
41447 + l3_debug(st, "up1tr6 CR len not 1");
41448 }
41449 dev_kfree_skb(skb);
41450 return;
41451 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41452 if (skb->data[0] == PROTO_DIS_N0) {
41453 dev_kfree_skb(skb);
41454 if (st->l3.debug & L3_DEB_STATE) {
41455 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41456 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41457 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41458 - l3_debug(st, tmp);
41459 }
41460 } else if (skb->data[0] == PROTO_DIS_N1) {
41461 if (!(proc = getl3proc(st, cr))) {
41462 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41463 if (cr < 128) {
41464 if (!(proc = new_l3_process(st, cr))) {
41465 if (st->l3.debug & L3_DEB_PROTERR) {
41466 - sprintf(tmp, "up1tr6 no roc mem");
41467 - l3_debug(st, tmp);
41468 + l3_debug(st, "up1tr6 no roc mem");
41469 }
41470 dev_kfree_skb(skb);
41471 return;
41472 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41473 } else {
41474 if (!(proc = new_l3_process(st, cr))) {
41475 if (st->l3.debug & L3_DEB_PROTERR) {
41476 - sprintf(tmp, "up1tr6 no roc mem");
41477 - l3_debug(st, tmp);
41478 + l3_debug(st, "up1tr6 no roc mem");
41479 }
41480 dev_kfree_skb(skb);
41481 return;
41482 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41483 if (i == ARRAY_SIZE(datastln1)) {
41484 dev_kfree_skb(skb);
41485 if (st->l3.debug & L3_DEB_STATE) {
41486 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41487 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41488 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41489 proc->state, mt);
41490 - l3_debug(st, tmp);
41491 }
41492 return;
41493 } else {
41494 if (st->l3.debug & L3_DEB_STATE) {
41495 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41496 + l3_debug(st, "up1tr6%sstate %d mt %x",
41497 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41498 proc->state, mt);
41499 - l3_debug(st, tmp);
41500 }
41501 datastln1[i].rout(proc, pr, skb);
41502 }
41503 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41504 int i, cr;
41505 struct l3_process *proc;
41506 struct Channel *chan;
41507 - char tmp[80];
41508
41509 if ((DL_ESTABLISH | REQUEST) == pr) {
41510 l3_msg(st, pr, NULL);
41511 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41512 break;
41513 if (i == ARRAY_SIZE(downstl)) {
41514 if (st->l3.debug & L3_DEB_STATE) {
41515 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41516 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41517 proc->state, pr);
41518 - l3_debug(st, tmp);
41519 }
41520 } else {
41521 if (st->l3.debug & L3_DEB_STATE) {
41522 - sprintf(tmp, "down1tr6 state %d prim %d",
41523 + l3_debug(st, "down1tr6 state %d prim %d",
41524 proc->state, pr);
41525 - l3_debug(st, tmp);
41526 }
41527 downstl[i].rout(proc, pr, arg);
41528 }
41529 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41530 index b646eed..233e432 100644
41531 --- a/drivers/isdn/hisax/netjet.c
41532 +++ b/drivers/isdn/hisax/netjet.c
41533 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41534 else
41535 j = i;
41536 QuickHex(t, p, j);
41537 - debugl1(cs, tmp);
41538 + debugl1(cs, "%s", tmp);
41539 p += j;
41540 i -= j;
41541 t = tmp;
41542 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41543 index 041bf52..af1b020 100644
41544 --- a/drivers/isdn/hisax/q931.c
41545 +++ b/drivers/isdn/hisax/q931.c
41546 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41547 dp--;
41548 *dp++ = '\n';
41549 *dp = 0;
41550 - HiSax_putstatus(cs, NULL, cs->dlog);
41551 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41552 } else
41553 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41554 }
41555 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41556 }
41557 if (finish) {
41558 *dp = 0;
41559 - HiSax_putstatus(cs, NULL, cs->dlog);
41560 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41561 return;
41562 }
41563 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41564 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41565 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41566 }
41567 *dp = 0;
41568 - HiSax_putstatus(cs, NULL, cs->dlog);
41569 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41570 }
41571 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41572 index d8cac69..a858955 100644
41573 --- a/drivers/isdn/hisax/w6692.c
41574 +++ b/drivers/isdn/hisax/w6692.c
41575 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41576
41577 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41578 QuickHex(t, ptr, count);
41579 - debugl1(cs, cs->dlog);
41580 + debugl1(cs, "%s", cs->dlog);
41581 }
41582 }
41583
41584 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41585
41586 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41587 QuickHex(t, ptr, count);
41588 - debugl1(cs, cs->dlog);
41589 + debugl1(cs, "%s", cs->dlog);
41590 }
41591 }
41592
41593 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41594 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41595 bcs->channel + '1', count);
41596 QuickHex(t, ptr, count);
41597 - debugl1(cs, bcs->blog);
41598 + debugl1(cs, "%s", bcs->blog);
41599 }
41600 }
41601
41602 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41603 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41604 bcs->channel + '1', count);
41605 QuickHex(t, ptr, count);
41606 - debugl1(cs, bcs->blog);
41607 + debugl1(cs, "%s", bcs->blog);
41608 }
41609 }
41610
41611 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41612 index 9bb12ba..d4262f7 100644
41613 --- a/drivers/isdn/i4l/isdn_common.c
41614 +++ b/drivers/isdn/i4l/isdn_common.c
41615 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41616 } else
41617 return -EINVAL;
41618 case IIOCDBGVAR:
41619 + if (!capable(CAP_SYS_RAWIO))
41620 + return -EPERM;
41621 if (arg) {
41622 if (copy_to_user(argp, &dev, sizeof(ulong)))
41623 return -EFAULT;
41624 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41625 index 3c5f249..5fac4d0 100644
41626 --- a/drivers/isdn/i4l/isdn_tty.c
41627 +++ b/drivers/isdn/i4l/isdn_tty.c
41628 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41629
41630 #ifdef ISDN_DEBUG_MODEM_OPEN
41631 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41632 - port->count);
41633 + atomic_read(&port->count));
41634 #endif
41635 - port->count++;
41636 + atomic_inc(&port->count);
41637 port->tty = tty;
41638 /*
41639 * Start up serial port
41640 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41641 #endif
41642 return;
41643 }
41644 - if ((tty->count == 1) && (port->count != 1)) {
41645 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41646 /*
41647 * Uh, oh. tty->count is 1, which means that the tty
41648 * structure will be freed. Info->count should always
41649 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41650 * serial port won't be shutdown.
41651 */
41652 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41653 - "info->count is %d\n", port->count);
41654 - port->count = 1;
41655 + "info->count is %d\n", atomic_read(&port->count));
41656 + atomic_set(&port->count, 1);
41657 }
41658 - if (--port->count < 0) {
41659 + if (atomic_dec_return(&port->count) < 0) {
41660 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41661 - info->line, port->count);
41662 - port->count = 0;
41663 + info->line, atomic_read(&port->count));
41664 + atomic_set(&port->count, 0);
41665 }
41666 - if (port->count) {
41667 + if (atomic_read(&port->count)) {
41668 #ifdef ISDN_DEBUG_MODEM_OPEN
41669 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41670 #endif
41671 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41672 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41673 return;
41674 isdn_tty_shutdown(info);
41675 - port->count = 0;
41676 + atomic_set(&port->count, 0);
41677 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41678 port->tty = NULL;
41679 wake_up_interruptible(&port->open_wait);
41680 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41681 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41682 modem_info *info = &dev->mdm.info[i];
41683
41684 - if (info->port.count == 0)
41685 + if (atomic_read(&info->port.count) == 0)
41686 continue;
41687 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41688 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41689 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41690 index e74df7c..03a03ba 100644
41691 --- a/drivers/isdn/icn/icn.c
41692 +++ b/drivers/isdn/icn/icn.c
41693 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41694 if (count > len)
41695 count = len;
41696 if (user) {
41697 - if (copy_from_user(msg, buf, count))
41698 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41699 return -EFAULT;
41700 } else
41701 memcpy(msg, buf, count);
41702 diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
41703 index baf2686..02125e6 100644
41704 --- a/drivers/isdn/isdnloop/isdnloop.c
41705 +++ b/drivers/isdn/isdnloop/isdnloop.c
41706 @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41707 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41708 return -ENOMEM;
41709 }
41710 - for (i = 0; i < 3; i++)
41711 - strcpy(card->s0num[i], sdef.num[i]);
41712 + for (i = 0; i < 3; i++) {
41713 + strlcpy(card->s0num[i], sdef.num[i],
41714 + sizeof(card->s0num[0]));
41715 + }
41716 break;
41717 case ISDN_PTYPE_1TR6:
41718 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
41719 @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41720 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41721 return -ENOMEM;
41722 }
41723 - strcpy(card->s0num[0], sdef.num[0]);
41724 + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
41725 card->s0num[1][0] = '\0';
41726 card->s0num[2][0] = '\0';
41727 break;
41728 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41729 index 6a8405d..0bd1c7e 100644
41730 --- a/drivers/leds/leds-clevo-mail.c
41731 +++ b/drivers/leds/leds-clevo-mail.c
41732 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41733 * detected as working, but in reality it is not) as low as
41734 * possible.
41735 */
41736 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41737 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41738 {
41739 .callback = clevo_mail_led_dmi_callback,
41740 .ident = "Clevo D410J",
41741 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41742 index 64e204e..c6bf189 100644
41743 --- a/drivers/leds/leds-ss4200.c
41744 +++ b/drivers/leds/leds-ss4200.c
41745 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41746 * detected as working, but in reality it is not) as low as
41747 * possible.
41748 */
41749 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41750 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41751 {
41752 .callback = ss4200_led_dmi_callback,
41753 .ident = "Intel SS4200-E",
41754 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41755 index 0bf1e4e..b4bf44e 100644
41756 --- a/drivers/lguest/core.c
41757 +++ b/drivers/lguest/core.c
41758 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41759 * The end address needs +1 because __get_vm_area allocates an
41760 * extra guard page, so we need space for that.
41761 */
41762 +
41763 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41764 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41765 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41766 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41767 +#else
41768 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41769 VM_ALLOC, switcher_addr, switcher_addr
41770 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41771 +#endif
41772 +
41773 if (!switcher_vma) {
41774 err = -ENOMEM;
41775 printk("lguest: could not map switcher pages high\n");
41776 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41777 * Now the Switcher is mapped at the right address, we can't fail!
41778 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41779 */
41780 - memcpy(switcher_vma->addr, start_switcher_text,
41781 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41782 end_switcher_text - start_switcher_text);
41783
41784 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41785 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41786 index a35d8d1..59fb772 100644
41787 --- a/drivers/lguest/page_tables.c
41788 +++ b/drivers/lguest/page_tables.c
41789 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41790 /*:*/
41791
41792 #ifdef CONFIG_X86_PAE
41793 -static void release_pmd(pmd_t *spmd)
41794 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41795 {
41796 /* If the entry's not present, there's nothing to release. */
41797 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41798 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41799 index 5169239..47cb4db 100644
41800 --- a/drivers/lguest/x86/core.c
41801 +++ b/drivers/lguest/x86/core.c
41802 @@ -59,7 +59,7 @@ static struct {
41803 /* Offset from where switcher.S was compiled to where we've copied it */
41804 static unsigned long switcher_offset(void)
41805 {
41806 - return switcher_addr - (unsigned long)start_switcher_text;
41807 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41808 }
41809
41810 /* This cpu's struct lguest_pages (after the Switcher text page) */
41811 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41812 * These copies are pretty cheap, so we do them unconditionally: */
41813 /* Save the current Host top-level page directory.
41814 */
41815 +
41816 +#ifdef CONFIG_PAX_PER_CPU_PGD
41817 + pages->state.host_cr3 = read_cr3();
41818 +#else
41819 pages->state.host_cr3 = __pa(current->mm->pgd);
41820 +#endif
41821 +
41822 /*
41823 * Set up the Guest's page tables to see this CPU's pages (and no
41824 * other CPU's pages).
41825 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41826 * compiled-in switcher code and the high-mapped copy we just made.
41827 */
41828 for (i = 0; i < IDT_ENTRIES; i++)
41829 - default_idt_entries[i] += switcher_offset();
41830 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41831
41832 /*
41833 * Set up the Switcher's per-cpu areas.
41834 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41835 * it will be undisturbed when we switch. To change %cs and jump we
41836 * need this structure to feed to Intel's "lcall" instruction.
41837 */
41838 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41839 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41840 lguest_entry.segment = LGUEST_CS;
41841
41842 /*
41843 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41844 index 40634b0..4f5855e 100644
41845 --- a/drivers/lguest/x86/switcher_32.S
41846 +++ b/drivers/lguest/x86/switcher_32.S
41847 @@ -87,6 +87,7 @@
41848 #include <asm/page.h>
41849 #include <asm/segment.h>
41850 #include <asm/lguest.h>
41851 +#include <asm/processor-flags.h>
41852
41853 // We mark the start of the code to copy
41854 // It's placed in .text tho it's never run here
41855 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41856 // Changes type when we load it: damn Intel!
41857 // For after we switch over our page tables
41858 // That entry will be read-only: we'd crash.
41859 +
41860 +#ifdef CONFIG_PAX_KERNEXEC
41861 + mov %cr0, %edx
41862 + xor $X86_CR0_WP, %edx
41863 + mov %edx, %cr0
41864 +#endif
41865 +
41866 movl $(GDT_ENTRY_TSS*8), %edx
41867 ltr %dx
41868
41869 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41870 // Let's clear it again for our return.
41871 // The GDT descriptor of the Host
41872 // Points to the table after two "size" bytes
41873 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41874 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41875 // Clear "used" from type field (byte 5, bit 2)
41876 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41877 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41878 +
41879 +#ifdef CONFIG_PAX_KERNEXEC
41880 + mov %cr0, %eax
41881 + xor $X86_CR0_WP, %eax
41882 + mov %eax, %cr0
41883 +#endif
41884
41885 // Once our page table's switched, the Guest is live!
41886 // The Host fades as we run this final step.
41887 @@ -295,13 +309,12 @@ deliver_to_host:
41888 // I consulted gcc, and it gave
41889 // These instructions, which I gladly credit:
41890 leal (%edx,%ebx,8), %eax
41891 - movzwl (%eax),%edx
41892 - movl 4(%eax), %eax
41893 - xorw %ax, %ax
41894 - orl %eax, %edx
41895 + movl 4(%eax), %edx
41896 + movw (%eax), %dx
41897 // Now the address of the handler's in %edx
41898 // We call it now: its "iret" drops us home.
41899 - jmp *%edx
41900 + ljmp $__KERNEL_CS, $1f
41901 +1: jmp *%edx
41902
41903 // Every interrupt can come to us here
41904 // But we must truly tell each apart.
41905 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41906 index 0003992..854bbce 100644
41907 --- a/drivers/md/bcache/closure.h
41908 +++ b/drivers/md/bcache/closure.h
41909 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41910 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41911 struct workqueue_struct *wq)
41912 {
41913 - BUG_ON(object_is_on_stack(cl));
41914 + BUG_ON(object_starts_on_stack(cl));
41915 closure_set_ip(cl);
41916 cl->fn = fn;
41917 cl->wq = wq;
41918 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41919 index 547c4c5..5be1de4 100644
41920 --- a/drivers/md/bcache/super.c
41921 +++ b/drivers/md/bcache/super.c
41922 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41923 err:
41924 closure_sync(&op.cl);
41925 /* XXX: test this, it's broken */
41926 - bch_cache_set_error(c, err);
41927 + bch_cache_set_error(c, "%s", err);
41928 }
41929
41930 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41931 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41932 index a7fd821..9dcf6c3 100644
41933 --- a/drivers/md/bitmap.c
41934 +++ b/drivers/md/bitmap.c
41935 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41936 chunk_kb ? "KB" : "B");
41937 if (bitmap->storage.file) {
41938 seq_printf(seq, ", file: ");
41939 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41940 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41941 }
41942
41943 seq_printf(seq, "\n");
41944 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41945 index f1b7586..a49c4bd 100644
41946 --- a/drivers/md/dm-ioctl.c
41947 +++ b/drivers/md/dm-ioctl.c
41948 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41949 cmd == DM_LIST_VERSIONS_CMD)
41950 return 0;
41951
41952 - if ((cmd == DM_DEV_CREATE_CMD)) {
41953 + if (cmd == DM_DEV_CREATE_CMD) {
41954 if (!*param->name) {
41955 DMWARN("name not supplied when creating device");
41956 return -EINVAL;
41957 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41958 index 699b5be..eac0a15 100644
41959 --- a/drivers/md/dm-raid1.c
41960 +++ b/drivers/md/dm-raid1.c
41961 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41962
41963 struct mirror {
41964 struct mirror_set *ms;
41965 - atomic_t error_count;
41966 + atomic_unchecked_t error_count;
41967 unsigned long error_type;
41968 struct dm_dev *dev;
41969 sector_t offset;
41970 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41971 struct mirror *m;
41972
41973 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41974 - if (!atomic_read(&m->error_count))
41975 + if (!atomic_read_unchecked(&m->error_count))
41976 return m;
41977
41978 return NULL;
41979 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41980 * simple way to tell if a device has encountered
41981 * errors.
41982 */
41983 - atomic_inc(&m->error_count);
41984 + atomic_inc_unchecked(&m->error_count);
41985
41986 if (test_and_set_bit(error_type, &m->error_type))
41987 return;
41988 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41989 struct mirror *m = get_default_mirror(ms);
41990
41991 do {
41992 - if (likely(!atomic_read(&m->error_count)))
41993 + if (likely(!atomic_read_unchecked(&m->error_count)))
41994 return m;
41995
41996 if (m-- == ms->mirror)
41997 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41998 {
41999 struct mirror *default_mirror = get_default_mirror(m->ms);
42000
42001 - return !atomic_read(&default_mirror->error_count);
42002 + return !atomic_read_unchecked(&default_mirror->error_count);
42003 }
42004
42005 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42006 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42007 */
42008 if (likely(region_in_sync(ms, region, 1)))
42009 m = choose_mirror(ms, bio->bi_sector);
42010 - else if (m && atomic_read(&m->error_count))
42011 + else if (m && atomic_read_unchecked(&m->error_count))
42012 m = NULL;
42013
42014 if (likely(m))
42015 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42016 }
42017
42018 ms->mirror[mirror].ms = ms;
42019 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42020 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42021 ms->mirror[mirror].error_type = 0;
42022 ms->mirror[mirror].offset = offset;
42023
42024 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42025 */
42026 static char device_status_char(struct mirror *m)
42027 {
42028 - if (!atomic_read(&(m->error_count)))
42029 + if (!atomic_read_unchecked(&(m->error_count)))
42030 return 'A';
42031
42032 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42033 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42034 index d907ca6..cfb8384 100644
42035 --- a/drivers/md/dm-stripe.c
42036 +++ b/drivers/md/dm-stripe.c
42037 @@ -20,7 +20,7 @@ struct stripe {
42038 struct dm_dev *dev;
42039 sector_t physical_start;
42040
42041 - atomic_t error_count;
42042 + atomic_unchecked_t error_count;
42043 };
42044
42045 struct stripe_c {
42046 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42047 kfree(sc);
42048 return r;
42049 }
42050 - atomic_set(&(sc->stripe[i].error_count), 0);
42051 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42052 }
42053
42054 ti->private = sc;
42055 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42056 DMEMIT("%d ", sc->stripes);
42057 for (i = 0; i < sc->stripes; i++) {
42058 DMEMIT("%s ", sc->stripe[i].dev->name);
42059 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42060 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42061 'D' : 'A';
42062 }
42063 buffer[i] = '\0';
42064 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42065 */
42066 for (i = 0; i < sc->stripes; i++)
42067 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42068 - atomic_inc(&(sc->stripe[i].error_count));
42069 - if (atomic_read(&(sc->stripe[i].error_count)) <
42070 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42071 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42072 DM_IO_ERROR_THRESHOLD)
42073 schedule_work(&sc->trigger_event);
42074 }
42075 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42076 index f221812..6cfda2f 100644
42077 --- a/drivers/md/dm-table.c
42078 +++ b/drivers/md/dm-table.c
42079 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42080 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42081 struct mapped_device *md)
42082 {
42083 - static char *_claim_ptr = "I belong to device-mapper";
42084 + static char _claim_ptr[] = "I belong to device-mapper";
42085 struct block_device *bdev;
42086
42087 int r;
42088 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42089 if (!dev_size)
42090 return 0;
42091
42092 - if ((start >= dev_size) || (start + len > dev_size)) {
42093 + if ((start >= dev_size) || (len > dev_size - start)) {
42094 DMWARN("%s: %s too small for target: "
42095 "start=%llu, len=%llu, dev_size=%llu",
42096 dm_device_name(ti->table->md), bdevname(bdev, b),
42097 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42098 index 60bce43..9b997d0 100644
42099 --- a/drivers/md/dm-thin-metadata.c
42100 +++ b/drivers/md/dm-thin-metadata.c
42101 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42102 {
42103 pmd->info.tm = pmd->tm;
42104 pmd->info.levels = 2;
42105 - pmd->info.value_type.context = pmd->data_sm;
42106 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42107 pmd->info.value_type.size = sizeof(__le64);
42108 pmd->info.value_type.inc = data_block_inc;
42109 pmd->info.value_type.dec = data_block_dec;
42110 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42111
42112 pmd->bl_info.tm = pmd->tm;
42113 pmd->bl_info.levels = 1;
42114 - pmd->bl_info.value_type.context = pmd->data_sm;
42115 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42116 pmd->bl_info.value_type.size = sizeof(__le64);
42117 pmd->bl_info.value_type.inc = data_block_inc;
42118 pmd->bl_info.value_type.dec = data_block_dec;
42119 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42120 index 995e1fc..2468cec 100644
42121 --- a/drivers/md/dm.c
42122 +++ b/drivers/md/dm.c
42123 @@ -178,9 +178,9 @@ struct mapped_device {
42124 /*
42125 * Event handling.
42126 */
42127 - atomic_t event_nr;
42128 + atomic_unchecked_t event_nr;
42129 wait_queue_head_t eventq;
42130 - atomic_t uevent_seq;
42131 + atomic_unchecked_t uevent_seq;
42132 struct list_head uevent_list;
42133 spinlock_t uevent_lock; /* Protect access to uevent_list */
42134
42135 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42136 spin_lock_init(&md->deferred_lock);
42137 atomic_set(&md->holders, 1);
42138 atomic_set(&md->open_count, 0);
42139 - atomic_set(&md->event_nr, 0);
42140 - atomic_set(&md->uevent_seq, 0);
42141 + atomic_set_unchecked(&md->event_nr, 0);
42142 + atomic_set_unchecked(&md->uevent_seq, 0);
42143 INIT_LIST_HEAD(&md->uevent_list);
42144 spin_lock_init(&md->uevent_lock);
42145
42146 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42147
42148 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42149
42150 - atomic_inc(&md->event_nr);
42151 + atomic_inc_unchecked(&md->event_nr);
42152 wake_up(&md->eventq);
42153 }
42154
42155 @@ -2727,18 +2727,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42156
42157 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42158 {
42159 - return atomic_add_return(1, &md->uevent_seq);
42160 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42161 }
42162
42163 uint32_t dm_get_event_nr(struct mapped_device *md)
42164 {
42165 - return atomic_read(&md->event_nr);
42166 + return atomic_read_unchecked(&md->event_nr);
42167 }
42168
42169 int dm_wait_event(struct mapped_device *md, int event_nr)
42170 {
42171 return wait_event_interruptible(md->eventq,
42172 - (event_nr != atomic_read(&md->event_nr)));
42173 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42174 }
42175
42176 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42177 diff --git a/drivers/md/md.c b/drivers/md/md.c
42178 index 866f489..9bf9ba3 100644
42179 --- a/drivers/md/md.c
42180 +++ b/drivers/md/md.c
42181 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42182 * start build, activate spare
42183 */
42184 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42185 -static atomic_t md_event_count;
42186 +static atomic_unchecked_t md_event_count;
42187 void md_new_event(struct mddev *mddev)
42188 {
42189 - atomic_inc(&md_event_count);
42190 + atomic_inc_unchecked(&md_event_count);
42191 wake_up(&md_event_waiters);
42192 }
42193 EXPORT_SYMBOL_GPL(md_new_event);
42194 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42195 */
42196 static void md_new_event_inintr(struct mddev *mddev)
42197 {
42198 - atomic_inc(&md_event_count);
42199 + atomic_inc_unchecked(&md_event_count);
42200 wake_up(&md_event_waiters);
42201 }
42202
42203 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42204 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42205 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42206 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42207 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42208 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42209
42210 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42211 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42212 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42213 else
42214 sb->resync_offset = cpu_to_le64(0);
42215
42216 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42217 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42218
42219 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42220 sb->size = cpu_to_le64(mddev->dev_sectors);
42221 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42222 static ssize_t
42223 errors_show(struct md_rdev *rdev, char *page)
42224 {
42225 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42226 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42227 }
42228
42229 static ssize_t
42230 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42231 char *e;
42232 unsigned long n = simple_strtoul(buf, &e, 10);
42233 if (*buf && (*e == 0 || *e == '\n')) {
42234 - atomic_set(&rdev->corrected_errors, n);
42235 + atomic_set_unchecked(&rdev->corrected_errors, n);
42236 return len;
42237 }
42238 return -EINVAL;
42239 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42240 rdev->sb_loaded = 0;
42241 rdev->bb_page = NULL;
42242 atomic_set(&rdev->nr_pending, 0);
42243 - atomic_set(&rdev->read_errors, 0);
42244 - atomic_set(&rdev->corrected_errors, 0);
42245 + atomic_set_unchecked(&rdev->read_errors, 0);
42246 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42247
42248 INIT_LIST_HEAD(&rdev->same_set);
42249 init_waitqueue_head(&rdev->blocked_wait);
42250 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42251
42252 spin_unlock(&pers_lock);
42253 seq_printf(seq, "\n");
42254 - seq->poll_event = atomic_read(&md_event_count);
42255 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42256 return 0;
42257 }
42258 if (v == (void*)2) {
42259 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42260 return error;
42261
42262 seq = file->private_data;
42263 - seq->poll_event = atomic_read(&md_event_count);
42264 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42265 return error;
42266 }
42267
42268 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42269 /* always allow read */
42270 mask = POLLIN | POLLRDNORM;
42271
42272 - if (seq->poll_event != atomic_read(&md_event_count))
42273 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42274 mask |= POLLERR | POLLPRI;
42275 return mask;
42276 }
42277 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42278 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42279 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42280 (int)part_stat_read(&disk->part0, sectors[1]) -
42281 - atomic_read(&disk->sync_io);
42282 + atomic_read_unchecked(&disk->sync_io);
42283 /* sync IO will cause sync_io to increase before the disk_stats
42284 * as sync_io is counted when a request starts, and
42285 * disk_stats is counted when it completes.
42286 diff --git a/drivers/md/md.h b/drivers/md/md.h
42287 index 20f02c0..fd8c821 100644
42288 --- a/drivers/md/md.h
42289 +++ b/drivers/md/md.h
42290 @@ -94,13 +94,13 @@ struct md_rdev {
42291 * only maintained for arrays that
42292 * support hot removal
42293 */
42294 - atomic_t read_errors; /* number of consecutive read errors that
42295 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42296 * we have tried to ignore.
42297 */
42298 struct timespec last_read_error; /* monotonic time since our
42299 * last read error
42300 */
42301 - atomic_t corrected_errors; /* number of corrected read errors,
42302 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42303 * for reporting to userspace and storing
42304 * in superblock.
42305 */
42306 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42307
42308 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42309 {
42310 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42311 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42312 }
42313
42314 struct md_personality
42315 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42316 index 3e6d115..ffecdeb 100644
42317 --- a/drivers/md/persistent-data/dm-space-map.h
42318 +++ b/drivers/md/persistent-data/dm-space-map.h
42319 @@ -71,6 +71,7 @@ struct dm_space_map {
42320 dm_sm_threshold_fn fn,
42321 void *context);
42322 };
42323 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42324
42325 /*----------------------------------------------------------------*/
42326
42327 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42328 index aacf6bf..67d63f2 100644
42329 --- a/drivers/md/raid1.c
42330 +++ b/drivers/md/raid1.c
42331 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42332 if (r1_sync_page_io(rdev, sect, s,
42333 bio->bi_io_vec[idx].bv_page,
42334 READ) != 0)
42335 - atomic_add(s, &rdev->corrected_errors);
42336 + atomic_add_unchecked(s, &rdev->corrected_errors);
42337 }
42338 sectors -= s;
42339 sect += s;
42340 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42341 test_bit(In_sync, &rdev->flags)) {
42342 if (r1_sync_page_io(rdev, sect, s,
42343 conf->tmppage, READ)) {
42344 - atomic_add(s, &rdev->corrected_errors);
42345 + atomic_add_unchecked(s, &rdev->corrected_errors);
42346 printk(KERN_INFO
42347 "md/raid1:%s: read error corrected "
42348 "(%d sectors at %llu on %s)\n",
42349 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42350 index 73dc8a3..bdd515a 100644
42351 --- a/drivers/md/raid10.c
42352 +++ b/drivers/md/raid10.c
42353 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42354 /* The write handler will notice the lack of
42355 * R10BIO_Uptodate and record any errors etc
42356 */
42357 - atomic_add(r10_bio->sectors,
42358 + atomic_add_unchecked(r10_bio->sectors,
42359 &conf->mirrors[d].rdev->corrected_errors);
42360
42361 /* for reconstruct, we always reschedule after a read.
42362 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42363 {
42364 struct timespec cur_time_mon;
42365 unsigned long hours_since_last;
42366 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42367 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42368
42369 ktime_get_ts(&cur_time_mon);
42370
42371 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42372 * overflowing the shift of read_errors by hours_since_last.
42373 */
42374 if (hours_since_last >= 8 * sizeof(read_errors))
42375 - atomic_set(&rdev->read_errors, 0);
42376 + atomic_set_unchecked(&rdev->read_errors, 0);
42377 else
42378 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42379 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42380 }
42381
42382 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42383 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42384 return;
42385
42386 check_decay_read_errors(mddev, rdev);
42387 - atomic_inc(&rdev->read_errors);
42388 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42389 + atomic_inc_unchecked(&rdev->read_errors);
42390 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42391 char b[BDEVNAME_SIZE];
42392 bdevname(rdev->bdev, b);
42393
42394 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42395 "md/raid10:%s: %s: Raid device exceeded "
42396 "read_error threshold [cur %d:max %d]\n",
42397 mdname(mddev), b,
42398 - atomic_read(&rdev->read_errors), max_read_errors);
42399 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42400 printk(KERN_NOTICE
42401 "md/raid10:%s: %s: Failing raid device\n",
42402 mdname(mddev), b);
42403 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42404 sect +
42405 choose_data_offset(r10_bio, rdev)),
42406 bdevname(rdev->bdev, b));
42407 - atomic_add(s, &rdev->corrected_errors);
42408 + atomic_add_unchecked(s, &rdev->corrected_errors);
42409 }
42410
42411 rdev_dec_pending(rdev, mddev);
42412 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42413 index d825059..d5e4ec7 100644
42414 --- a/drivers/md/raid5.c
42415 +++ b/drivers/md/raid5.c
42416 @@ -1776,21 +1776,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42417 mdname(conf->mddev), STRIPE_SECTORS,
42418 (unsigned long long)s,
42419 bdevname(rdev->bdev, b));
42420 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42421 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42422 clear_bit(R5_ReadError, &sh->dev[i].flags);
42423 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42424 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42425 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42426
42427 - if (atomic_read(&rdev->read_errors))
42428 - atomic_set(&rdev->read_errors, 0);
42429 + if (atomic_read_unchecked(&rdev->read_errors))
42430 + atomic_set_unchecked(&rdev->read_errors, 0);
42431 } else {
42432 const char *bdn = bdevname(rdev->bdev, b);
42433 int retry = 0;
42434 int set_bad = 0;
42435
42436 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42437 - atomic_inc(&rdev->read_errors);
42438 + atomic_inc_unchecked(&rdev->read_errors);
42439 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42440 printk_ratelimited(
42441 KERN_WARNING
42442 @@ -1818,7 +1818,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42443 mdname(conf->mddev),
42444 (unsigned long long)s,
42445 bdn);
42446 - } else if (atomic_read(&rdev->read_errors)
42447 + } else if (atomic_read_unchecked(&rdev->read_errors)
42448 > conf->max_nr_stripes)
42449 printk(KERN_WARNING
42450 "md/raid:%s: Too many read errors, failing device %s.\n",
42451 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42452 index 401ef64..836e563 100644
42453 --- a/drivers/media/dvb-core/dvbdev.c
42454 +++ b/drivers/media/dvb-core/dvbdev.c
42455 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42456 const struct dvb_device *template, void *priv, int type)
42457 {
42458 struct dvb_device *dvbdev;
42459 - struct file_operations *dvbdevfops;
42460 + file_operations_no_const *dvbdevfops;
42461 struct device *clsdev;
42462 int minor;
42463 int id;
42464 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42465 index 9b6c3bb..baeb5c7 100644
42466 --- a/drivers/media/dvb-frontends/dib3000.h
42467 +++ b/drivers/media/dvb-frontends/dib3000.h
42468 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42469 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42470 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42471 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42472 -};
42473 +} __no_const;
42474
42475 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42476 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42477 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42478 index ecf21d9..b992428d 100644
42479 --- a/drivers/media/pci/cx88/cx88-video.c
42480 +++ b/drivers/media/pci/cx88/cx88-video.c
42481 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42482
42483 /* ------------------------------------------------------------------ */
42484
42485 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42486 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42487 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42488 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42489 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42490 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42491
42492 module_param_array(video_nr, int, NULL, 0444);
42493 module_param_array(vbi_nr, int, NULL, 0444);
42494 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42495 index c08ae3e..eb59af1 100644
42496 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42497 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42498 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42499 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42500
42501 /* ivtv instance counter */
42502 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42503 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42504
42505 /* Parameter declarations */
42506 static int cardtype[IVTV_MAX_CARDS];
42507 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42508 index dfd0a21..6bbb465 100644
42509 --- a/drivers/media/platform/omap/omap_vout.c
42510 +++ b/drivers/media/platform/omap/omap_vout.c
42511 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42512 OMAP_VIDEO2,
42513 };
42514
42515 -static struct videobuf_queue_ops video_vbq_ops;
42516 /* Variables configurable through module params*/
42517 static u32 video1_numbuffers = 3;
42518 static u32 video2_numbuffers = 3;
42519 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42520 {
42521 struct videobuf_queue *q;
42522 struct omap_vout_device *vout = NULL;
42523 + static struct videobuf_queue_ops video_vbq_ops = {
42524 + .buf_setup = omap_vout_buffer_setup,
42525 + .buf_prepare = omap_vout_buffer_prepare,
42526 + .buf_release = omap_vout_buffer_release,
42527 + .buf_queue = omap_vout_buffer_queue,
42528 + };
42529
42530 vout = video_drvdata(file);
42531 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42532 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42533 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42534
42535 q = &vout->vbq;
42536 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42537 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42538 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42539 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42540 spin_lock_init(&vout->vbq_lock);
42541
42542 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42543 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42544 index 04e6490..2df65bf 100644
42545 --- a/drivers/media/platform/s5p-tv/mixer.h
42546 +++ b/drivers/media/platform/s5p-tv/mixer.h
42547 @@ -156,7 +156,7 @@ struct mxr_layer {
42548 /** layer index (unique identifier) */
42549 int idx;
42550 /** callbacks for layer methods */
42551 - struct mxr_layer_ops ops;
42552 + struct mxr_layer_ops *ops;
42553 /** format array */
42554 const struct mxr_format **fmt_array;
42555 /** size of format array */
42556 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42557 index b93a21f..2535195 100644
42558 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42559 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42560 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42561 {
42562 struct mxr_layer *layer;
42563 int ret;
42564 - struct mxr_layer_ops ops = {
42565 + static struct mxr_layer_ops ops = {
42566 .release = mxr_graph_layer_release,
42567 .buffer_set = mxr_graph_buffer_set,
42568 .stream_set = mxr_graph_stream_set,
42569 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42570 index b713403..53cb5ad 100644
42571 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42572 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42573 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42574 layer->update_buf = next;
42575 }
42576
42577 - layer->ops.buffer_set(layer, layer->update_buf);
42578 + layer->ops->buffer_set(layer, layer->update_buf);
42579
42580 if (done && done != layer->shadow_buf)
42581 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42582 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42583 index 641b1f0..49cff30 100644
42584 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42585 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42586 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42587 layer->geo.src.height = layer->geo.src.full_height;
42588
42589 mxr_geometry_dump(mdev, &layer->geo);
42590 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42591 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42592 mxr_geometry_dump(mdev, &layer->geo);
42593 }
42594
42595 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42596 layer->geo.dst.full_width = mbus_fmt.width;
42597 layer->geo.dst.full_height = mbus_fmt.height;
42598 layer->geo.dst.field = mbus_fmt.field;
42599 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42600 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42601
42602 mxr_geometry_dump(mdev, &layer->geo);
42603 }
42604 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42605 /* set source size to highest accepted value */
42606 geo->src.full_width = max(geo->dst.full_width, pix->width);
42607 geo->src.full_height = max(geo->dst.full_height, pix->height);
42608 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42609 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42610 mxr_geometry_dump(mdev, &layer->geo);
42611 /* set cropping to total visible screen */
42612 geo->src.width = pix->width;
42613 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42614 geo->src.x_offset = 0;
42615 geo->src.y_offset = 0;
42616 /* assure consistency of geometry */
42617 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42618 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42619 mxr_geometry_dump(mdev, &layer->geo);
42620 /* set full size to lowest possible value */
42621 geo->src.full_width = 0;
42622 geo->src.full_height = 0;
42623 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42624 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42625 mxr_geometry_dump(mdev, &layer->geo);
42626
42627 /* returning results */
42628 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42629 target->width = s->r.width;
42630 target->height = s->r.height;
42631
42632 - layer->ops.fix_geometry(layer, stage, s->flags);
42633 + layer->ops->fix_geometry(layer, stage, s->flags);
42634
42635 /* retrieve update selection rectangle */
42636 res.left = target->x_offset;
42637 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42638 mxr_output_get(mdev);
42639
42640 mxr_layer_update_output(layer);
42641 - layer->ops.format_set(layer);
42642 + layer->ops->format_set(layer);
42643 /* enabling layer in hardware */
42644 spin_lock_irqsave(&layer->enq_slock, flags);
42645 layer->state = MXR_LAYER_STREAMING;
42646 spin_unlock_irqrestore(&layer->enq_slock, flags);
42647
42648 - layer->ops.stream_set(layer, MXR_ENABLE);
42649 + layer->ops->stream_set(layer, MXR_ENABLE);
42650 mxr_streamer_get(mdev);
42651
42652 return 0;
42653 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42654 spin_unlock_irqrestore(&layer->enq_slock, flags);
42655
42656 /* disabling layer in hardware */
42657 - layer->ops.stream_set(layer, MXR_DISABLE);
42658 + layer->ops->stream_set(layer, MXR_DISABLE);
42659 /* remove one streamer */
42660 mxr_streamer_put(mdev);
42661 /* allow changes in output configuration */
42662 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42663
42664 void mxr_layer_release(struct mxr_layer *layer)
42665 {
42666 - if (layer->ops.release)
42667 - layer->ops.release(layer);
42668 + if (layer->ops->release)
42669 + layer->ops->release(layer);
42670 }
42671
42672 void mxr_base_layer_release(struct mxr_layer *layer)
42673 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42674
42675 layer->mdev = mdev;
42676 layer->idx = idx;
42677 - layer->ops = *ops;
42678 + layer->ops = ops;
42679
42680 spin_lock_init(&layer->enq_slock);
42681 INIT_LIST_HEAD(&layer->enq_list);
42682 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42683 index 3d13a63..da31bf1 100644
42684 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42685 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42686 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42687 {
42688 struct mxr_layer *layer;
42689 int ret;
42690 - struct mxr_layer_ops ops = {
42691 + static struct mxr_layer_ops ops = {
42692 .release = mxr_vp_layer_release,
42693 .buffer_set = mxr_vp_buffer_set,
42694 .stream_set = mxr_vp_stream_set,
42695 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42696 index 545c04c..a14bded 100644
42697 --- a/drivers/media/radio/radio-cadet.c
42698 +++ b/drivers/media/radio/radio-cadet.c
42699 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42700 unsigned char readbuf[RDS_BUFFER];
42701 int i = 0;
42702
42703 + if (count > RDS_BUFFER)
42704 + return -EFAULT;
42705 mutex_lock(&dev->lock);
42706 if (dev->rdsstat == 0)
42707 cadet_start_rds(dev);
42708 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42709 while (i < count && dev->rdsin != dev->rdsout)
42710 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42711
42712 - if (i && copy_to_user(data, readbuf, i))
42713 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42714 i = -EFAULT;
42715 unlock:
42716 mutex_unlock(&dev->lock);
42717 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42718 index bd4d3a7..ffc0b9d 100644
42719 --- a/drivers/media/radio/radio-maxiradio.c
42720 +++ b/drivers/media/radio/radio-maxiradio.c
42721 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42722 /* TEA5757 pin mappings */
42723 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42724
42725 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42726 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42727
42728 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42729 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42730 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42731 index 8fa18ab..caee70f 100644
42732 --- a/drivers/media/radio/radio-shark.c
42733 +++ b/drivers/media/radio/radio-shark.c
42734 @@ -79,7 +79,7 @@ struct shark_device {
42735 u32 last_val;
42736 };
42737
42738 -static atomic_t shark_instance = ATOMIC_INIT(0);
42739 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42740
42741 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42742 {
42743 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42744 index 9fb6697..f167415 100644
42745 --- a/drivers/media/radio/radio-shark2.c
42746 +++ b/drivers/media/radio/radio-shark2.c
42747 @@ -74,7 +74,7 @@ struct shark_device {
42748 u8 *transfer_buffer;
42749 };
42750
42751 -static atomic_t shark_instance = ATOMIC_INIT(0);
42752 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42753
42754 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42755 {
42756 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42757 index 9c9084c..a9e8dfb 100644
42758 --- a/drivers/media/radio/radio-si476x.c
42759 +++ b/drivers/media/radio/radio-si476x.c
42760 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42761 struct si476x_radio *radio;
42762 struct v4l2_ctrl *ctrl;
42763
42764 - static atomic_t instance = ATOMIC_INIT(0);
42765 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42766
42767 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42768 if (!radio)
42769 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42770 index 1cf382a..c22998c 100644
42771 --- a/drivers/media/rc/rc-main.c
42772 +++ b/drivers/media/rc/rc-main.c
42773 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42774 int rc_register_device(struct rc_dev *dev)
42775 {
42776 static bool raw_init = false; /* raw decoders loaded? */
42777 - static atomic_t devno = ATOMIC_INIT(0);
42778 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42779 struct rc_map *rc_map;
42780 const char *path;
42781 int rc;
42782 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42783 */
42784 mutex_lock(&dev->lock);
42785
42786 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42787 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42788 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42789 dev_set_drvdata(&dev->dev, dev);
42790 rc = device_add(&dev->dev);
42791 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42792 index 3940bb0..fb3952a 100644
42793 --- a/drivers/media/usb/dvb-usb/cxusb.c
42794 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42795 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42796
42797 struct dib0700_adapter_state {
42798 int (*set_param_save) (struct dvb_frontend *);
42799 -};
42800 +} __no_const;
42801
42802 static int dib7070_set_param_override(struct dvb_frontend *fe)
42803 {
42804 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42805 index 6e237b6..dc25556 100644
42806 --- a/drivers/media/usb/dvb-usb/dw2102.c
42807 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42808 @@ -118,7 +118,7 @@ struct su3000_state {
42809
42810 struct s6x0_state {
42811 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42812 -};
42813 +} __no_const;
42814
42815 /* debug */
42816 static int dvb_usb_dw2102_debug;
42817 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42818 index 8f7a6a4..59502dd 100644
42819 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42820 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42821 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42822 __u32 reserved;
42823 };
42824
42825 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42826 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42827 enum v4l2_memory memory)
42828 {
42829 void __user *up_pln;
42830 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42831 return 0;
42832 }
42833
42834 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42835 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42836 enum v4l2_memory memory)
42837 {
42838 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42839 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42840 put_user(kp->start_block, &up->start_block) ||
42841 put_user(kp->blocks, &up->blocks) ||
42842 put_user(tmp, &up->edid) ||
42843 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42844 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42845 return -EFAULT;
42846 return 0;
42847 }
42848 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42849 index 02d1b63..5fd6b16 100644
42850 --- a/drivers/media/v4l2-core/v4l2-device.c
42851 +++ b/drivers/media/v4l2-core/v4l2-device.c
42852 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42853 EXPORT_SYMBOL_GPL(v4l2_device_put);
42854
42855 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42856 - atomic_t *instance)
42857 + atomic_unchecked_t *instance)
42858 {
42859 - int num = atomic_inc_return(instance) - 1;
42860 + int num = atomic_inc_return_unchecked(instance) - 1;
42861 int len = strlen(basename);
42862
42863 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42864 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42865 index 68e6b5e..d8b923e 100644
42866 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42867 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42868 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42869 struct file *file, void *fh, void *p);
42870 } u;
42871 void (*debug)(const void *arg, bool write_only);
42872 -};
42873 +} __do_const;
42874 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42875
42876 /* This control needs a priority check */
42877 #define INFO_FL_PRIO (1 << 0)
42878 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42879 struct video_device *vfd = video_devdata(file);
42880 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42881 bool write_only = false;
42882 - struct v4l2_ioctl_info default_info;
42883 + v4l2_ioctl_info_no_const default_info;
42884 const struct v4l2_ioctl_info *info;
42885 void *fh = file->private_data;
42886 struct v4l2_fh *vfh = NULL;
42887 @@ -2194,7 +2195,7 @@ done:
42888 }
42889
42890 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42891 - void * __user *user_ptr, void ***kernel_ptr)
42892 + void __user **user_ptr, void ***kernel_ptr)
42893 {
42894 int ret = 0;
42895
42896 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42897 ret = -EINVAL;
42898 break;
42899 }
42900 - *user_ptr = (void __user *)buf->m.planes;
42901 + *user_ptr = (void __force_user *)buf->m.planes;
42902 *kernel_ptr = (void *)&buf->m.planes;
42903 *array_size = sizeof(struct v4l2_plane) * buf->length;
42904 ret = 1;
42905 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42906 ret = -EINVAL;
42907 break;
42908 }
42909 - *user_ptr = (void __user *)ctrls->controls;
42910 + *user_ptr = (void __force_user *)ctrls->controls;
42911 *kernel_ptr = (void *)&ctrls->controls;
42912 *array_size = sizeof(struct v4l2_ext_control)
42913 * ctrls->count;
42914 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42915 index 767ff4d..c69d259 100644
42916 --- a/drivers/message/fusion/mptbase.c
42917 +++ b/drivers/message/fusion/mptbase.c
42918 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42919 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42920 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42921
42922 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42923 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42924 +#else
42925 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42926 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42927 +#endif
42928 +
42929 /*
42930 * Rounding UP to nearest 4-kB boundary here...
42931 */
42932 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42933 ioc->facts.GlobalCredits);
42934
42935 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42936 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42937 + NULL, NULL);
42938 +#else
42939 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42940 +#endif
42941 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42942 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42943 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42944 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42945 index dd239bd..689c4f7 100644
42946 --- a/drivers/message/fusion/mptsas.c
42947 +++ b/drivers/message/fusion/mptsas.c
42948 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42949 return 0;
42950 }
42951
42952 +static inline void
42953 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42954 +{
42955 + if (phy_info->port_details) {
42956 + phy_info->port_details->rphy = rphy;
42957 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42958 + ioc->name, rphy));
42959 + }
42960 +
42961 + if (rphy) {
42962 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42963 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42964 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42965 + ioc->name, rphy, rphy->dev.release));
42966 + }
42967 +}
42968 +
42969 /* no mutex */
42970 static void
42971 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42972 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42973 return NULL;
42974 }
42975
42976 -static inline void
42977 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42978 -{
42979 - if (phy_info->port_details) {
42980 - phy_info->port_details->rphy = rphy;
42981 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42982 - ioc->name, rphy));
42983 - }
42984 -
42985 - if (rphy) {
42986 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42987 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42988 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42989 - ioc->name, rphy, rphy->dev.release));
42990 - }
42991 -}
42992 -
42993 static inline struct sas_port *
42994 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42995 {
42996 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42997 index 727819c..ad74694 100644
42998 --- a/drivers/message/fusion/mptscsih.c
42999 +++ b/drivers/message/fusion/mptscsih.c
43000 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43001
43002 h = shost_priv(SChost);
43003
43004 - if (h) {
43005 - if (h->info_kbuf == NULL)
43006 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43007 - return h->info_kbuf;
43008 - h->info_kbuf[0] = '\0';
43009 + if (!h)
43010 + return NULL;
43011
43012 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43013 - h->info_kbuf[size-1] = '\0';
43014 - }
43015 + if (h->info_kbuf == NULL)
43016 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43017 + return h->info_kbuf;
43018 + h->info_kbuf[0] = '\0';
43019 +
43020 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43021 + h->info_kbuf[size-1] = '\0';
43022
43023 return h->info_kbuf;
43024 }
43025 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43026 index b7d87cd..3fb36da 100644
43027 --- a/drivers/message/i2o/i2o_proc.c
43028 +++ b/drivers/message/i2o/i2o_proc.c
43029 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43030 "Array Controller Device"
43031 };
43032
43033 -static char *chtostr(char *tmp, u8 *chars, int n)
43034 -{
43035 - tmp[0] = 0;
43036 - return strncat(tmp, (char *)chars, n);
43037 -}
43038 -
43039 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43040 char *group)
43041 {
43042 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43043 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43044 {
43045 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43046 - static u32 work32[5];
43047 - static u8 *work8 = (u8 *) work32;
43048 - static u16 *work16 = (u16 *) work32;
43049 + u32 work32[5];
43050 + u8 *work8 = (u8 *) work32;
43051 + u16 *work16 = (u16 *) work32;
43052 int token;
43053 u32 hwcap;
43054
43055 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43056 } *result;
43057
43058 i2o_exec_execute_ddm_table ddm_table;
43059 - char tmp[28 + 1];
43060
43061 result = kmalloc(sizeof(*result), GFP_KERNEL);
43062 if (!result)
43063 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43064
43065 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43066 seq_printf(seq, "%-#8x", ddm_table.module_id);
43067 - seq_printf(seq, "%-29s",
43068 - chtostr(tmp, ddm_table.module_name_version, 28));
43069 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43070 seq_printf(seq, "%9d ", ddm_table.data_size);
43071 seq_printf(seq, "%8d", ddm_table.code_size);
43072
43073 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43074
43075 i2o_driver_result_table *result;
43076 i2o_driver_store_table *dst;
43077 - char tmp[28 + 1];
43078
43079 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43080 if (result == NULL)
43081 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43082
43083 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43084 seq_printf(seq, "%-#8x", dst->module_id);
43085 - seq_printf(seq, "%-29s",
43086 - chtostr(tmp, dst->module_name_version, 28));
43087 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43088 + seq_printf(seq, "%-.28s", dst->module_name_version);
43089 + seq_printf(seq, "%-.8s", dst->date);
43090 seq_printf(seq, "%8d ", dst->module_size);
43091 seq_printf(seq, "%8d ", dst->mpb_size);
43092 seq_printf(seq, "0x%04x", dst->module_flags);
43093 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43094 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43095 {
43096 struct i2o_device *d = (struct i2o_device *)seq->private;
43097 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43098 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43099 // == (allow) 512d bytes (max)
43100 - static u16 *work16 = (u16 *) work32;
43101 + u16 *work16 = (u16 *) work32;
43102 int token;
43103 - char tmp[16 + 1];
43104
43105 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43106
43107 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43108 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43109 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43110 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43111 - seq_printf(seq, "Vendor info : %s\n",
43112 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43113 - seq_printf(seq, "Product info : %s\n",
43114 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43115 - seq_printf(seq, "Description : %s\n",
43116 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43117 - seq_printf(seq, "Product rev. : %s\n",
43118 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43119 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43120 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43121 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43122 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43123
43124 seq_printf(seq, "Serial number : ");
43125 print_serial_number(seq, (u8 *) (work32 + 16),
43126 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43127 u8 pad[256]; // allow up to 256 byte (max) serial number
43128 } result;
43129
43130 - char tmp[24 + 1];
43131 -
43132 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43133
43134 if (token < 0) {
43135 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43136 }
43137
43138 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43139 - seq_printf(seq, "Module name : %s\n",
43140 - chtostr(tmp, result.module_name, 24));
43141 - seq_printf(seq, "Module revision : %s\n",
43142 - chtostr(tmp, result.module_rev, 8));
43143 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43144 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43145
43146 seq_printf(seq, "Serial number : ");
43147 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43148 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43149 u8 instance_number[4];
43150 } result;
43151
43152 - char tmp[64 + 1];
43153 -
43154 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43155
43156 if (token < 0) {
43157 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43158 return 0;
43159 }
43160
43161 - seq_printf(seq, "Device name : %s\n",
43162 - chtostr(tmp, result.device_name, 64));
43163 - seq_printf(seq, "Service name : %s\n",
43164 - chtostr(tmp, result.service_name, 64));
43165 - seq_printf(seq, "Physical name : %s\n",
43166 - chtostr(tmp, result.physical_location, 64));
43167 - seq_printf(seq, "Instance number : %s\n",
43168 - chtostr(tmp, result.instance_number, 4));
43169 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43170 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43171 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43172 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43173
43174 return 0;
43175 }
43176 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43177 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43178 {
43179 struct i2o_device *d = (struct i2o_device *)seq->private;
43180 - static u32 work32[12];
43181 - static u16 *work16 = (u16 *) work32;
43182 - static u8 *work8 = (u8 *) work32;
43183 + u32 work32[12];
43184 + u16 *work16 = (u16 *) work32;
43185 + u8 *work8 = (u8 *) work32;
43186 int token;
43187
43188 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43189 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43190 index a8c08f3..155fe3d 100644
43191 --- a/drivers/message/i2o/iop.c
43192 +++ b/drivers/message/i2o/iop.c
43193 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43194
43195 spin_lock_irqsave(&c->context_list_lock, flags);
43196
43197 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43198 - atomic_inc(&c->context_list_counter);
43199 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43200 + atomic_inc_unchecked(&c->context_list_counter);
43201
43202 - entry->context = atomic_read(&c->context_list_counter);
43203 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43204
43205 list_add(&entry->list, &c->context_list);
43206
43207 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43208
43209 #if BITS_PER_LONG == 64
43210 spin_lock_init(&c->context_list_lock);
43211 - atomic_set(&c->context_list_counter, 0);
43212 + atomic_set_unchecked(&c->context_list_counter, 0);
43213 INIT_LIST_HEAD(&c->context_list);
43214 #endif
43215
43216 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43217 index fcbb2e9..2635e11 100644
43218 --- a/drivers/mfd/janz-cmodio.c
43219 +++ b/drivers/mfd/janz-cmodio.c
43220 @@ -13,6 +13,7 @@
43221
43222 #include <linux/kernel.h>
43223 #include <linux/module.h>
43224 +#include <linux/slab.h>
43225 #include <linux/init.h>
43226 #include <linux/pci.h>
43227 #include <linux/interrupt.h>
43228 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43229 index 8042b32..cba3166 100644
43230 --- a/drivers/mfd/max8925-i2c.c
43231 +++ b/drivers/mfd/max8925-i2c.c
43232 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43233 const struct i2c_device_id *id)
43234 {
43235 struct max8925_platform_data *pdata = client->dev.platform_data;
43236 - static struct max8925_chip *chip;
43237 + struct max8925_chip *chip;
43238 struct device_node *node = client->dev.of_node;
43239
43240 if (node && !pdata) {
43241 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43242 index d792772..cd73ba3 100644
43243 --- a/drivers/mfd/tps65910.c
43244 +++ b/drivers/mfd/tps65910.c
43245 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43246 struct tps65910_platform_data *pdata)
43247 {
43248 int ret = 0;
43249 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43250 + struct regmap_irq_chip *tps6591x_irqs_chip;
43251
43252 if (!irq) {
43253 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43254 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43255 index 9aa6d1e..1631bfc 100644
43256 --- a/drivers/mfd/twl4030-irq.c
43257 +++ b/drivers/mfd/twl4030-irq.c
43258 @@ -35,6 +35,7 @@
43259 #include <linux/of.h>
43260 #include <linux/irqdomain.h>
43261 #include <linux/i2c/twl.h>
43262 +#include <asm/pgtable.h>
43263
43264 #include "twl-core.h"
43265
43266 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43267 * Install an irq handler for each of the SIH modules;
43268 * clone dummy irq_chip since PIH can't *do* anything
43269 */
43270 - twl4030_irq_chip = dummy_irq_chip;
43271 - twl4030_irq_chip.name = "twl4030";
43272 + pax_open_kernel();
43273 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43274 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43275
43276 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43277 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43278 + pax_close_kernel();
43279
43280 for (i = irq_base; i < irq_end; i++) {
43281 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43282 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43283 index 277a8db..0e0b754 100644
43284 --- a/drivers/mfd/twl6030-irq.c
43285 +++ b/drivers/mfd/twl6030-irq.c
43286 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43287 * install an irq handler for each of the modules;
43288 * clone dummy irq_chip since PIH can't *do* anything
43289 */
43290 - twl6030_irq_chip = dummy_irq_chip;
43291 - twl6030_irq_chip.name = "twl6030";
43292 - twl6030_irq_chip.irq_set_type = NULL;
43293 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43294 + pax_open_kernel();
43295 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43296 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43297 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43298 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43299 + pax_close_kernel();
43300
43301 for (i = irq_base; i < irq_end; i++) {
43302 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43303 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43304 index f32550a..e3e52a2 100644
43305 --- a/drivers/misc/c2port/core.c
43306 +++ b/drivers/misc/c2port/core.c
43307 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43308 mutex_init(&c2dev->mutex);
43309
43310 /* Create binary file */
43311 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43312 + pax_open_kernel();
43313 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43314 + pax_close_kernel();
43315 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43316 if (unlikely(ret))
43317 goto error_device_create_bin_file;
43318 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43319 index 36f5d52..32311c3 100644
43320 --- a/drivers/misc/kgdbts.c
43321 +++ b/drivers/misc/kgdbts.c
43322 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43323 char before[BREAK_INSTR_SIZE];
43324 char after[BREAK_INSTR_SIZE];
43325
43326 - probe_kernel_read(before, (char *)kgdbts_break_test,
43327 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43328 BREAK_INSTR_SIZE);
43329 init_simple_test();
43330 ts.tst = plant_and_detach_test;
43331 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43332 /* Activate test with initial breakpoint */
43333 if (!is_early)
43334 kgdb_breakpoint();
43335 - probe_kernel_read(after, (char *)kgdbts_break_test,
43336 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43337 BREAK_INSTR_SIZE);
43338 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43339 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43340 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43341 index 036effe..b3a6336 100644
43342 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43343 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43344 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43345 * the lid is closed. This leads to interrupts as soon as a little move
43346 * is done.
43347 */
43348 - atomic_inc(&lis3->count);
43349 + atomic_inc_unchecked(&lis3->count);
43350
43351 wake_up_interruptible(&lis3->misc_wait);
43352 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43353 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43354 if (lis3->pm_dev)
43355 pm_runtime_get_sync(lis3->pm_dev);
43356
43357 - atomic_set(&lis3->count, 0);
43358 + atomic_set_unchecked(&lis3->count, 0);
43359 return 0;
43360 }
43361
43362 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43363 add_wait_queue(&lis3->misc_wait, &wait);
43364 while (true) {
43365 set_current_state(TASK_INTERRUPTIBLE);
43366 - data = atomic_xchg(&lis3->count, 0);
43367 + data = atomic_xchg_unchecked(&lis3->count, 0);
43368 if (data)
43369 break;
43370
43371 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43372 struct lis3lv02d, miscdev);
43373
43374 poll_wait(file, &lis3->misc_wait, wait);
43375 - if (atomic_read(&lis3->count))
43376 + if (atomic_read_unchecked(&lis3->count))
43377 return POLLIN | POLLRDNORM;
43378 return 0;
43379 }
43380 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43381 index c439c82..1f20f57 100644
43382 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43383 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43384 @@ -297,7 +297,7 @@ struct lis3lv02d {
43385 struct input_polled_dev *idev; /* input device */
43386 struct platform_device *pdev; /* platform device */
43387 struct regulator_bulk_data regulators[2];
43388 - atomic_t count; /* interrupt count after last read */
43389 + atomic_unchecked_t count; /* interrupt count after last read */
43390 union axis_conversion ac; /* hw -> logical axis */
43391 int mapped_btns[3];
43392
43393 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43394 index 2f30bad..c4c13d0 100644
43395 --- a/drivers/misc/sgi-gru/gruhandles.c
43396 +++ b/drivers/misc/sgi-gru/gruhandles.c
43397 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43398 unsigned long nsec;
43399
43400 nsec = CLKS2NSEC(clks);
43401 - atomic_long_inc(&mcs_op_statistics[op].count);
43402 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43403 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43404 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43405 if (mcs_op_statistics[op].max < nsec)
43406 mcs_op_statistics[op].max = nsec;
43407 }
43408 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43409 index 4f76359..cdfcb2e 100644
43410 --- a/drivers/misc/sgi-gru/gruprocfs.c
43411 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43412 @@ -32,9 +32,9 @@
43413
43414 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43415
43416 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43417 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43418 {
43419 - unsigned long val = atomic_long_read(v);
43420 + unsigned long val = atomic_long_read_unchecked(v);
43421
43422 seq_printf(s, "%16lu %s\n", val, id);
43423 }
43424 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43425
43426 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43427 for (op = 0; op < mcsop_last; op++) {
43428 - count = atomic_long_read(&mcs_op_statistics[op].count);
43429 - total = atomic_long_read(&mcs_op_statistics[op].total);
43430 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43431 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43432 max = mcs_op_statistics[op].max;
43433 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43434 count ? total / count : 0, max);
43435 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43436 index 5c3ce24..4915ccb 100644
43437 --- a/drivers/misc/sgi-gru/grutables.h
43438 +++ b/drivers/misc/sgi-gru/grutables.h
43439 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43440 * GRU statistics.
43441 */
43442 struct gru_stats_s {
43443 - atomic_long_t vdata_alloc;
43444 - atomic_long_t vdata_free;
43445 - atomic_long_t gts_alloc;
43446 - atomic_long_t gts_free;
43447 - atomic_long_t gms_alloc;
43448 - atomic_long_t gms_free;
43449 - atomic_long_t gts_double_allocate;
43450 - atomic_long_t assign_context;
43451 - atomic_long_t assign_context_failed;
43452 - atomic_long_t free_context;
43453 - atomic_long_t load_user_context;
43454 - atomic_long_t load_kernel_context;
43455 - atomic_long_t lock_kernel_context;
43456 - atomic_long_t unlock_kernel_context;
43457 - atomic_long_t steal_user_context;
43458 - atomic_long_t steal_kernel_context;
43459 - atomic_long_t steal_context_failed;
43460 - atomic_long_t nopfn;
43461 - atomic_long_t asid_new;
43462 - atomic_long_t asid_next;
43463 - atomic_long_t asid_wrap;
43464 - atomic_long_t asid_reuse;
43465 - atomic_long_t intr;
43466 - atomic_long_t intr_cbr;
43467 - atomic_long_t intr_tfh;
43468 - atomic_long_t intr_spurious;
43469 - atomic_long_t intr_mm_lock_failed;
43470 - atomic_long_t call_os;
43471 - atomic_long_t call_os_wait_queue;
43472 - atomic_long_t user_flush_tlb;
43473 - atomic_long_t user_unload_context;
43474 - atomic_long_t user_exception;
43475 - atomic_long_t set_context_option;
43476 - atomic_long_t check_context_retarget_intr;
43477 - atomic_long_t check_context_unload;
43478 - atomic_long_t tlb_dropin;
43479 - atomic_long_t tlb_preload_page;
43480 - atomic_long_t tlb_dropin_fail_no_asid;
43481 - atomic_long_t tlb_dropin_fail_upm;
43482 - atomic_long_t tlb_dropin_fail_invalid;
43483 - atomic_long_t tlb_dropin_fail_range_active;
43484 - atomic_long_t tlb_dropin_fail_idle;
43485 - atomic_long_t tlb_dropin_fail_fmm;
43486 - atomic_long_t tlb_dropin_fail_no_exception;
43487 - atomic_long_t tfh_stale_on_fault;
43488 - atomic_long_t mmu_invalidate_range;
43489 - atomic_long_t mmu_invalidate_page;
43490 - atomic_long_t flush_tlb;
43491 - atomic_long_t flush_tlb_gru;
43492 - atomic_long_t flush_tlb_gru_tgh;
43493 - atomic_long_t flush_tlb_gru_zero_asid;
43494 + atomic_long_unchecked_t vdata_alloc;
43495 + atomic_long_unchecked_t vdata_free;
43496 + atomic_long_unchecked_t gts_alloc;
43497 + atomic_long_unchecked_t gts_free;
43498 + atomic_long_unchecked_t gms_alloc;
43499 + atomic_long_unchecked_t gms_free;
43500 + atomic_long_unchecked_t gts_double_allocate;
43501 + atomic_long_unchecked_t assign_context;
43502 + atomic_long_unchecked_t assign_context_failed;
43503 + atomic_long_unchecked_t free_context;
43504 + atomic_long_unchecked_t load_user_context;
43505 + atomic_long_unchecked_t load_kernel_context;
43506 + atomic_long_unchecked_t lock_kernel_context;
43507 + atomic_long_unchecked_t unlock_kernel_context;
43508 + atomic_long_unchecked_t steal_user_context;
43509 + atomic_long_unchecked_t steal_kernel_context;
43510 + atomic_long_unchecked_t steal_context_failed;
43511 + atomic_long_unchecked_t nopfn;
43512 + atomic_long_unchecked_t asid_new;
43513 + atomic_long_unchecked_t asid_next;
43514 + atomic_long_unchecked_t asid_wrap;
43515 + atomic_long_unchecked_t asid_reuse;
43516 + atomic_long_unchecked_t intr;
43517 + atomic_long_unchecked_t intr_cbr;
43518 + atomic_long_unchecked_t intr_tfh;
43519 + atomic_long_unchecked_t intr_spurious;
43520 + atomic_long_unchecked_t intr_mm_lock_failed;
43521 + atomic_long_unchecked_t call_os;
43522 + atomic_long_unchecked_t call_os_wait_queue;
43523 + atomic_long_unchecked_t user_flush_tlb;
43524 + atomic_long_unchecked_t user_unload_context;
43525 + atomic_long_unchecked_t user_exception;
43526 + atomic_long_unchecked_t set_context_option;
43527 + atomic_long_unchecked_t check_context_retarget_intr;
43528 + atomic_long_unchecked_t check_context_unload;
43529 + atomic_long_unchecked_t tlb_dropin;
43530 + atomic_long_unchecked_t tlb_preload_page;
43531 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43532 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43533 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43534 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43535 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43536 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43537 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43538 + atomic_long_unchecked_t tfh_stale_on_fault;
43539 + atomic_long_unchecked_t mmu_invalidate_range;
43540 + atomic_long_unchecked_t mmu_invalidate_page;
43541 + atomic_long_unchecked_t flush_tlb;
43542 + atomic_long_unchecked_t flush_tlb_gru;
43543 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43544 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43545
43546 - atomic_long_t copy_gpa;
43547 - atomic_long_t read_gpa;
43548 + atomic_long_unchecked_t copy_gpa;
43549 + atomic_long_unchecked_t read_gpa;
43550
43551 - atomic_long_t mesq_receive;
43552 - atomic_long_t mesq_receive_none;
43553 - atomic_long_t mesq_send;
43554 - atomic_long_t mesq_send_failed;
43555 - atomic_long_t mesq_noop;
43556 - atomic_long_t mesq_send_unexpected_error;
43557 - atomic_long_t mesq_send_lb_overflow;
43558 - atomic_long_t mesq_send_qlimit_reached;
43559 - atomic_long_t mesq_send_amo_nacked;
43560 - atomic_long_t mesq_send_put_nacked;
43561 - atomic_long_t mesq_page_overflow;
43562 - atomic_long_t mesq_qf_locked;
43563 - atomic_long_t mesq_qf_noop_not_full;
43564 - atomic_long_t mesq_qf_switch_head_failed;
43565 - atomic_long_t mesq_qf_unexpected_error;
43566 - atomic_long_t mesq_noop_unexpected_error;
43567 - atomic_long_t mesq_noop_lb_overflow;
43568 - atomic_long_t mesq_noop_qlimit_reached;
43569 - atomic_long_t mesq_noop_amo_nacked;
43570 - atomic_long_t mesq_noop_put_nacked;
43571 - atomic_long_t mesq_noop_page_overflow;
43572 + atomic_long_unchecked_t mesq_receive;
43573 + atomic_long_unchecked_t mesq_receive_none;
43574 + atomic_long_unchecked_t mesq_send;
43575 + atomic_long_unchecked_t mesq_send_failed;
43576 + atomic_long_unchecked_t mesq_noop;
43577 + atomic_long_unchecked_t mesq_send_unexpected_error;
43578 + atomic_long_unchecked_t mesq_send_lb_overflow;
43579 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43580 + atomic_long_unchecked_t mesq_send_amo_nacked;
43581 + atomic_long_unchecked_t mesq_send_put_nacked;
43582 + atomic_long_unchecked_t mesq_page_overflow;
43583 + atomic_long_unchecked_t mesq_qf_locked;
43584 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43585 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43586 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43587 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43588 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43589 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43590 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43591 + atomic_long_unchecked_t mesq_noop_put_nacked;
43592 + atomic_long_unchecked_t mesq_noop_page_overflow;
43593
43594 };
43595
43596 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43597 tghop_invalidate, mcsop_last};
43598
43599 struct mcs_op_statistic {
43600 - atomic_long_t count;
43601 - atomic_long_t total;
43602 + atomic_long_unchecked_t count;
43603 + atomic_long_unchecked_t total;
43604 unsigned long max;
43605 };
43606
43607 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43608
43609 #define STAT(id) do { \
43610 if (gru_options & OPT_STATS) \
43611 - atomic_long_inc(&gru_stats.id); \
43612 + atomic_long_inc_unchecked(&gru_stats.id); \
43613 } while (0)
43614
43615 #ifdef CONFIG_SGI_GRU_DEBUG
43616 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43617 index c862cd4..0d176fe 100644
43618 --- a/drivers/misc/sgi-xp/xp.h
43619 +++ b/drivers/misc/sgi-xp/xp.h
43620 @@ -288,7 +288,7 @@ struct xpc_interface {
43621 xpc_notify_func, void *);
43622 void (*received) (short, int, void *);
43623 enum xp_retval (*partid_to_nasids) (short, void *);
43624 -};
43625 +} __no_const;
43626
43627 extern struct xpc_interface xpc_interface;
43628
43629 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43630 index b94d5f7..7f494c5 100644
43631 --- a/drivers/misc/sgi-xp/xpc.h
43632 +++ b/drivers/misc/sgi-xp/xpc.h
43633 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43634 void (*received_payload) (struct xpc_channel *, void *);
43635 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43636 };
43637 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43638
43639 /* struct xpc_partition act_state values (for XPC HB) */
43640
43641 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43642 /* found in xpc_main.c */
43643 extern struct device *xpc_part;
43644 extern struct device *xpc_chan;
43645 -extern struct xpc_arch_operations xpc_arch_ops;
43646 +extern xpc_arch_operations_no_const xpc_arch_ops;
43647 extern int xpc_disengage_timelimit;
43648 extern int xpc_disengage_timedout;
43649 extern int xpc_activate_IRQ_rcvd;
43650 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43651 index 82dc574..8539ab2 100644
43652 --- a/drivers/misc/sgi-xp/xpc_main.c
43653 +++ b/drivers/misc/sgi-xp/xpc_main.c
43654 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43655 .notifier_call = xpc_system_die,
43656 };
43657
43658 -struct xpc_arch_operations xpc_arch_ops;
43659 +xpc_arch_operations_no_const xpc_arch_ops;
43660
43661 /*
43662 * Timer function to enforce the timelimit on the partition disengage.
43663 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43664
43665 if (((die_args->trapnr == X86_TRAP_MF) ||
43666 (die_args->trapnr == X86_TRAP_XF)) &&
43667 - !user_mode_vm(die_args->regs))
43668 + !user_mode(die_args->regs))
43669 xpc_die_deactivate();
43670
43671 break;
43672 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43673 index 837fc73..acb5862 100644
43674 --- a/drivers/mmc/core/mmc_ops.c
43675 +++ b/drivers/mmc/core/mmc_ops.c
43676 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43677 void *data_buf;
43678 int is_on_stack;
43679
43680 - is_on_stack = object_is_on_stack(buf);
43681 + is_on_stack = object_starts_on_stack(buf);
43682 if (is_on_stack) {
43683 /*
43684 * dma onto stack is unsafe/nonportable, but callers to this
43685 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43686 index 81b2994..dce857e 100644
43687 --- a/drivers/mmc/host/dw_mmc.h
43688 +++ b/drivers/mmc/host/dw_mmc.h
43689 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43690 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43691 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43692 int (*parse_dt)(struct dw_mci *host);
43693 -};
43694 +} __do_const;
43695 #endif /* _DW_MMC_H_ */
43696 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43697 index c3785ed..1984c44 100644
43698 --- a/drivers/mmc/host/mmci.c
43699 +++ b/drivers/mmc/host/mmci.c
43700 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43701 }
43702
43703 if (variant->busy_detect) {
43704 - mmci_ops.card_busy = mmci_card_busy;
43705 + pax_open_kernel();
43706 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43707 + pax_close_kernel();
43708 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43709 }
43710
43711 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43712 index 926aaf6..8e153e2 100644
43713 --- a/drivers/mmc/host/sdhci-s3c.c
43714 +++ b/drivers/mmc/host/sdhci-s3c.c
43715 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43716 * we can use overriding functions instead of default.
43717 */
43718 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43719 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43720 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43721 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43722 + pax_open_kernel();
43723 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43724 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43725 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43726 + pax_close_kernel();
43727 }
43728
43729 /* It supports additional host capabilities if needed */
43730 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43731 index 096993f..f02c23b 100644
43732 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43733 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43734 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43735 size_t totlen = 0, thislen;
43736 int ret = 0;
43737 size_t buflen = 0;
43738 - static char *buffer;
43739 + char *buffer;
43740
43741 if (!ECCBUF_SIZE) {
43742 /* We should fall back to a general writev implementation.
43743 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43744 index 0c8bb6b..6f35deb 100644
43745 --- a/drivers/mtd/nand/denali.c
43746 +++ b/drivers/mtd/nand/denali.c
43747 @@ -24,6 +24,7 @@
43748 #include <linux/slab.h>
43749 #include <linux/mtd/mtd.h>
43750 #include <linux/module.h>
43751 +#include <linux/slab.h>
43752
43753 #include "denali.h"
43754
43755 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43756 index 51b9d6a..52af9a7 100644
43757 --- a/drivers/mtd/nftlmount.c
43758 +++ b/drivers/mtd/nftlmount.c
43759 @@ -24,6 +24,7 @@
43760 #include <asm/errno.h>
43761 #include <linux/delay.h>
43762 #include <linux/slab.h>
43763 +#include <linux/sched.h>
43764 #include <linux/mtd/mtd.h>
43765 #include <linux/mtd/nand.h>
43766 #include <linux/mtd/nftl.h>
43767 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43768 index f9d5615..99dd95f 100644
43769 --- a/drivers/mtd/sm_ftl.c
43770 +++ b/drivers/mtd/sm_ftl.c
43771 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43772 #define SM_CIS_VENDOR_OFFSET 0x59
43773 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43774 {
43775 - struct attribute_group *attr_group;
43776 + attribute_group_no_const *attr_group;
43777 struct attribute **attributes;
43778 struct sm_sysfs_attribute *vendor_attribute;
43779
43780 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43781 index 5e31046..82f8ddc 100644
43782 --- a/drivers/net/bonding/bond_main.c
43783 +++ b/drivers/net/bonding/bond_main.c
43784 @@ -4839,7 +4839,7 @@ static unsigned int bond_get_num_tx_queues(void)
43785 return tx_queues;
43786 }
43787
43788 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43789 +static struct rtnl_link_ops bond_link_ops = {
43790 .kind = "bond",
43791 .priv_size = sizeof(struct bonding),
43792 .setup = bond_setup,
43793 @@ -4964,8 +4964,8 @@ static void __exit bonding_exit(void)
43794
43795 bond_destroy_debugfs();
43796
43797 - rtnl_link_unregister(&bond_link_ops);
43798 unregister_pernet_subsys(&bond_net_ops);
43799 + rtnl_link_unregister(&bond_link_ops);
43800
43801 #ifdef CONFIG_NET_POLL_CONTROLLER
43802 /*
43803 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43804 index e1d2643..7f4133b 100644
43805 --- a/drivers/net/ethernet/8390/ax88796.c
43806 +++ b/drivers/net/ethernet/8390/ax88796.c
43807 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43808 if (ax->plat->reg_offsets)
43809 ei_local->reg_offset = ax->plat->reg_offsets;
43810 else {
43811 + resource_size_t _mem_size = mem_size;
43812 + do_div(_mem_size, 0x18);
43813 ei_local->reg_offset = ax->reg_offsets;
43814 for (ret = 0; ret < 0x18; ret++)
43815 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43816 + ax->reg_offsets[ret] = _mem_size * ret;
43817 }
43818
43819 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43820 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43821 index c07a6d0..ca88c45 100644
43822 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43823 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43824 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43825 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43826 {
43827 /* RX_MODE controlling object */
43828 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43829 + bnx2x_init_rx_mode_obj(bp);
43830
43831 /* multicast configuration controlling object */
43832 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43833 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43834 index 8f03c98..dd0ef10 100644
43835 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43836 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43837 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43838 return rc;
43839 }
43840
43841 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43842 - struct bnx2x_rx_mode_obj *o)
43843 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43844 {
43845 if (CHIP_IS_E1x(bp)) {
43846 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43847 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43848 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43849 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43850 } else {
43851 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43852 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43853 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43854 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43855 }
43856 }
43857
43858 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43859 index 798dfe9..05d0a44 100644
43860 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43861 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43862 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43863
43864 /********************* RX MODE ****************/
43865
43866 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43867 - struct bnx2x_rx_mode_obj *o);
43868 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43869
43870 /**
43871 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43872 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43873 index cd63d11..b67dd78 100644
43874 --- a/drivers/net/ethernet/broadcom/tg3.h
43875 +++ b/drivers/net/ethernet/broadcom/tg3.h
43876 @@ -147,6 +147,7 @@
43877 #define CHIPREV_ID_5750_A0 0x4000
43878 #define CHIPREV_ID_5750_A1 0x4001
43879 #define CHIPREV_ID_5750_A3 0x4003
43880 +#define CHIPREV_ID_5750_C1 0x4201
43881 #define CHIPREV_ID_5750_C2 0x4202
43882 #define CHIPREV_ID_5752_A0_HW 0x5000
43883 #define CHIPREV_ID_5752_A0 0x6000
43884 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43885 index 8cffcdf..aadf043 100644
43886 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43887 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43888 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43889 */
43890 struct l2t_skb_cb {
43891 arp_failure_handler_func arp_failure_handler;
43892 -};
43893 +} __no_const;
43894
43895 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43896
43897 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43898 index 5a3256b..60f16d8 100644
43899 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43900 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43901 @@ -2177,7 +2177,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43902
43903 int i;
43904 struct adapter *ap = netdev2adap(dev);
43905 - static const unsigned int *reg_ranges;
43906 + const unsigned int *reg_ranges;
43907 int arr_size = 0, buf_size = 0;
43908
43909 if (is_t4(ap->chip)) {
43910 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43911 index 4c83003..2a2a5b9 100644
43912 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43913 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43914 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43915 for (i=0; i<ETH_ALEN; i++) {
43916 tmp.addr[i] = dev->dev_addr[i];
43917 }
43918 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43919 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43920 break;
43921
43922 case DE4X5_SET_HWADDR: /* Set the hardware address */
43923 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43924 spin_lock_irqsave(&lp->lock, flags);
43925 memcpy(&statbuf, &lp->pktStats, ioc->len);
43926 spin_unlock_irqrestore(&lp->lock, flags);
43927 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43928 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43929 return -EFAULT;
43930 break;
43931 }
43932 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43933 index 3d91a5e..1014702 100644
43934 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43935 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43936 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43937
43938 if (wrapped)
43939 newacc += 65536;
43940 - ACCESS_ONCE(*acc) = newacc;
43941 + ACCESS_ONCE_RW(*acc) = newacc;
43942 }
43943
43944 void populate_erx_stats(struct be_adapter *adapter,
43945 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43946 index 934e1ae..b262e6b 100644
43947 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43948 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43949 @@ -31,6 +31,8 @@
43950 #include <linux/netdevice.h>
43951 #include <linux/phy.h>
43952 #include <linux/platform_device.h>
43953 +#include <linux/interrupt.h>
43954 +#include <linux/irqreturn.h>
43955 #include <net/ip.h>
43956
43957 #include "ftgmac100.h"
43958 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43959 index 4658f4c..407d155 100644
43960 --- a/drivers/net/ethernet/faraday/ftmac100.c
43961 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43962 @@ -31,6 +31,8 @@
43963 #include <linux/module.h>
43964 #include <linux/netdevice.h>
43965 #include <linux/platform_device.h>
43966 +#include <linux/interrupt.h>
43967 +#include <linux/irqreturn.h>
43968
43969 #include "ftmac100.h"
43970
43971 diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43972 index 85fe7b5..e2da180 100644
43973 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
43974 +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43975 @@ -2637,6 +2637,8 @@ static int igb_set_eee(struct net_device *netdev,
43976 (hw->phy.media_type != e1000_media_type_copper))
43977 return -EOPNOTSUPP;
43978
43979 + memset(&eee_curr, 0, sizeof(struct ethtool_eee));
43980 +
43981 ret_val = igb_get_eee(netdev, &eee_curr);
43982 if (ret_val)
43983 return ret_val;
43984 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43985 index 331987d..3be1135 100644
43986 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43987 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43988 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43989 }
43990
43991 /* update the base incval used to calculate frequency adjustment */
43992 - ACCESS_ONCE(adapter->base_incval) = incval;
43993 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43994 smp_mb();
43995
43996 /* need lock to prevent incorrect read while modifying cyclecounter */
43997 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43998 index fbe5363..266b4e3 100644
43999 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44000 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44001 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44002 struct __vxge_hw_fifo *fifo;
44003 struct vxge_hw_fifo_config *config;
44004 u32 txdl_size, txdl_per_memblock;
44005 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44006 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44007 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44008 + };
44009 +
44010 struct __vxge_hw_virtualpath *vpath;
44011
44012 if ((vp == NULL) || (attr == NULL)) {
44013 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44014 goto exit;
44015 }
44016
44017 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44018 -
44019 fifo->mempool =
44020 __vxge_hw_mempool_create(vpath->hldev,
44021 fifo->config->memblock_size,
44022 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44023 index 345d987..af69721 100644
44024 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44025 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44026 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44027 op_mode = QLC_83XX_DEFAULT_OPMODE;
44028
44029 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44030 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44031 + pax_open_kernel();
44032 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44033 + pax_close_kernel();
44034 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44035 } else {
44036 return -EIO;
44037 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44038 index 599d1fd..59868fe 100644
44039 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44040 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44041 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44042 case QLCNIC_NON_PRIV_FUNC:
44043 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44044 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44045 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44046 + pax_open_kernel();
44047 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44048 + pax_close_kernel();
44049 break;
44050 case QLCNIC_PRIV_FUNC:
44051 ahw->op_mode = QLCNIC_PRIV_FUNC;
44052 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44053 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44054 + pax_open_kernel();
44055 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44056 + pax_close_kernel();
44057 break;
44058 case QLCNIC_MGMT_FUNC:
44059 ahw->op_mode = QLCNIC_MGMT_FUNC;
44060 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44061 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44062 + pax_open_kernel();
44063 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44064 + pax_close_kernel();
44065 break;
44066 default:
44067 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44068 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44069 index 79e54ef..dec4019 100644
44070 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44071 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44072 @@ -1105,7 +1105,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44073 struct qlcnic_dump_entry *entry;
44074 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44075 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44076 - static const struct qlcnic_dump_operations *fw_dump_ops;
44077 + const struct qlcnic_dump_operations *fw_dump_ops;
44078 struct device *dev = &adapter->pdev->dev;
44079 struct qlcnic_hardware_context *ahw;
44080 void *temp_buffer;
44081 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44082 index 7ba68e0..618c73d 100644
44083 --- a/drivers/net/ethernet/realtek/r8169.c
44084 +++ b/drivers/net/ethernet/realtek/r8169.c
44085 @@ -759,22 +759,22 @@ struct rtl8169_private {
44086 struct mdio_ops {
44087 void (*write)(struct rtl8169_private *, int, int);
44088 int (*read)(struct rtl8169_private *, int);
44089 - } mdio_ops;
44090 + } __no_const mdio_ops;
44091
44092 struct pll_power_ops {
44093 void (*down)(struct rtl8169_private *);
44094 void (*up)(struct rtl8169_private *);
44095 - } pll_power_ops;
44096 + } __no_const pll_power_ops;
44097
44098 struct jumbo_ops {
44099 void (*enable)(struct rtl8169_private *);
44100 void (*disable)(struct rtl8169_private *);
44101 - } jumbo_ops;
44102 + } __no_const jumbo_ops;
44103
44104 struct csi_ops {
44105 void (*write)(struct rtl8169_private *, int, int);
44106 u32 (*read)(struct rtl8169_private *, int);
44107 - } csi_ops;
44108 + } __no_const csi_ops;
44109
44110 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44111 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44112 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44113 index b495394..0748c54 100644
44114 --- a/drivers/net/ethernet/sfc/ptp.c
44115 +++ b/drivers/net/ethernet/sfc/ptp.c
44116 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44117 (u32)((u64)ptp->start.dma_addr >> 32));
44118
44119 /* Clear flag that signals MC ready */
44120 - ACCESS_ONCE(*start) = 0;
44121 + ACCESS_ONCE_RW(*start) = 0;
44122 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44123 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44124
44125 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44126 index 50617c5..b13724c 100644
44127 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44128 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44129 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44130
44131 writel(value, ioaddr + MMC_CNTRL);
44132
44133 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44134 - MMC_CNTRL, value);
44135 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44136 +// MMC_CNTRL, value);
44137 }
44138
44139 /* To mask all all interrupts.*/
44140 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44141 index e6fe0d8..2b7d752 100644
44142 --- a/drivers/net/hyperv/hyperv_net.h
44143 +++ b/drivers/net/hyperv/hyperv_net.h
44144 @@ -101,7 +101,7 @@ struct rndis_device {
44145
44146 enum rndis_device_state state;
44147 bool link_state;
44148 - atomic_t new_req_id;
44149 + atomic_unchecked_t new_req_id;
44150
44151 spinlock_t request_lock;
44152 struct list_head req_list;
44153 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44154 index 0775f0a..d4fb316 100644
44155 --- a/drivers/net/hyperv/rndis_filter.c
44156 +++ b/drivers/net/hyperv/rndis_filter.c
44157 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44158 * template
44159 */
44160 set = &rndis_msg->msg.set_req;
44161 - set->req_id = atomic_inc_return(&dev->new_req_id);
44162 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44163
44164 /* Add to the request list */
44165 spin_lock_irqsave(&dev->request_lock, flags);
44166 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44167
44168 /* Setup the rndis set */
44169 halt = &request->request_msg.msg.halt_req;
44170 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44171 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44172
44173 /* Ignore return since this msg is optional. */
44174 rndis_filter_send_request(dev, request);
44175 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44176 index bf0d55e..82bcfbd1 100644
44177 --- a/drivers/net/ieee802154/fakehard.c
44178 +++ b/drivers/net/ieee802154/fakehard.c
44179 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44180 phy->transmit_power = 0xbf;
44181
44182 dev->netdev_ops = &fake_ops;
44183 - dev->ml_priv = &fake_mlme;
44184 + dev->ml_priv = (void *)&fake_mlme;
44185
44186 priv = netdev_priv(dev);
44187 priv->phy = phy;
44188 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44189 index 16b43bf..ead0c35 100644
44190 --- a/drivers/net/macvlan.c
44191 +++ b/drivers/net/macvlan.c
44192 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44193 int macvlan_link_register(struct rtnl_link_ops *ops)
44194 {
44195 /* common fields */
44196 - ops->priv_size = sizeof(struct macvlan_dev);
44197 - ops->validate = macvlan_validate;
44198 - ops->maxtype = IFLA_MACVLAN_MAX;
44199 - ops->policy = macvlan_policy;
44200 - ops->changelink = macvlan_changelink;
44201 - ops->get_size = macvlan_get_size;
44202 - ops->fill_info = macvlan_fill_info;
44203 + pax_open_kernel();
44204 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44205 + *(void **)&ops->validate = macvlan_validate;
44206 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44207 + *(const void **)&ops->policy = macvlan_policy;
44208 + *(void **)&ops->changelink = macvlan_changelink;
44209 + *(void **)&ops->get_size = macvlan_get_size;
44210 + *(void **)&ops->fill_info = macvlan_fill_info;
44211 + pax_close_kernel();
44212
44213 return rtnl_link_register(ops);
44214 };
44215 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44216 return NOTIFY_DONE;
44217 }
44218
44219 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44220 +static struct notifier_block macvlan_notifier_block = {
44221 .notifier_call = macvlan_device_event,
44222 };
44223
44224 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44225 index ea53abb..2e4d087 100644
44226 --- a/drivers/net/macvtap.c
44227 +++ b/drivers/net/macvtap.c
44228 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44229 return NOTIFY_DONE;
44230 }
44231
44232 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44233 +static struct notifier_block macvtap_notifier_block = {
44234 .notifier_call = macvtap_device_event,
44235 };
44236
44237 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44238 index daec9b0..6428fcb 100644
44239 --- a/drivers/net/phy/mdio-bitbang.c
44240 +++ b/drivers/net/phy/mdio-bitbang.c
44241 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44242 struct mdiobb_ctrl *ctrl = bus->priv;
44243
44244 module_put(ctrl->ops->owner);
44245 + mdiobus_unregister(bus);
44246 mdiobus_free(bus);
44247 }
44248 EXPORT_SYMBOL(free_mdio_bitbang);
44249 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44250 index 72ff14b..11d442d 100644
44251 --- a/drivers/net/ppp/ppp_generic.c
44252 +++ b/drivers/net/ppp/ppp_generic.c
44253 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44254 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44255 struct ppp_stats stats;
44256 struct ppp_comp_stats cstats;
44257 - char *vers;
44258
44259 switch (cmd) {
44260 case SIOCGPPPSTATS:
44261 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44262 break;
44263
44264 case SIOCGPPPVER:
44265 - vers = PPP_VERSION;
44266 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44267 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44268 break;
44269 err = 0;
44270 break;
44271 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44272 index 1252d9c..80e660b 100644
44273 --- a/drivers/net/slip/slhc.c
44274 +++ b/drivers/net/slip/slhc.c
44275 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44276 register struct tcphdr *thp;
44277 register struct iphdr *ip;
44278 register struct cstate *cs;
44279 - int len, hdrlen;
44280 + long len, hdrlen;
44281 unsigned char *cp = icp;
44282
44283 /* We've got a compressed packet; read the change byte */
44284 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44285 index bff7e0b..7315137 100644
44286 --- a/drivers/net/team/team.c
44287 +++ b/drivers/net/team/team.c
44288 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44289 return NOTIFY_DONE;
44290 }
44291
44292 -static struct notifier_block team_notifier_block __read_mostly = {
44293 +static struct notifier_block team_notifier_block = {
44294 .notifier_call = team_device_event,
44295 };
44296
44297 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44298 index 68b9aa3..b3c20f3 100644
44299 --- a/drivers/net/tun.c
44300 +++ b/drivers/net/tun.c
44301 @@ -1874,7 +1874,7 @@ unlock:
44302 }
44303
44304 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44305 - unsigned long arg, int ifreq_len)
44306 + unsigned long arg, size_t ifreq_len)
44307 {
44308 struct tun_file *tfile = file->private_data;
44309 struct tun_struct *tun;
44310 @@ -1886,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44311 int vnet_hdr_sz;
44312 int ret;
44313
44314 + if (ifreq_len > sizeof ifr)
44315 + return -EFAULT;
44316 +
44317 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44318 if (copy_from_user(&ifr, argp, ifreq_len))
44319 return -EFAULT;
44320 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44321 index 86292e6..8d34433 100644
44322 --- a/drivers/net/usb/hso.c
44323 +++ b/drivers/net/usb/hso.c
44324 @@ -71,7 +71,7 @@
44325 #include <asm/byteorder.h>
44326 #include <linux/serial_core.h>
44327 #include <linux/serial.h>
44328 -
44329 +#include <asm/local.h>
44330
44331 #define MOD_AUTHOR "Option Wireless"
44332 #define MOD_DESCRIPTION "USB High Speed Option driver"
44333 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44334 struct urb *urb;
44335
44336 urb = serial->rx_urb[0];
44337 - if (serial->port.count > 0) {
44338 + if (atomic_read(&serial->port.count) > 0) {
44339 count = put_rxbuf_data(urb, serial);
44340 if (count == -1)
44341 return;
44342 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44343 DUMP1(urb->transfer_buffer, urb->actual_length);
44344
44345 /* Anyone listening? */
44346 - if (serial->port.count == 0)
44347 + if (atomic_read(&serial->port.count) == 0)
44348 return;
44349
44350 if (status == 0) {
44351 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44352 tty_port_tty_set(&serial->port, tty);
44353
44354 /* check for port already opened, if not set the termios */
44355 - serial->port.count++;
44356 - if (serial->port.count == 1) {
44357 + if (atomic_inc_return(&serial->port.count) == 1) {
44358 serial->rx_state = RX_IDLE;
44359 /* Force default termio settings */
44360 _hso_serial_set_termios(tty, NULL);
44361 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44362 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44363 if (result) {
44364 hso_stop_serial_device(serial->parent);
44365 - serial->port.count--;
44366 + atomic_dec(&serial->port.count);
44367 kref_put(&serial->parent->ref, hso_serial_ref_free);
44368 }
44369 } else {
44370 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44371
44372 /* reset the rts and dtr */
44373 /* do the actual close */
44374 - serial->port.count--;
44375 + atomic_dec(&serial->port.count);
44376
44377 - if (serial->port.count <= 0) {
44378 - serial->port.count = 0;
44379 + if (atomic_read(&serial->port.count) <= 0) {
44380 + atomic_set(&serial->port.count, 0);
44381 tty_port_tty_set(&serial->port, NULL);
44382 if (!usb_gone)
44383 hso_stop_serial_device(serial->parent);
44384 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44385
44386 /* the actual setup */
44387 spin_lock_irqsave(&serial->serial_lock, flags);
44388 - if (serial->port.count)
44389 + if (atomic_read(&serial->port.count))
44390 _hso_serial_set_termios(tty, old);
44391 else
44392 tty->termios = *old;
44393 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44394 D1("Pending read interrupt on port %d\n", i);
44395 spin_lock(&serial->serial_lock);
44396 if (serial->rx_state == RX_IDLE &&
44397 - serial->port.count > 0) {
44398 + atomic_read(&serial->port.count) > 0) {
44399 /* Setup and send a ctrl req read on
44400 * port i */
44401 if (!serial->rx_urb_filled[0]) {
44402 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44403 /* Start all serial ports */
44404 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44405 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44406 - if (dev2ser(serial_table[i])->port.count) {
44407 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44408 result =
44409 hso_start_serial_device(serial_table[i], GFP_NOIO);
44410 hso_kick_transmit(dev2ser(serial_table[i]));
44411 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44412 index a79e9d3..78cd4fa 100644
44413 --- a/drivers/net/usb/sierra_net.c
44414 +++ b/drivers/net/usb/sierra_net.c
44415 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44416 /* atomic counter partially included in MAC address to make sure 2 devices
44417 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44418 */
44419 -static atomic_t iface_counter = ATOMIC_INIT(0);
44420 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44421
44422 /*
44423 * SYNC Timer Delay definition used to set the expiry time
44424 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44425 dev->net->netdev_ops = &sierra_net_device_ops;
44426
44427 /* change MAC addr to include, ifacenum, and to be unique */
44428 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44429 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44430 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44431
44432 /* we will have to manufacture ethernet headers, prepare template */
44433 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44434 index 8a05d77..ba8b9c5 100644
44435 --- a/drivers/net/vxlan.c
44436 +++ b/drivers/net/vxlan.c
44437 @@ -1870,7 +1870,7 @@ nla_put_failure:
44438 return -EMSGSIZE;
44439 }
44440
44441 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44442 +static struct rtnl_link_ops vxlan_link_ops = {
44443 .kind = "vxlan",
44444 .maxtype = IFLA_VXLAN_MAX,
44445 .policy = vxlan_policy,
44446 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44447 index 0b60295..b8bfa5b 100644
44448 --- a/drivers/net/wimax/i2400m/rx.c
44449 +++ b/drivers/net/wimax/i2400m/rx.c
44450 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44451 if (i2400m->rx_roq == NULL)
44452 goto error_roq_alloc;
44453
44454 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44455 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44456 GFP_KERNEL);
44457 if (rd == NULL) {
44458 result = -ENOMEM;
44459 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44460 index d0adbaf..6cedbf0 100644
44461 --- a/drivers/net/wireless/airo.c
44462 +++ b/drivers/net/wireless/airo.c
44463 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44464 struct airo_info *ai = dev->ml_priv;
44465 int ridcode;
44466 int enabled;
44467 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44468 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44469 unsigned char *iobuf;
44470
44471 /* Only super-user can write RIDs */
44472 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44473 index 34c8a33..3261fdc 100644
44474 --- a/drivers/net/wireless/at76c50x-usb.c
44475 +++ b/drivers/net/wireless/at76c50x-usb.c
44476 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44477 }
44478
44479 /* Convert timeout from the DFU status to jiffies */
44480 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44481 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44482 {
44483 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44484 | (s->poll_timeout[1] << 8)
44485 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44486 index 2b3426b..1f564be 100644
44487 --- a/drivers/net/wireless/ath/ath10k/core.c
44488 +++ b/drivers/net/wireless/ath/ath10k/core.c
44489 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44490
44491 int ath10k_core_register(struct ath10k *ar)
44492 {
44493 - struct ath10k_htc_ops htc_ops;
44494 + static struct ath10k_htc_ops htc_ops = {
44495 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44496 + };
44497 struct bmi_target_info target_info;
44498 int status;
44499
44500 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44501 if (status)
44502 goto err;
44503
44504 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44505 -
44506 ar->htc = ath10k_htc_create(ar, &htc_ops);
44507 if (IS_ERR(ar->htc)) {
44508 status = PTR_ERR(ar->htc);
44509 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44510 index 74363c9..237b926 100644
44511 --- a/drivers/net/wireless/ath/ath10k/htc.c
44512 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44513 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44514 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44515 struct ath10k_htc_ops *htc_ops)
44516 {
44517 - struct ath10k_hif_cb htc_callbacks;
44518 + static struct ath10k_hif_cb htc_callbacks = {
44519 + .rx_completion = ath10k_htc_rx_completion_handler,
44520 + .tx_completion = ath10k_htc_tx_completion_handler,
44521 + };
44522 struct ath10k_htc_ep *ep = NULL;
44523 struct ath10k_htc *htc = NULL;
44524
44525 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44526 ath10k_htc_reset_endpoint_states(htc);
44527
44528 /* setup HIF layer callbacks */
44529 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44530 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44531 htc->ar = ar;
44532
44533 /* Get HIF default pipe for HTC message exchange */
44534 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44535 index 8d78253..bebbb68 100644
44536 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44537 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44538 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44539 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44540 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44541
44542 - ACCESS_ONCE(ads->ds_link) = i->link;
44543 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44544 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44545 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44546
44547 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44548 ctl6 = SM(i->keytype, AR_EncrType);
44549 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44550
44551 if ((i->is_first || i->is_last) &&
44552 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44553 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44554 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44555 | set11nTries(i->rates, 1)
44556 | set11nTries(i->rates, 2)
44557 | set11nTries(i->rates, 3)
44558 | (i->dur_update ? AR_DurUpdateEna : 0)
44559 | SM(0, AR_BurstDur);
44560
44561 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44562 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44563 | set11nRate(i->rates, 1)
44564 | set11nRate(i->rates, 2)
44565 | set11nRate(i->rates, 3);
44566 } else {
44567 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44568 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44569 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44570 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44571 }
44572
44573 if (!i->is_first) {
44574 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44575 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44576 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44577 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44578 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44579 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44580 return;
44581 }
44582
44583 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44584 break;
44585 }
44586
44587 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44588 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44589 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44590 | SM(i->txpower, AR_XmitPower)
44591 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44592 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44593 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44594 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44595
44596 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44597 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44598 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44599 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44600
44601 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44602 return;
44603
44604 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44605 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44606 | set11nPktDurRTSCTS(i->rates, 1);
44607
44608 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44609 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44610 | set11nPktDurRTSCTS(i->rates, 3);
44611
44612 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44613 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44614 | set11nRateFlags(i->rates, 1)
44615 | set11nRateFlags(i->rates, 2)
44616 | set11nRateFlags(i->rates, 3)
44617 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44618 index 5163abd..3ada4c2 100644
44619 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44620 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44621 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44622 (i->qcu << AR_TxQcuNum_S) | desc_len;
44623
44624 checksum += val;
44625 - ACCESS_ONCE(ads->info) = val;
44626 + ACCESS_ONCE_RW(ads->info) = val;
44627
44628 checksum += i->link;
44629 - ACCESS_ONCE(ads->link) = i->link;
44630 + ACCESS_ONCE_RW(ads->link) = i->link;
44631
44632 checksum += i->buf_addr[0];
44633 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44634 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44635 checksum += i->buf_addr[1];
44636 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44637 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44638 checksum += i->buf_addr[2];
44639 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44640 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44641 checksum += i->buf_addr[3];
44642 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44643 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44644
44645 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44646 - ACCESS_ONCE(ads->ctl3) = val;
44647 + ACCESS_ONCE_RW(ads->ctl3) = val;
44648 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44649 - ACCESS_ONCE(ads->ctl5) = val;
44650 + ACCESS_ONCE_RW(ads->ctl5) = val;
44651 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44652 - ACCESS_ONCE(ads->ctl7) = val;
44653 + ACCESS_ONCE_RW(ads->ctl7) = val;
44654 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44655 - ACCESS_ONCE(ads->ctl9) = val;
44656 + ACCESS_ONCE_RW(ads->ctl9) = val;
44657
44658 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44659 - ACCESS_ONCE(ads->ctl10) = checksum;
44660 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44661
44662 if (i->is_first || i->is_last) {
44663 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44664 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44665 | set11nTries(i->rates, 1)
44666 | set11nTries(i->rates, 2)
44667 | set11nTries(i->rates, 3)
44668 | (i->dur_update ? AR_DurUpdateEna : 0)
44669 | SM(0, AR_BurstDur);
44670
44671 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44672 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44673 | set11nRate(i->rates, 1)
44674 | set11nRate(i->rates, 2)
44675 | set11nRate(i->rates, 3);
44676 } else {
44677 - ACCESS_ONCE(ads->ctl13) = 0;
44678 - ACCESS_ONCE(ads->ctl14) = 0;
44679 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44680 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44681 }
44682
44683 ads->ctl20 = 0;
44684 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44685
44686 ctl17 = SM(i->keytype, AR_EncrType);
44687 if (!i->is_first) {
44688 - ACCESS_ONCE(ads->ctl11) = 0;
44689 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44690 - ACCESS_ONCE(ads->ctl15) = 0;
44691 - ACCESS_ONCE(ads->ctl16) = 0;
44692 - ACCESS_ONCE(ads->ctl17) = ctl17;
44693 - ACCESS_ONCE(ads->ctl18) = 0;
44694 - ACCESS_ONCE(ads->ctl19) = 0;
44695 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44696 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44697 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44698 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44699 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44700 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44701 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44702 return;
44703 }
44704
44705 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44706 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44707 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44708 | SM(i->txpower, AR_XmitPower)
44709 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44710 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44711 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44712 ctl12 |= SM(val, AR_PAPRDChainMask);
44713
44714 - ACCESS_ONCE(ads->ctl12) = ctl12;
44715 - ACCESS_ONCE(ads->ctl17) = ctl17;
44716 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44717 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44718
44719 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44720 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44721 | set11nPktDurRTSCTS(i->rates, 1);
44722
44723 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44724 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44725 | set11nPktDurRTSCTS(i->rates, 3);
44726
44727 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44728 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44729 | set11nRateFlags(i->rates, 1)
44730 | set11nRateFlags(i->rates, 2)
44731 | set11nRateFlags(i->rates, 3)
44732 | SM(i->rtscts_rate, AR_RTSCTSRate);
44733
44734 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44735 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44736 }
44737
44738 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44739 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44740 index cd74b3a..6a28d24 100644
44741 --- a/drivers/net/wireless/ath/ath9k/hw.h
44742 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44743 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44744
44745 /* ANI */
44746 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44747 -};
44748 +} __no_const;
44749
44750 /**
44751 * struct ath_spec_scan - parameters for Atheros spectral scan
44752 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44753 struct ath_spec_scan *param);
44754 void (*spectral_scan_trigger)(struct ath_hw *ah);
44755 void (*spectral_scan_wait)(struct ath_hw *ah);
44756 -};
44757 +} __no_const;
44758
44759 struct ath_nf_limits {
44760 s16 max;
44761 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44762 index 92190da..f3a4c4c 100644
44763 --- a/drivers/net/wireless/b43/phy_lp.c
44764 +++ b/drivers/net/wireless/b43/phy_lp.c
44765 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44766 {
44767 struct ssb_bus *bus = dev->dev->sdev->bus;
44768
44769 - static const struct b206x_channel *chandata = NULL;
44770 + const struct b206x_channel *chandata = NULL;
44771 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44772 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44773 u16 old_comm15, scale;
44774 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44775 index 9581d07..84f6a76 100644
44776 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44777 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44778 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44779 */
44780 if (il3945_mod_params.disable_hw_scan) {
44781 D_INFO("Disabling hw_scan\n");
44782 - il3945_mac_ops.hw_scan = NULL;
44783 + pax_open_kernel();
44784 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44785 + pax_close_kernel();
44786 }
44787
44788 D_INFO("*** LOAD DRIVER ***\n");
44789 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44790 index d532948..e0d8bb1 100644
44791 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44792 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44793 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44794 {
44795 struct iwl_priv *priv = file->private_data;
44796 char buf[64];
44797 - int buf_size;
44798 + size_t buf_size;
44799 u32 offset, len;
44800
44801 memset(buf, 0, sizeof(buf));
44802 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44803 struct iwl_priv *priv = file->private_data;
44804
44805 char buf[8];
44806 - int buf_size;
44807 + size_t buf_size;
44808 u32 reset_flag;
44809
44810 memset(buf, 0, sizeof(buf));
44811 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44812 {
44813 struct iwl_priv *priv = file->private_data;
44814 char buf[8];
44815 - int buf_size;
44816 + size_t buf_size;
44817 int ht40;
44818
44819 memset(buf, 0, sizeof(buf));
44820 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44821 {
44822 struct iwl_priv *priv = file->private_data;
44823 char buf[8];
44824 - int buf_size;
44825 + size_t buf_size;
44826 int value;
44827
44828 memset(buf, 0, sizeof(buf));
44829 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44830 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44831 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44832
44833 -static const char *fmt_value = " %-30s %10u\n";
44834 -static const char *fmt_hex = " %-30s 0x%02X\n";
44835 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44836 -static const char *fmt_header =
44837 +static const char fmt_value[] = " %-30s %10u\n";
44838 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44839 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44840 +static const char fmt_header[] =
44841 "%-32s current cumulative delta max\n";
44842
44843 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44844 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44845 {
44846 struct iwl_priv *priv = file->private_data;
44847 char buf[8];
44848 - int buf_size;
44849 + size_t buf_size;
44850 int clear;
44851
44852 memset(buf, 0, sizeof(buf));
44853 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44854 {
44855 struct iwl_priv *priv = file->private_data;
44856 char buf[8];
44857 - int buf_size;
44858 + size_t buf_size;
44859 int trace;
44860
44861 memset(buf, 0, sizeof(buf));
44862 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44863 {
44864 struct iwl_priv *priv = file->private_data;
44865 char buf[8];
44866 - int buf_size;
44867 + size_t buf_size;
44868 int missed;
44869
44870 memset(buf, 0, sizeof(buf));
44871 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44872
44873 struct iwl_priv *priv = file->private_data;
44874 char buf[8];
44875 - int buf_size;
44876 + size_t buf_size;
44877 int plcp;
44878
44879 memset(buf, 0, sizeof(buf));
44880 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44881
44882 struct iwl_priv *priv = file->private_data;
44883 char buf[8];
44884 - int buf_size;
44885 + size_t buf_size;
44886 int flush;
44887
44888 memset(buf, 0, sizeof(buf));
44889 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44890
44891 struct iwl_priv *priv = file->private_data;
44892 char buf[8];
44893 - int buf_size;
44894 + size_t buf_size;
44895 int rts;
44896
44897 if (!priv->cfg->ht_params)
44898 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44899 {
44900 struct iwl_priv *priv = file->private_data;
44901 char buf[8];
44902 - int buf_size;
44903 + size_t buf_size;
44904
44905 memset(buf, 0, sizeof(buf));
44906 buf_size = min(count, sizeof(buf) - 1);
44907 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44908 struct iwl_priv *priv = file->private_data;
44909 u32 event_log_flag;
44910 char buf[8];
44911 - int buf_size;
44912 + size_t buf_size;
44913
44914 /* check that the interface is up */
44915 if (!iwl_is_ready(priv))
44916 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44917 struct iwl_priv *priv = file->private_data;
44918 char buf[8];
44919 u32 calib_disabled;
44920 - int buf_size;
44921 + size_t buf_size;
44922
44923 memset(buf, 0, sizeof(buf));
44924 buf_size = min(count, sizeof(buf) - 1);
44925 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44926 index 1531a4f..21d2641 100644
44927 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44928 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44929 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44930 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44931 {
44932 struct iwl_nvm_data *data = priv->nvm_data;
44933 - char *debug_msg;
44934 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44935
44936 if (data->sku_cap_11n_enable &&
44937 !priv->cfg->ht_params) {
44938 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44939 return -EINVAL;
44940 }
44941
44942 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44943 IWL_DEBUG_INFO(priv, debug_msg,
44944 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44945 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44946 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44947 index 390e2f0..75cfbaf 100644
44948 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44949 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44950 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44951 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44952
44953 char buf[8];
44954 - int buf_size;
44955 + size_t buf_size;
44956 u32 reset_flag;
44957
44958 memset(buf, 0, sizeof(buf));
44959 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44960 {
44961 struct iwl_trans *trans = file->private_data;
44962 char buf[8];
44963 - int buf_size;
44964 + size_t buf_size;
44965 int csr;
44966
44967 memset(buf, 0, sizeof(buf));
44968 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44969 index cb34c78..9fec0dc 100644
44970 --- a/drivers/net/wireless/mac80211_hwsim.c
44971 +++ b/drivers/net/wireless/mac80211_hwsim.c
44972 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
44973
44974 if (channels > 1) {
44975 hwsim_if_comb.num_different_channels = channels;
44976 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44977 - mac80211_hwsim_ops.cancel_hw_scan =
44978 - mac80211_hwsim_cancel_hw_scan;
44979 - mac80211_hwsim_ops.sw_scan_start = NULL;
44980 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44981 - mac80211_hwsim_ops.remain_on_channel =
44982 - mac80211_hwsim_roc;
44983 - mac80211_hwsim_ops.cancel_remain_on_channel =
44984 - mac80211_hwsim_croc;
44985 - mac80211_hwsim_ops.add_chanctx =
44986 - mac80211_hwsim_add_chanctx;
44987 - mac80211_hwsim_ops.remove_chanctx =
44988 - mac80211_hwsim_remove_chanctx;
44989 - mac80211_hwsim_ops.change_chanctx =
44990 - mac80211_hwsim_change_chanctx;
44991 - mac80211_hwsim_ops.assign_vif_chanctx =
44992 - mac80211_hwsim_assign_vif_chanctx;
44993 - mac80211_hwsim_ops.unassign_vif_chanctx =
44994 - mac80211_hwsim_unassign_vif_chanctx;
44995 + pax_open_kernel();
44996 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44997 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
44998 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
44999 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45000 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45001 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45002 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45003 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45004 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45005 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45006 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45007 + pax_close_kernel();
45008 }
45009
45010 spin_lock_init(&hwsim_radio_lock);
45011 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45012 index 8169a85..7fa3b47 100644
45013 --- a/drivers/net/wireless/rndis_wlan.c
45014 +++ b/drivers/net/wireless/rndis_wlan.c
45015 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45016
45017 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45018
45019 - if (rts_threshold < 0 || rts_threshold > 2347)
45020 + if (rts_threshold > 2347)
45021 rts_threshold = 2347;
45022
45023 tmp = cpu_to_le32(rts_threshold);
45024 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45025 index ee3fc57..ed5ddc9 100644
45026 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45027 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45028 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45029 * for hardware which doesn't support hardware
45030 * sequence counting.
45031 */
45032 - atomic_t seqno;
45033 + atomic_unchecked_t seqno;
45034 };
45035
45036 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45037 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45038 index aa95c6c..a59dd67 100644
45039 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45040 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45041 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45042 * sequence counter given by mac80211.
45043 */
45044 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45045 - seqno = atomic_add_return(0x10, &intf->seqno);
45046 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45047 else
45048 - seqno = atomic_read(&intf->seqno);
45049 + seqno = atomic_read_unchecked(&intf->seqno);
45050
45051 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45052 hdr->seq_ctrl |= cpu_to_le16(seqno);
45053 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45054 index e2b3d9c..67a5184 100644
45055 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45056 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45057 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45058
45059 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45060
45061 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45062 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45063 + pax_open_kernel();
45064 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45065 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45066 + pax_close_kernel();
45067
45068 wl1251_info("using dedicated interrupt line");
45069 } else {
45070 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45071 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45072 + pax_open_kernel();
45073 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45074 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45075 + pax_close_kernel();
45076
45077 wl1251_info("using SDIO interrupt");
45078 }
45079 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45080 index 1c627da..69f7d17 100644
45081 --- a/drivers/net/wireless/ti/wl12xx/main.c
45082 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45083 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45084 sizeof(wl->conf.mem));
45085
45086 /* read data preparation is only needed by wl127x */
45087 - wl->ops->prepare_read = wl127x_prepare_read;
45088 + pax_open_kernel();
45089 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45090 + pax_close_kernel();
45091
45092 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45093 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45094 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45095 sizeof(wl->conf.mem));
45096
45097 /* read data preparation is only needed by wl127x */
45098 - wl->ops->prepare_read = wl127x_prepare_read;
45099 + pax_open_kernel();
45100 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45101 + pax_close_kernel();
45102
45103 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45104 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45105 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45106 index 7aa0eb8..5a9ef38 100644
45107 --- a/drivers/net/wireless/ti/wl18xx/main.c
45108 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45109 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45110 }
45111
45112 if (!checksum_param) {
45113 - wl18xx_ops.set_rx_csum = NULL;
45114 - wl18xx_ops.init_vif = NULL;
45115 + pax_open_kernel();
45116 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45117 + *(void **)&wl18xx_ops.init_vif = NULL;
45118 + pax_close_kernel();
45119 }
45120
45121 /* Enable 11a Band only if we have 5G antennas */
45122 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45123 index 7ef0b4a..ff65c28 100644
45124 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45125 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45126 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45127 {
45128 struct zd_usb *usb = urb->context;
45129 struct zd_usb_interrupt *intr = &usb->intr;
45130 - int len;
45131 + unsigned int len;
45132 u16 int_num;
45133
45134 ZD_ASSERT(in_interrupt());
45135 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45136 index 59f95d8..53e0e7f 100644
45137 --- a/drivers/nfc/nfcwilink.c
45138 +++ b/drivers/nfc/nfcwilink.c
45139 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45140
45141 static int nfcwilink_probe(struct platform_device *pdev)
45142 {
45143 - static struct nfcwilink *drv;
45144 + struct nfcwilink *drv;
45145 int rc;
45146 __u32 protocols;
45147
45148 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45149 index d93b2b6..ae50401 100644
45150 --- a/drivers/oprofile/buffer_sync.c
45151 +++ b/drivers/oprofile/buffer_sync.c
45152 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45153 if (cookie == NO_COOKIE)
45154 offset = pc;
45155 if (cookie == INVALID_COOKIE) {
45156 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45157 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45158 offset = pc;
45159 }
45160 if (cookie != last_cookie) {
45161 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45162 /* add userspace sample */
45163
45164 if (!mm) {
45165 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45166 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45167 return 0;
45168 }
45169
45170 cookie = lookup_dcookie(mm, s->eip, &offset);
45171
45172 if (cookie == INVALID_COOKIE) {
45173 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45174 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45175 return 0;
45176 }
45177
45178 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45179 /* ignore backtraces if failed to add a sample */
45180 if (state == sb_bt_start) {
45181 state = sb_bt_ignore;
45182 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45183 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45184 }
45185 }
45186 release_mm(mm);
45187 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45188 index c0cc4e7..44d4e54 100644
45189 --- a/drivers/oprofile/event_buffer.c
45190 +++ b/drivers/oprofile/event_buffer.c
45191 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45192 }
45193
45194 if (buffer_pos == buffer_size) {
45195 - atomic_inc(&oprofile_stats.event_lost_overflow);
45196 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45197 return;
45198 }
45199
45200 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45201 index ed2c3ec..deda85a 100644
45202 --- a/drivers/oprofile/oprof.c
45203 +++ b/drivers/oprofile/oprof.c
45204 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45205 if (oprofile_ops.switch_events())
45206 return;
45207
45208 - atomic_inc(&oprofile_stats.multiplex_counter);
45209 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45210 start_switch_worker();
45211 }
45212
45213 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45214 index 84a208d..d61b0a1 100644
45215 --- a/drivers/oprofile/oprofile_files.c
45216 +++ b/drivers/oprofile/oprofile_files.c
45217 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45218
45219 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45220
45221 -static ssize_t timeout_read(struct file *file, char __user *buf,
45222 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45223 size_t count, loff_t *offset)
45224 {
45225 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45226 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45227 index 917d28e..d62d981 100644
45228 --- a/drivers/oprofile/oprofile_stats.c
45229 +++ b/drivers/oprofile/oprofile_stats.c
45230 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45231 cpu_buf->sample_invalid_eip = 0;
45232 }
45233
45234 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45235 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45236 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45237 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45238 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45239 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45240 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45241 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45242 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45243 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45244 }
45245
45246
45247 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45248 index 38b6fc0..b5cbfce 100644
45249 --- a/drivers/oprofile/oprofile_stats.h
45250 +++ b/drivers/oprofile/oprofile_stats.h
45251 @@ -13,11 +13,11 @@
45252 #include <linux/atomic.h>
45253
45254 struct oprofile_stat_struct {
45255 - atomic_t sample_lost_no_mm;
45256 - atomic_t sample_lost_no_mapping;
45257 - atomic_t bt_lost_no_mapping;
45258 - atomic_t event_lost_overflow;
45259 - atomic_t multiplex_counter;
45260 + atomic_unchecked_t sample_lost_no_mm;
45261 + atomic_unchecked_t sample_lost_no_mapping;
45262 + atomic_unchecked_t bt_lost_no_mapping;
45263 + atomic_unchecked_t event_lost_overflow;
45264 + atomic_unchecked_t multiplex_counter;
45265 };
45266
45267 extern struct oprofile_stat_struct oprofile_stats;
45268 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45269 index 7c12d9c..9f5e825 100644
45270 --- a/drivers/oprofile/oprofilefs.c
45271 +++ b/drivers/oprofile/oprofilefs.c
45272 @@ -177,8 +177,8 @@ int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root,
45273
45274 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45275 {
45276 - atomic_t *val = file->private_data;
45277 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45278 + atomic_unchecked_t *val = file->private_data;
45279 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45280 }
45281
45282
45283 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45284
45285
45286 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45287 - char const *name, atomic_t *val)
45288 + char const *name, atomic_unchecked_t *val)
45289 {
45290 return __oprofilefs_create_file(sb, root, name,
45291 &atomic_ro_fops, 0444, val);
45292 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45293 index 61be1d9..dec05d7 100644
45294 --- a/drivers/oprofile/timer_int.c
45295 +++ b/drivers/oprofile/timer_int.c
45296 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45297 return NOTIFY_OK;
45298 }
45299
45300 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45301 +static struct notifier_block oprofile_cpu_notifier = {
45302 .notifier_call = oprofile_cpu_notify,
45303 };
45304
45305 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45306 index 92ed045..62d39bd7 100644
45307 --- a/drivers/parport/procfs.c
45308 +++ b/drivers/parport/procfs.c
45309 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45310
45311 *ppos += len;
45312
45313 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45314 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45315 }
45316
45317 #ifdef CONFIG_PARPORT_1284
45318 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45319
45320 *ppos += len;
45321
45322 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45323 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45324 }
45325 #endif /* IEEE1284.3 support. */
45326
45327 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45328 index c35e8ad..fc33beb 100644
45329 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45330 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45331 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45332 goto init_cleanup;
45333 }
45334
45335 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45336 + pax_open_kernel();
45337 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45338 + pax_close_kernel();
45339 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45340
45341 return retval;
45342 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45343 index a6a71c4..c91097b 100644
45344 --- a/drivers/pci/hotplug/cpcihp_generic.c
45345 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45346 @@ -73,7 +73,6 @@ static u16 port;
45347 static unsigned int enum_bit;
45348 static u8 enum_mask;
45349
45350 -static struct cpci_hp_controller_ops generic_hpc_ops;
45351 static struct cpci_hp_controller generic_hpc;
45352
45353 static int __init validate_parameters(void)
45354 @@ -139,6 +138,10 @@ static int query_enum(void)
45355 return ((value & enum_mask) == enum_mask);
45356 }
45357
45358 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45359 + .query_enum = query_enum,
45360 +};
45361 +
45362 static int __init cpcihp_generic_init(void)
45363 {
45364 int status;
45365 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45366 pci_dev_put(dev);
45367
45368 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45369 - generic_hpc_ops.query_enum = query_enum;
45370 generic_hpc.ops = &generic_hpc_ops;
45371
45372 status = cpci_hp_register_controller(&generic_hpc);
45373 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45374 index 449b4bb..257e2e8 100644
45375 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45376 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45377 @@ -59,7 +59,6 @@
45378 /* local variables */
45379 static bool debug;
45380 static bool poll;
45381 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45382 static struct cpci_hp_controller zt5550_hpc;
45383
45384 /* Primary cPCI bus bridge device */
45385 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45386 return 0;
45387 }
45388
45389 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45390 + .query_enum = zt5550_hc_query_enum,
45391 +};
45392 +
45393 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45394 {
45395 int status;
45396 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45397 dbg("returned from zt5550_hc_config");
45398
45399 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45400 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45401 zt5550_hpc.ops = &zt5550_hpc_ops;
45402 if(!poll) {
45403 zt5550_hpc.irq = hc_dev->irq;
45404 zt5550_hpc.irq_flags = IRQF_SHARED;
45405 zt5550_hpc.dev_id = hc_dev;
45406
45407 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45408 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45409 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45410 + pax_open_kernel();
45411 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45412 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45413 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45414 + pax_open_kernel();
45415 } else {
45416 info("using ENUM# polling mode");
45417 }
45418 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45419 index 76ba8a1..20ca857 100644
45420 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45421 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45422 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45423
45424 void compaq_nvram_init (void __iomem *rom_start)
45425 {
45426 +
45427 +#ifndef CONFIG_PAX_KERNEXEC
45428 if (rom_start) {
45429 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45430 }
45431 +#endif
45432 +
45433 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45434
45435 /* initialize our int15 lock */
45436 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45437 index ec20f74..c1d961e 100644
45438 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45439 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45440 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45441 return -EINVAL;
45442 }
45443
45444 - slot->ops->owner = owner;
45445 - slot->ops->mod_name = mod_name;
45446 + pax_open_kernel();
45447 + *(struct module **)&slot->ops->owner = owner;
45448 + *(const char **)&slot->ops->mod_name = mod_name;
45449 + pax_close_kernel();
45450
45451 mutex_lock(&pci_hp_mutex);
45452 /*
45453 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45454 index 7d72c5e..edce02c 100644
45455 --- a/drivers/pci/hotplug/pciehp_core.c
45456 +++ b/drivers/pci/hotplug/pciehp_core.c
45457 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45458 struct slot *slot = ctrl->slot;
45459 struct hotplug_slot *hotplug = NULL;
45460 struct hotplug_slot_info *info = NULL;
45461 - struct hotplug_slot_ops *ops = NULL;
45462 + hotplug_slot_ops_no_const *ops = NULL;
45463 char name[SLOT_NAME_SIZE];
45464 int retval = -ENOMEM;
45465
45466 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45467 index c0dbe1f..94cf3d8 100644
45468 --- a/drivers/pci/pci-sysfs.c
45469 +++ b/drivers/pci/pci-sysfs.c
45470 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45471 {
45472 /* allocate attribute structure, piggyback attribute name */
45473 int name_len = write_combine ? 13 : 10;
45474 - struct bin_attribute *res_attr;
45475 + bin_attribute_no_const *res_attr;
45476 int retval;
45477
45478 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45479 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45480 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45481 {
45482 int retval;
45483 - struct bin_attribute *attr;
45484 + bin_attribute_no_const *attr;
45485
45486 /* If the device has VPD, try to expose it in sysfs. */
45487 if (dev->vpd) {
45488 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45489 {
45490 int retval;
45491 int rom_size = 0;
45492 - struct bin_attribute *attr;
45493 + bin_attribute_no_const *attr;
45494
45495 if (!sysfs_initialized)
45496 return -EACCES;
45497 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45498 index d1182c4..2a138ec 100644
45499 --- a/drivers/pci/pci.h
45500 +++ b/drivers/pci/pci.h
45501 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45502 struct pci_vpd {
45503 unsigned int len;
45504 const struct pci_vpd_ops *ops;
45505 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45506 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45507 };
45508
45509 int pci_vpd_pci22_init(struct pci_dev *dev);
45510 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45511 index 403a443..034e050 100644
45512 --- a/drivers/pci/pcie/aspm.c
45513 +++ b/drivers/pci/pcie/aspm.c
45514 @@ -27,9 +27,9 @@
45515 #define MODULE_PARAM_PREFIX "pcie_aspm."
45516
45517 /* Note: those are not register definitions */
45518 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45519 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45520 -#define ASPM_STATE_L1 (4) /* L1 state */
45521 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45522 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45523 +#define ASPM_STATE_L1 (4U) /* L1 state */
45524 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45525 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45526
45527 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45528 index 46ada5c..20da716 100644
45529 --- a/drivers/pci/probe.c
45530 +++ b/drivers/pci/probe.c
45531 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45532 struct pci_bus_region region, inverted_region;
45533 bool bar_too_big = false, bar_disabled = false;
45534
45535 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45536 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45537
45538 /* No printks while decoding is disabled! */
45539 if (!dev->mmio_always_on) {
45540 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45541 index cdc7836..528635c 100644
45542 --- a/drivers/pci/proc.c
45543 +++ b/drivers/pci/proc.c
45544 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45545 static int __init pci_proc_init(void)
45546 {
45547 struct pci_dev *dev = NULL;
45548 +
45549 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45550 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45551 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45552 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45553 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45554 +#endif
45555 +#else
45556 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45557 +#endif
45558 proc_create("devices", 0, proc_bus_pci_dir,
45559 &proc_bus_pci_dev_operations);
45560 proc_initialized = 1;
45561 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45562 index 3e5b4497..dcdfb70 100644
45563 --- a/drivers/platform/x86/chromeos_laptop.c
45564 +++ b/drivers/platform/x86/chromeos_laptop.c
45565 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45566 return 0;
45567 }
45568
45569 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45570 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45571 {
45572 .ident = "Samsung Series 5 550 - Touchpad",
45573 .matches = {
45574 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45575 index 62f8030..c7f2a45 100644
45576 --- a/drivers/platform/x86/msi-laptop.c
45577 +++ b/drivers/platform/x86/msi-laptop.c
45578 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45579
45580 if (!quirks->ec_read_only) {
45581 /* allow userland write sysfs file */
45582 - dev_attr_bluetooth.store = store_bluetooth;
45583 - dev_attr_wlan.store = store_wlan;
45584 - dev_attr_threeg.store = store_threeg;
45585 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45586 - dev_attr_wlan.attr.mode |= S_IWUSR;
45587 - dev_attr_threeg.attr.mode |= S_IWUSR;
45588 + pax_open_kernel();
45589 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45590 + *(void **)&dev_attr_wlan.store = store_wlan;
45591 + *(void **)&dev_attr_threeg.store = store_threeg;
45592 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45593 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45594 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45595 + pax_close_kernel();
45596 }
45597
45598 /* disable hardware control by fn key */
45599 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45600 index 70222f2..8c8ce66 100644
45601 --- a/drivers/platform/x86/msi-wmi.c
45602 +++ b/drivers/platform/x86/msi-wmi.c
45603 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45604 static void msi_wmi_notify(u32 value, void *context)
45605 {
45606 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45607 - static struct key_entry *key;
45608 + struct key_entry *key;
45609 union acpi_object *obj;
45610 acpi_status status;
45611
45612 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45613 index 3a1b6bf..b453930 100644
45614 --- a/drivers/platform/x86/sony-laptop.c
45615 +++ b/drivers/platform/x86/sony-laptop.c
45616 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45617 }
45618
45619 /* High speed charging function */
45620 -static struct device_attribute *hsc_handle;
45621 +static device_attribute_no_const *hsc_handle;
45622
45623 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45624 struct device_attribute *attr,
45625 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45626 index 54d31c0..3f896d3 100644
45627 --- a/drivers/platform/x86/thinkpad_acpi.c
45628 +++ b/drivers/platform/x86/thinkpad_acpi.c
45629 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45630 return 0;
45631 }
45632
45633 -void static hotkey_mask_warn_incomplete_mask(void)
45634 +static void hotkey_mask_warn_incomplete_mask(void)
45635 {
45636 /* log only what the user can fix... */
45637 const u32 wantedmask = hotkey_driver_mask &
45638 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45639 }
45640 }
45641
45642 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45643 - struct tp_nvram_state *newn,
45644 - const u32 event_mask)
45645 -{
45646 -
45647 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45648 do { \
45649 if ((event_mask & (1 << __scancode)) && \
45650 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45651 tpacpi_hotkey_send_key(__scancode); \
45652 } while (0)
45653
45654 - void issue_volchange(const unsigned int oldvol,
45655 - const unsigned int newvol)
45656 - {
45657 - unsigned int i = oldvol;
45658 +static void issue_volchange(const unsigned int oldvol,
45659 + const unsigned int newvol,
45660 + const u32 event_mask)
45661 +{
45662 + unsigned int i = oldvol;
45663
45664 - while (i > newvol) {
45665 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45666 - i--;
45667 - }
45668 - while (i < newvol) {
45669 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45670 - i++;
45671 - }
45672 + while (i > newvol) {
45673 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45674 + i--;
45675 }
45676 + while (i < newvol) {
45677 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45678 + i++;
45679 + }
45680 +}
45681
45682 - void issue_brightnesschange(const unsigned int oldbrt,
45683 - const unsigned int newbrt)
45684 - {
45685 - unsigned int i = oldbrt;
45686 +static void issue_brightnesschange(const unsigned int oldbrt,
45687 + const unsigned int newbrt,
45688 + const u32 event_mask)
45689 +{
45690 + unsigned int i = oldbrt;
45691
45692 - while (i > newbrt) {
45693 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45694 - i--;
45695 - }
45696 - while (i < newbrt) {
45697 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45698 - i++;
45699 - }
45700 + while (i > newbrt) {
45701 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45702 + i--;
45703 + }
45704 + while (i < newbrt) {
45705 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45706 + i++;
45707 }
45708 +}
45709
45710 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45711 + struct tp_nvram_state *newn,
45712 + const u32 event_mask)
45713 +{
45714 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45715 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45716 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45717 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45718 oldn->volume_level != newn->volume_level) {
45719 /* recently muted, or repeated mute keypress, or
45720 * multiple presses ending in mute */
45721 - issue_volchange(oldn->volume_level, newn->volume_level);
45722 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45723 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45724 }
45725 } else {
45726 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45727 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45728 }
45729 if (oldn->volume_level != newn->volume_level) {
45730 - issue_volchange(oldn->volume_level, newn->volume_level);
45731 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45732 } else if (oldn->volume_toggle != newn->volume_toggle) {
45733 /* repeated vol up/down keypress at end of scale ? */
45734 if (newn->volume_level == 0)
45735 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45736 /* handle brightness */
45737 if (oldn->brightness_level != newn->brightness_level) {
45738 issue_brightnesschange(oldn->brightness_level,
45739 - newn->brightness_level);
45740 + newn->brightness_level,
45741 + event_mask);
45742 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45743 /* repeated key presses that didn't change state */
45744 if (newn->brightness_level == 0)
45745 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45746 && !tp_features.bright_unkfw)
45747 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45748 }
45749 +}
45750
45751 #undef TPACPI_COMPARE_KEY
45752 #undef TPACPI_MAY_SEND_KEY
45753 -}
45754
45755 /*
45756 * Polling driver
45757 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45758 index 769d265..a3a05ca 100644
45759 --- a/drivers/pnp/pnpbios/bioscalls.c
45760 +++ b/drivers/pnp/pnpbios/bioscalls.c
45761 @@ -58,7 +58,7 @@ do { \
45762 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45763 } while(0)
45764
45765 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45766 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45767 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45768
45769 /*
45770 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45771
45772 cpu = get_cpu();
45773 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45774 +
45775 + pax_open_kernel();
45776 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45777 + pax_close_kernel();
45778
45779 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45780 spin_lock_irqsave(&pnp_bios_lock, flags);
45781 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45782 :"memory");
45783 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45784
45785 + pax_open_kernel();
45786 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45787 + pax_close_kernel();
45788 +
45789 put_cpu();
45790
45791 /* If we get here and this is set then the PnP BIOS faulted on us. */
45792 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45793 return status;
45794 }
45795
45796 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45797 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45798 {
45799 int i;
45800
45801 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45802 pnp_bios_callpoint.offset = header->fields.pm16offset;
45803 pnp_bios_callpoint.segment = PNP_CS16;
45804
45805 + pax_open_kernel();
45806 +
45807 for_each_possible_cpu(i) {
45808 struct desc_struct *gdt = get_cpu_gdt_table(i);
45809 if (!gdt)
45810 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45811 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45812 (unsigned long)__va(header->fields.pm16dseg));
45813 }
45814 +
45815 + pax_close_kernel();
45816 }
45817 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45818 index d95e101..67f0c3f 100644
45819 --- a/drivers/pnp/resource.c
45820 +++ b/drivers/pnp/resource.c
45821 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45822 return 1;
45823
45824 /* check if the resource is valid */
45825 - if (*irq < 0 || *irq > 15)
45826 + if (*irq > 15)
45827 return 0;
45828
45829 /* check if the resource is reserved */
45830 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45831 return 1;
45832
45833 /* check if the resource is valid */
45834 - if (*dma < 0 || *dma == 4 || *dma > 7)
45835 + if (*dma == 4 || *dma > 7)
45836 return 0;
45837
45838 /* check if the resource is reserved */
45839 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45840 index 0c52e2a..3421ab7 100644
45841 --- a/drivers/power/pda_power.c
45842 +++ b/drivers/power/pda_power.c
45843 @@ -37,7 +37,11 @@ static int polling;
45844
45845 #if IS_ENABLED(CONFIG_USB_PHY)
45846 static struct usb_phy *transceiver;
45847 -static struct notifier_block otg_nb;
45848 +static int otg_handle_notification(struct notifier_block *nb,
45849 + unsigned long event, void *unused);
45850 +static struct notifier_block otg_nb = {
45851 + .notifier_call = otg_handle_notification
45852 +};
45853 #endif
45854
45855 static struct regulator *ac_draw;
45856 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45857
45858 #if IS_ENABLED(CONFIG_USB_PHY)
45859 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45860 - otg_nb.notifier_call = otg_handle_notification;
45861 ret = usb_register_notifier(transceiver, &otg_nb);
45862 if (ret) {
45863 dev_err(dev, "failure to register otg notifier\n");
45864 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45865 index cc439fd..8fa30df 100644
45866 --- a/drivers/power/power_supply.h
45867 +++ b/drivers/power/power_supply.h
45868 @@ -16,12 +16,12 @@ struct power_supply;
45869
45870 #ifdef CONFIG_SYSFS
45871
45872 -extern void power_supply_init_attrs(struct device_type *dev_type);
45873 +extern void power_supply_init_attrs(void);
45874 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45875
45876 #else
45877
45878 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45879 +static inline void power_supply_init_attrs(void) {}
45880 #define power_supply_uevent NULL
45881
45882 #endif /* CONFIG_SYSFS */
45883 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45884 index 3b2d5df..3207114 100644
45885 --- a/drivers/power/power_supply_core.c
45886 +++ b/drivers/power/power_supply_core.c
45887 @@ -24,7 +24,10 @@
45888 struct class *power_supply_class;
45889 EXPORT_SYMBOL_GPL(power_supply_class);
45890
45891 -static struct device_type power_supply_dev_type;
45892 +extern const struct attribute_group *power_supply_attr_groups[];
45893 +static struct device_type power_supply_dev_type = {
45894 + .groups = power_supply_attr_groups,
45895 +};
45896
45897 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45898 struct power_supply *supply)
45899 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45900 return PTR_ERR(power_supply_class);
45901
45902 power_supply_class->dev_uevent = power_supply_uevent;
45903 - power_supply_init_attrs(&power_supply_dev_type);
45904 + power_supply_init_attrs();
45905
45906 return 0;
45907 }
45908 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45909 index 29178f7..c65f324 100644
45910 --- a/drivers/power/power_supply_sysfs.c
45911 +++ b/drivers/power/power_supply_sysfs.c
45912 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45913 .is_visible = power_supply_attr_is_visible,
45914 };
45915
45916 -static const struct attribute_group *power_supply_attr_groups[] = {
45917 +const struct attribute_group *power_supply_attr_groups[] = {
45918 &power_supply_attr_group,
45919 NULL,
45920 };
45921
45922 -void power_supply_init_attrs(struct device_type *dev_type)
45923 +void power_supply_init_attrs(void)
45924 {
45925 int i;
45926
45927 - dev_type->groups = power_supply_attr_groups;
45928 -
45929 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45930 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45931 }
45932 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45933 index 288c75a..065bc84 100644
45934 --- a/drivers/regulator/core.c
45935 +++ b/drivers/regulator/core.c
45936 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45937 {
45938 const struct regulation_constraints *constraints = NULL;
45939 const struct regulator_init_data *init_data;
45940 - static atomic_t regulator_no = ATOMIC_INIT(0);
45941 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45942 struct regulator_dev *rdev;
45943 struct device *dev;
45944 int ret, i;
45945 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45946 rdev->dev.of_node = config->of_node;
45947 rdev->dev.parent = dev;
45948 dev_set_name(&rdev->dev, "regulator.%d",
45949 - atomic_inc_return(&regulator_no) - 1);
45950 + atomic_inc_return_unchecked(&regulator_no) - 1);
45951 ret = device_register(&rdev->dev);
45952 if (ret != 0) {
45953 put_device(&rdev->dev);
45954 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45955 index d428ef9..fdc0357 100644
45956 --- a/drivers/regulator/max8660.c
45957 +++ b/drivers/regulator/max8660.c
45958 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45959 max8660->shadow_regs[MAX8660_OVER1] = 5;
45960 } else {
45961 /* Otherwise devices can be toggled via software */
45962 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45963 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45964 + pax_open_kernel();
45965 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45966 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45967 + pax_close_kernel();
45968 }
45969
45970 /*
45971 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45972 index 0c5195a..637a453d 100644
45973 --- a/drivers/regulator/max8973-regulator.c
45974 +++ b/drivers/regulator/max8973-regulator.c
45975 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45976 if (!pdata || !pdata->enable_ext_control) {
45977 max->desc.enable_reg = MAX8973_VOUT;
45978 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45979 - max->ops.enable = regulator_enable_regmap;
45980 - max->ops.disable = regulator_disable_regmap;
45981 - max->ops.is_enabled = regulator_is_enabled_regmap;
45982 + pax_open_kernel();
45983 + *(void **)&max->ops.enable = regulator_enable_regmap;
45984 + *(void **)&max->ops.disable = regulator_disable_regmap;
45985 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45986 + pax_close_kernel();
45987 }
45988
45989 if (pdata) {
45990 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45991 index 1037e07..e64dea1 100644
45992 --- a/drivers/regulator/mc13892-regulator.c
45993 +++ b/drivers/regulator/mc13892-regulator.c
45994 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45995 }
45996 mc13xxx_unlock(mc13892);
45997
45998 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45999 + pax_open_kernel();
46000 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46001 = mc13892_vcam_set_mode;
46002 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46003 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46004 = mc13892_vcam_get_mode;
46005 + pax_close_kernel();
46006
46007 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46008 ARRAY_SIZE(mc13892_regulators));
46009 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46010 index be06d71..264aee9 100644
46011 --- a/drivers/rtc/rtc-cmos.c
46012 +++ b/drivers/rtc/rtc-cmos.c
46013 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46014 hpet_rtc_timer_init();
46015
46016 /* export at least the first block of NVRAM */
46017 - nvram.size = address_space - NVRAM_OFFSET;
46018 + pax_open_kernel();
46019 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46020 + pax_close_kernel();
46021 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46022 if (retval < 0) {
46023 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46024 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46025 index d049393..bb20be0 100644
46026 --- a/drivers/rtc/rtc-dev.c
46027 +++ b/drivers/rtc/rtc-dev.c
46028 @@ -16,6 +16,7 @@
46029 #include <linux/module.h>
46030 #include <linux/rtc.h>
46031 #include <linux/sched.h>
46032 +#include <linux/grsecurity.h>
46033 #include "rtc-core.h"
46034
46035 static dev_t rtc_devt;
46036 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46037 if (copy_from_user(&tm, uarg, sizeof(tm)))
46038 return -EFAULT;
46039
46040 + gr_log_timechange();
46041 +
46042 return rtc_set_time(rtc, &tm);
46043
46044 case RTC_PIE_ON:
46045 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46046 index ca18fd1..055e42d 100644
46047 --- a/drivers/rtc/rtc-ds1307.c
46048 +++ b/drivers/rtc/rtc-ds1307.c
46049 @@ -107,7 +107,7 @@ struct ds1307 {
46050 u8 offset; /* register's offset */
46051 u8 regs[11];
46052 u16 nvram_offset;
46053 - struct bin_attribute *nvram;
46054 + bin_attribute_no_const *nvram;
46055 enum ds_type type;
46056 unsigned long flags;
46057 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46058 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46059 index fcb0329..d77b7f2 100644
46060 --- a/drivers/rtc/rtc-m48t59.c
46061 +++ b/drivers/rtc/rtc-m48t59.c
46062 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46063 if (IS_ERR(m48t59->rtc))
46064 return PTR_ERR(m48t59->rtc);
46065
46066 - m48t59_nvram_attr.size = pdata->offset;
46067 + pax_open_kernel();
46068 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46069 + pax_close_kernel();
46070
46071 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46072 if (ret)
46073 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46074 index 14b5f8d..cc9bd26 100644
46075 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46076 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46077 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46078 for (bit = 0; bit < 8; bit++) {
46079
46080 if ((pci_status[i] & (0x1 << bit)) != 0) {
46081 - static const char *s;
46082 + const char *s;
46083
46084 s = pci_status_strings[bit];
46085 if (i == 7/*TARG*/ && bit == 3)
46086 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46087
46088 for (bit = 0; bit < 8; bit++) {
46089
46090 - if ((split_status[i] & (0x1 << bit)) != 0) {
46091 - static const char *s;
46092 -
46093 - s = split_status_strings[bit];
46094 - printk(s, ahd_name(ahd),
46095 + if ((split_status[i] & (0x1 << bit)) != 0)
46096 + printk(split_status_strings[bit], ahd_name(ahd),
46097 split_status_source[i]);
46098 - }
46099
46100 if (i > 1)
46101 continue;
46102
46103 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46104 - static const char *s;
46105 -
46106 - s = split_status_strings[bit];
46107 - printk(s, ahd_name(ahd), "SG");
46108 - }
46109 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46110 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46111 }
46112 }
46113 /*
46114 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46115 index e693af6..2e525b6 100644
46116 --- a/drivers/scsi/bfa/bfa_fcpim.h
46117 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46118 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46119
46120 struct bfa_itn_s {
46121 bfa_isr_func_t isr;
46122 -};
46123 +} __no_const;
46124
46125 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46126 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46127 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46128 index 90814fe..4384138 100644
46129 --- a/drivers/scsi/bfa/bfa_ioc.h
46130 +++ b/drivers/scsi/bfa/bfa_ioc.h
46131 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46132 bfa_ioc_disable_cbfn_t disable_cbfn;
46133 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46134 bfa_ioc_reset_cbfn_t reset_cbfn;
46135 -};
46136 +} __no_const;
46137
46138 /*
46139 * IOC event notification mechanism.
46140 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46141 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46142 enum bfi_ioc_state fwstate);
46143 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46144 -};
46145 +} __no_const;
46146
46147 /*
46148 * Queue element to wait for room in request queue. FIFO order is
46149 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46150 index c9382d6..6619864 100644
46151 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46152 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46153 @@ -33,8 +33,8 @@
46154 */
46155 #include "libfcoe.h"
46156
46157 -static atomic_t ctlr_num;
46158 -static atomic_t fcf_num;
46159 +static atomic_unchecked_t ctlr_num;
46160 +static atomic_unchecked_t fcf_num;
46161
46162 /*
46163 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46164 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46165 if (!ctlr)
46166 goto out;
46167
46168 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46169 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46170 ctlr->f = f;
46171 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46172 INIT_LIST_HEAD(&ctlr->fcfs);
46173 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46174 fcf->dev.parent = &ctlr->dev;
46175 fcf->dev.bus = &fcoe_bus_type;
46176 fcf->dev.type = &fcoe_fcf_device_type;
46177 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46178 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46179 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46180
46181 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46182 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46183 {
46184 int error;
46185
46186 - atomic_set(&ctlr_num, 0);
46187 - atomic_set(&fcf_num, 0);
46188 + atomic_set_unchecked(&ctlr_num, 0);
46189 + atomic_set_unchecked(&fcf_num, 0);
46190
46191 error = bus_register(&fcoe_bus_type);
46192 if (error)
46193 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46194 index df0c3c7..b00e1d0 100644
46195 --- a/drivers/scsi/hosts.c
46196 +++ b/drivers/scsi/hosts.c
46197 @@ -42,7 +42,7 @@
46198 #include "scsi_logging.h"
46199
46200
46201 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46202 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46203
46204
46205 static void scsi_host_cls_release(struct device *dev)
46206 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46207 * subtract one because we increment first then return, but we need to
46208 * know what the next host number was before increment
46209 */
46210 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46211 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46212 shost->dma_channel = 0xff;
46213
46214 /* These three are default values which can be overridden */
46215 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46216 index 7f4f790..b75b92a 100644
46217 --- a/drivers/scsi/hpsa.c
46218 +++ b/drivers/scsi/hpsa.c
46219 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46220 unsigned long flags;
46221
46222 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46223 - return h->access.command_completed(h, q);
46224 + return h->access->command_completed(h, q);
46225
46226 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46227 a = rq->head[rq->current_entry];
46228 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46229 while (!list_empty(&h->reqQ)) {
46230 c = list_entry(h->reqQ.next, struct CommandList, list);
46231 /* can't do anything if fifo is full */
46232 - if ((h->access.fifo_full(h))) {
46233 + if ((h->access->fifo_full(h))) {
46234 dev_warn(&h->pdev->dev, "fifo full\n");
46235 break;
46236 }
46237 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46238
46239 /* Tell the controller execute command */
46240 spin_unlock_irqrestore(&h->lock, flags);
46241 - h->access.submit_command(h, c);
46242 + h->access->submit_command(h, c);
46243 spin_lock_irqsave(&h->lock, flags);
46244 }
46245 spin_unlock_irqrestore(&h->lock, flags);
46246 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46247
46248 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46249 {
46250 - return h->access.command_completed(h, q);
46251 + return h->access->command_completed(h, q);
46252 }
46253
46254 static inline bool interrupt_pending(struct ctlr_info *h)
46255 {
46256 - return h->access.intr_pending(h);
46257 + return h->access->intr_pending(h);
46258 }
46259
46260 static inline long interrupt_not_for_us(struct ctlr_info *h)
46261 {
46262 - return (h->access.intr_pending(h) == 0) ||
46263 + return (h->access->intr_pending(h) == 0) ||
46264 (h->interrupts_enabled == 0);
46265 }
46266
46267 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46268 if (prod_index < 0)
46269 return -ENODEV;
46270 h->product_name = products[prod_index].product_name;
46271 - h->access = *(products[prod_index].access);
46272 + h->access = products[prod_index].access;
46273
46274 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46275 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46276 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46277
46278 assert_spin_locked(&lockup_detector_lock);
46279 remove_ctlr_from_lockup_detector_list(h);
46280 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46281 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46282 spin_lock_irqsave(&h->lock, flags);
46283 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46284 spin_unlock_irqrestore(&h->lock, flags);
46285 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46286 }
46287
46288 /* make sure the board interrupts are off */
46289 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46290 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46291
46292 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46293 goto clean2;
46294 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46295 * fake ones to scoop up any residual completions.
46296 */
46297 spin_lock_irqsave(&h->lock, flags);
46298 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46299 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46300 spin_unlock_irqrestore(&h->lock, flags);
46301 free_irqs(h);
46302 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46303 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46304 dev_info(&h->pdev->dev, "Board READY.\n");
46305 dev_info(&h->pdev->dev,
46306 "Waiting for stale completions to drain.\n");
46307 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46308 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46309 msleep(10000);
46310 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46311 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46312
46313 rc = controller_reset_failed(h->cfgtable);
46314 if (rc)
46315 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46316 }
46317
46318 /* Turn the interrupts on so we can service requests */
46319 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46320 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46321
46322 hpsa_hba_inquiry(h);
46323 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46324 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46325 * To write all data in the battery backed cache to disks
46326 */
46327 hpsa_flush_cache(h);
46328 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46329 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46330 hpsa_free_irqs_and_disable_msix(h);
46331 }
46332
46333 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46334 return;
46335 }
46336 /* Change the access methods to the performant access methods */
46337 - h->access = SA5_performant_access;
46338 + h->access = &SA5_performant_access;
46339 h->transMethod = CFGTBL_Trans_Performant;
46340 }
46341
46342 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46343 index 9816479..c5d4e97 100644
46344 --- a/drivers/scsi/hpsa.h
46345 +++ b/drivers/scsi/hpsa.h
46346 @@ -79,7 +79,7 @@ struct ctlr_info {
46347 unsigned int msix_vector;
46348 unsigned int msi_vector;
46349 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46350 - struct access_method access;
46351 + struct access_method *access;
46352
46353 /* queue and queue Info */
46354 struct list_head reqQ;
46355 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46356 index 5879929..32b241d 100644
46357 --- a/drivers/scsi/libfc/fc_exch.c
46358 +++ b/drivers/scsi/libfc/fc_exch.c
46359 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46360 u16 pool_max_index;
46361
46362 struct {
46363 - atomic_t no_free_exch;
46364 - atomic_t no_free_exch_xid;
46365 - atomic_t xid_not_found;
46366 - atomic_t xid_busy;
46367 - atomic_t seq_not_found;
46368 - atomic_t non_bls_resp;
46369 + atomic_unchecked_t no_free_exch;
46370 + atomic_unchecked_t no_free_exch_xid;
46371 + atomic_unchecked_t xid_not_found;
46372 + atomic_unchecked_t xid_busy;
46373 + atomic_unchecked_t seq_not_found;
46374 + atomic_unchecked_t non_bls_resp;
46375 } stats;
46376 };
46377
46378 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46379 /* allocate memory for exchange */
46380 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46381 if (!ep) {
46382 - atomic_inc(&mp->stats.no_free_exch);
46383 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46384 goto out;
46385 }
46386 memset(ep, 0, sizeof(*ep));
46387 @@ -797,7 +797,7 @@ out:
46388 return ep;
46389 err:
46390 spin_unlock_bh(&pool->lock);
46391 - atomic_inc(&mp->stats.no_free_exch_xid);
46392 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46393 mempool_free(ep, mp->ep_pool);
46394 return NULL;
46395 }
46396 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46397 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46398 ep = fc_exch_find(mp, xid);
46399 if (!ep) {
46400 - atomic_inc(&mp->stats.xid_not_found);
46401 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46402 reject = FC_RJT_OX_ID;
46403 goto out;
46404 }
46405 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46406 ep = fc_exch_find(mp, xid);
46407 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46408 if (ep) {
46409 - atomic_inc(&mp->stats.xid_busy);
46410 + atomic_inc_unchecked(&mp->stats.xid_busy);
46411 reject = FC_RJT_RX_ID;
46412 goto rel;
46413 }
46414 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46415 }
46416 xid = ep->xid; /* get our XID */
46417 } else if (!ep) {
46418 - atomic_inc(&mp->stats.xid_not_found);
46419 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46420 reject = FC_RJT_RX_ID; /* XID not found */
46421 goto out;
46422 }
46423 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46424 } else {
46425 sp = &ep->seq;
46426 if (sp->id != fh->fh_seq_id) {
46427 - atomic_inc(&mp->stats.seq_not_found);
46428 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46429 if (f_ctl & FC_FC_END_SEQ) {
46430 /*
46431 * Update sequence_id based on incoming last
46432 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46433
46434 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46435 if (!ep) {
46436 - atomic_inc(&mp->stats.xid_not_found);
46437 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46438 goto out;
46439 }
46440 if (ep->esb_stat & ESB_ST_COMPLETE) {
46441 - atomic_inc(&mp->stats.xid_not_found);
46442 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46443 goto rel;
46444 }
46445 if (ep->rxid == FC_XID_UNKNOWN)
46446 ep->rxid = ntohs(fh->fh_rx_id);
46447 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46448 - atomic_inc(&mp->stats.xid_not_found);
46449 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46450 goto rel;
46451 }
46452 if (ep->did != ntoh24(fh->fh_s_id) &&
46453 ep->did != FC_FID_FLOGI) {
46454 - atomic_inc(&mp->stats.xid_not_found);
46455 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46456 goto rel;
46457 }
46458 sof = fr_sof(fp);
46459 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46460 sp->ssb_stat |= SSB_ST_RESP;
46461 sp->id = fh->fh_seq_id;
46462 } else if (sp->id != fh->fh_seq_id) {
46463 - atomic_inc(&mp->stats.seq_not_found);
46464 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46465 goto rel;
46466 }
46467
46468 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46469 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46470
46471 if (!sp)
46472 - atomic_inc(&mp->stats.xid_not_found);
46473 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46474 else
46475 - atomic_inc(&mp->stats.non_bls_resp);
46476 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46477
46478 fc_frame_free(fp);
46479 }
46480 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46481
46482 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46483 mp = ema->mp;
46484 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46485 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46486 st->fc_no_free_exch_xid +=
46487 - atomic_read(&mp->stats.no_free_exch_xid);
46488 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46489 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46490 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46491 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46492 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46493 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46494 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46495 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46496 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46497 }
46498 }
46499 EXPORT_SYMBOL(fc_exch_update_stats);
46500 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46501 index 161c98e..6d563b3 100644
46502 --- a/drivers/scsi/libsas/sas_ata.c
46503 +++ b/drivers/scsi/libsas/sas_ata.c
46504 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46505 .postreset = ata_std_postreset,
46506 .error_handler = ata_std_error_handler,
46507 .post_internal_cmd = sas_ata_post_internal,
46508 - .qc_defer = ata_std_qc_defer,
46509 + .qc_defer = ata_std_qc_defer,
46510 .qc_prep = ata_noop_qc_prep,
46511 .qc_issue = sas_ata_qc_issue,
46512 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46513 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46514 index 93f222d..73e977b 100644
46515 --- a/drivers/scsi/lpfc/lpfc.h
46516 +++ b/drivers/scsi/lpfc/lpfc.h
46517 @@ -431,7 +431,7 @@ struct lpfc_vport {
46518 struct dentry *debug_nodelist;
46519 struct dentry *vport_debugfs_root;
46520 struct lpfc_debugfs_trc *disc_trc;
46521 - atomic_t disc_trc_cnt;
46522 + atomic_unchecked_t disc_trc_cnt;
46523 #endif
46524 uint8_t stat_data_enabled;
46525 uint8_t stat_data_blocked;
46526 @@ -865,8 +865,8 @@ struct lpfc_hba {
46527 struct timer_list fabric_block_timer;
46528 unsigned long bit_flags;
46529 #define FABRIC_COMANDS_BLOCKED 0
46530 - atomic_t num_rsrc_err;
46531 - atomic_t num_cmd_success;
46532 + atomic_unchecked_t num_rsrc_err;
46533 + atomic_unchecked_t num_cmd_success;
46534 unsigned long last_rsrc_error_time;
46535 unsigned long last_ramp_down_time;
46536 unsigned long last_ramp_up_time;
46537 @@ -902,7 +902,7 @@ struct lpfc_hba {
46538
46539 struct dentry *debug_slow_ring_trc;
46540 struct lpfc_debugfs_trc *slow_ring_trc;
46541 - atomic_t slow_ring_trc_cnt;
46542 + atomic_unchecked_t slow_ring_trc_cnt;
46543 /* iDiag debugfs sub-directory */
46544 struct dentry *idiag_root;
46545 struct dentry *idiag_pci_cfg;
46546 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46547 index 60084e6..0e2e700 100644
46548 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46549 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46550 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46551
46552 #include <linux/debugfs.h>
46553
46554 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46555 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46556 static unsigned long lpfc_debugfs_start_time = 0L;
46557
46558 /* iDiag */
46559 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46560 lpfc_debugfs_enable = 0;
46561
46562 len = 0;
46563 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46564 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46565 (lpfc_debugfs_max_disc_trc - 1);
46566 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46567 dtp = vport->disc_trc + i;
46568 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46569 lpfc_debugfs_enable = 0;
46570
46571 len = 0;
46572 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46573 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46574 (lpfc_debugfs_max_slow_ring_trc - 1);
46575 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46576 dtp = phba->slow_ring_trc + i;
46577 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46578 !vport || !vport->disc_trc)
46579 return;
46580
46581 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46582 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46583 (lpfc_debugfs_max_disc_trc - 1);
46584 dtp = vport->disc_trc + index;
46585 dtp->fmt = fmt;
46586 dtp->data1 = data1;
46587 dtp->data2 = data2;
46588 dtp->data3 = data3;
46589 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46590 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46591 dtp->jif = jiffies;
46592 #endif
46593 return;
46594 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46595 !phba || !phba->slow_ring_trc)
46596 return;
46597
46598 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46599 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46600 (lpfc_debugfs_max_slow_ring_trc - 1);
46601 dtp = phba->slow_ring_trc + index;
46602 dtp->fmt = fmt;
46603 dtp->data1 = data1;
46604 dtp->data2 = data2;
46605 dtp->data3 = data3;
46606 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46607 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46608 dtp->jif = jiffies;
46609 #endif
46610 return;
46611 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46612 "slow_ring buffer\n");
46613 goto debug_failed;
46614 }
46615 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46616 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46617 memset(phba->slow_ring_trc, 0,
46618 (sizeof(struct lpfc_debugfs_trc) *
46619 lpfc_debugfs_max_slow_ring_trc));
46620 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46621 "buffer\n");
46622 goto debug_failed;
46623 }
46624 - atomic_set(&vport->disc_trc_cnt, 0);
46625 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46626
46627 snprintf(name, sizeof(name), "discovery_trace");
46628 vport->debug_disc_trc =
46629 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46630 index e0b20fa..30c2c0d 100644
46631 --- a/drivers/scsi/lpfc/lpfc_init.c
46632 +++ b/drivers/scsi/lpfc/lpfc_init.c
46633 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46634 "misc_register returned with status %d", error);
46635
46636 if (lpfc_enable_npiv) {
46637 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46638 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46639 + pax_open_kernel();
46640 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46641 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46642 + pax_close_kernel();
46643 }
46644 lpfc_transport_template =
46645 fc_attach_transport(&lpfc_transport_functions);
46646 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46647 index 243de1d..f40e3e5 100644
46648 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46649 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46650 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46651 uint32_t evt_posted;
46652
46653 spin_lock_irqsave(&phba->hbalock, flags);
46654 - atomic_inc(&phba->num_rsrc_err);
46655 + atomic_inc_unchecked(&phba->num_rsrc_err);
46656 phba->last_rsrc_error_time = jiffies;
46657
46658 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46659 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46660 unsigned long flags;
46661 struct lpfc_hba *phba = vport->phba;
46662 uint32_t evt_posted;
46663 - atomic_inc(&phba->num_cmd_success);
46664 + atomic_inc_unchecked(&phba->num_cmd_success);
46665
46666 if (vport->cfg_lun_queue_depth <= queue_depth)
46667 return;
46668 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46669 unsigned long num_rsrc_err, num_cmd_success;
46670 int i;
46671
46672 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46673 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46674 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46675 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46676
46677 /*
46678 * The error and success command counters are global per
46679 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46680 }
46681 }
46682 lpfc_destroy_vport_work_array(phba, vports);
46683 - atomic_set(&phba->num_rsrc_err, 0);
46684 - atomic_set(&phba->num_cmd_success, 0);
46685 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46686 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46687 }
46688
46689 /**
46690 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46691 }
46692 }
46693 lpfc_destroy_vport_work_array(phba, vports);
46694 - atomic_set(&phba->num_rsrc_err, 0);
46695 - atomic_set(&phba->num_cmd_success, 0);
46696 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46697 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46698 }
46699
46700 /**
46701 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46702 index 5100476..3d89a9e 100644
46703 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46704 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46705 @@ -1542,7 +1542,7 @@ _scsih_get_resync(struct device *dev)
46706 {
46707 struct scsi_device *sdev = to_scsi_device(dev);
46708 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46709 - static struct _raid_device *raid_device;
46710 + struct _raid_device *raid_device;
46711 unsigned long flags;
46712 Mpi2RaidVolPage0_t vol_pg0;
46713 Mpi2ConfigReply_t mpi_reply;
46714 @@ -1594,7 +1594,7 @@ _scsih_get_state(struct device *dev)
46715 {
46716 struct scsi_device *sdev = to_scsi_device(dev);
46717 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46718 - static struct _raid_device *raid_device;
46719 + struct _raid_device *raid_device;
46720 unsigned long flags;
46721 Mpi2RaidVolPage0_t vol_pg0;
46722 Mpi2ConfigReply_t mpi_reply;
46723 @@ -6622,7 +6622,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46724 struct fw_event_work *fw_event)
46725 {
46726 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46727 - static struct _raid_device *raid_device;
46728 + struct _raid_device *raid_device;
46729 unsigned long flags;
46730 u16 handle;
46731
46732 @@ -7093,7 +7093,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46733 u64 sas_address;
46734 struct _sas_device *sas_device;
46735 struct _sas_node *expander_device;
46736 - static struct _raid_device *raid_device;
46737 + struct _raid_device *raid_device;
46738 u8 retry_count;
46739 unsigned long flags;
46740
46741 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46742 index 1eb7b028..b2a6080 100644
46743 --- a/drivers/scsi/pmcraid.c
46744 +++ b/drivers/scsi/pmcraid.c
46745 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46746 res->scsi_dev = scsi_dev;
46747 scsi_dev->hostdata = res;
46748 res->change_detected = 0;
46749 - atomic_set(&res->read_failures, 0);
46750 - atomic_set(&res->write_failures, 0);
46751 + atomic_set_unchecked(&res->read_failures, 0);
46752 + atomic_set_unchecked(&res->write_failures, 0);
46753 rc = 0;
46754 }
46755 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46756 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46757
46758 /* If this was a SCSI read/write command keep count of errors */
46759 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46760 - atomic_inc(&res->read_failures);
46761 + atomic_inc_unchecked(&res->read_failures);
46762 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46763 - atomic_inc(&res->write_failures);
46764 + atomic_inc_unchecked(&res->write_failures);
46765
46766 if (!RES_IS_GSCSI(res->cfg_entry) &&
46767 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46768 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46769 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46770 * hrrq_id assigned here in queuecommand
46771 */
46772 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46773 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46774 pinstance->num_hrrq;
46775 cmd->cmd_done = pmcraid_io_done;
46776
46777 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46778 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46779 * hrrq_id assigned here in queuecommand
46780 */
46781 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46782 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46783 pinstance->num_hrrq;
46784
46785 if (request_size) {
46786 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46787
46788 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46789 /* add resources only after host is added into system */
46790 - if (!atomic_read(&pinstance->expose_resources))
46791 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46792 return;
46793
46794 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46795 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46796 init_waitqueue_head(&pinstance->reset_wait_q);
46797
46798 atomic_set(&pinstance->outstanding_cmds, 0);
46799 - atomic_set(&pinstance->last_message_id, 0);
46800 - atomic_set(&pinstance->expose_resources, 0);
46801 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46802 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46803
46804 INIT_LIST_HEAD(&pinstance->free_res_q);
46805 INIT_LIST_HEAD(&pinstance->used_res_q);
46806 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46807 /* Schedule worker thread to handle CCN and take care of adding and
46808 * removing devices to OS
46809 */
46810 - atomic_set(&pinstance->expose_resources, 1);
46811 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46812 schedule_work(&pinstance->worker_q);
46813 return rc;
46814
46815 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46816 index e1d150f..6c6df44 100644
46817 --- a/drivers/scsi/pmcraid.h
46818 +++ b/drivers/scsi/pmcraid.h
46819 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46820 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46821
46822 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46823 - atomic_t last_message_id;
46824 + atomic_unchecked_t last_message_id;
46825
46826 /* configuration table */
46827 struct pmcraid_config_table *cfg_table;
46828 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46829 atomic_t outstanding_cmds;
46830
46831 /* should add/delete resources to mid-layer now ?*/
46832 - atomic_t expose_resources;
46833 + atomic_unchecked_t expose_resources;
46834
46835
46836
46837 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46838 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46839 };
46840 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46841 - atomic_t read_failures; /* count of failed READ commands */
46842 - atomic_t write_failures; /* count of failed WRITE commands */
46843 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46844 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46845
46846 /* To indicate add/delete/modify during CCN */
46847 u8 change_detected;
46848 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46849 index d7a99ae..801df70 100644
46850 --- a/drivers/scsi/qla2xxx/qla_attr.c
46851 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46852 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46853 return 0;
46854 }
46855
46856 -struct fc_function_template qla2xxx_transport_functions = {
46857 +fc_function_template_no_const qla2xxx_transport_functions = {
46858
46859 .show_host_node_name = 1,
46860 .show_host_port_name = 1,
46861 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46862 .bsg_timeout = qla24xx_bsg_timeout,
46863 };
46864
46865 -struct fc_function_template qla2xxx_transport_vport_functions = {
46866 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46867
46868 .show_host_node_name = 1,
46869 .show_host_port_name = 1,
46870 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46871 index 2d98232..a84298e 100644
46872 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46873 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46874 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46875 struct device_attribute;
46876 extern struct device_attribute *qla2x00_host_attrs[];
46877 struct fc_function_template;
46878 -extern struct fc_function_template qla2xxx_transport_functions;
46879 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46880 +extern fc_function_template_no_const qla2xxx_transport_functions;
46881 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46882 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46883 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46884 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46885 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46886 index 3e21e9f..426ba79 100644
46887 --- a/drivers/scsi/qla2xxx/qla_os.c
46888 +++ b/drivers/scsi/qla2xxx/qla_os.c
46889 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46890 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46891 /* Ok, a 64bit DMA mask is applicable. */
46892 ha->flags.enable_64bit_addressing = 1;
46893 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46894 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46895 + pax_open_kernel();
46896 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46897 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46898 + pax_close_kernel();
46899 return;
46900 }
46901 }
46902 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46903 index ddf16a8..80f4dd0 100644
46904 --- a/drivers/scsi/qla4xxx/ql4_def.h
46905 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46906 @@ -291,7 +291,7 @@ struct ddb_entry {
46907 * (4000 only) */
46908 atomic_t relogin_timer; /* Max Time to wait for
46909 * relogin to complete */
46910 - atomic_t relogin_retry_count; /* Num of times relogin has been
46911 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46912 * retried */
46913 uint32_t default_time2wait; /* Default Min time between
46914 * relogins (+aens) */
46915 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46916 index b246b3c..897004d 100644
46917 --- a/drivers/scsi/qla4xxx/ql4_os.c
46918 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46919 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46920 */
46921 if (!iscsi_is_session_online(cls_sess)) {
46922 /* Reset retry relogin timer */
46923 - atomic_inc(&ddb_entry->relogin_retry_count);
46924 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46925 DEBUG2(ql4_printk(KERN_INFO, ha,
46926 "%s: index[%d] relogin timed out-retrying"
46927 " relogin (%d), retry (%d)\n", __func__,
46928 ddb_entry->fw_ddb_index,
46929 - atomic_read(&ddb_entry->relogin_retry_count),
46930 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46931 ddb_entry->default_time2wait + 4));
46932 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46933 atomic_set(&ddb_entry->retry_relogin_timer,
46934 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46935
46936 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46937 atomic_set(&ddb_entry->relogin_timer, 0);
46938 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46939 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46940 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46941 ddb_entry->default_relogin_timeout =
46942 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46943 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46944 index eaa808e..95f8841 100644
46945 --- a/drivers/scsi/scsi.c
46946 +++ b/drivers/scsi/scsi.c
46947 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46948 unsigned long timeout;
46949 int rtn = 0;
46950
46951 - atomic_inc(&cmd->device->iorequest_cnt);
46952 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46953
46954 /* check if the device is still usable */
46955 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46956 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46957 index 124392f..75eb43e 100644
46958 --- a/drivers/scsi/scsi_lib.c
46959 +++ b/drivers/scsi/scsi_lib.c
46960 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46961 shost = sdev->host;
46962 scsi_init_cmd_errh(cmd);
46963 cmd->result = DID_NO_CONNECT << 16;
46964 - atomic_inc(&cmd->device->iorequest_cnt);
46965 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46966
46967 /*
46968 * SCSI request completion path will do scsi_device_unbusy(),
46969 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46970
46971 INIT_LIST_HEAD(&cmd->eh_entry);
46972
46973 - atomic_inc(&cmd->device->iodone_cnt);
46974 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46975 if (cmd->result)
46976 - atomic_inc(&cmd->device->ioerr_cnt);
46977 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46978
46979 disposition = scsi_decide_disposition(cmd);
46980 if (disposition != SUCCESS &&
46981 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46982 index 7e50061..71db7a6 100644
46983 --- a/drivers/scsi/scsi_sysfs.c
46984 +++ b/drivers/scsi/scsi_sysfs.c
46985 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46986 char *buf) \
46987 { \
46988 struct scsi_device *sdev = to_scsi_device(dev); \
46989 - unsigned long long count = atomic_read(&sdev->field); \
46990 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46991 return snprintf(buf, 20, "0x%llx\n", count); \
46992 } \
46993 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46994 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46995 index 84a1fdf..693b0d6 100644
46996 --- a/drivers/scsi/scsi_tgt_lib.c
46997 +++ b/drivers/scsi/scsi_tgt_lib.c
46998 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46999 int err;
47000
47001 dprintk("%lx %u\n", uaddr, len);
47002 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47003 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47004 if (err) {
47005 /*
47006 * TODO: need to fixup sg_tablesize, max_segment_size,
47007 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47008 index 4628fd5..a94a1c2 100644
47009 --- a/drivers/scsi/scsi_transport_fc.c
47010 +++ b/drivers/scsi/scsi_transport_fc.c
47011 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47012 * Netlink Infrastructure
47013 */
47014
47015 -static atomic_t fc_event_seq;
47016 +static atomic_unchecked_t fc_event_seq;
47017
47018 /**
47019 * fc_get_event_number - Obtain the next sequential FC event number
47020 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47021 u32
47022 fc_get_event_number(void)
47023 {
47024 - return atomic_add_return(1, &fc_event_seq);
47025 + return atomic_add_return_unchecked(1, &fc_event_seq);
47026 }
47027 EXPORT_SYMBOL(fc_get_event_number);
47028
47029 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47030 {
47031 int error;
47032
47033 - atomic_set(&fc_event_seq, 0);
47034 + atomic_set_unchecked(&fc_event_seq, 0);
47035
47036 error = transport_class_register(&fc_host_class);
47037 if (error)
47038 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47039 char *cp;
47040
47041 *val = simple_strtoul(buf, &cp, 0);
47042 - if ((*cp && (*cp != '\n')) || (*val < 0))
47043 + if (*cp && (*cp != '\n'))
47044 return -EINVAL;
47045 /*
47046 * Check for overflow; dev_loss_tmo is u32
47047 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47048 index abf7c40..c3240ed 100644
47049 --- a/drivers/scsi/scsi_transport_iscsi.c
47050 +++ b/drivers/scsi/scsi_transport_iscsi.c
47051 @@ -80,7 +80,7 @@ struct iscsi_internal {
47052 struct transport_container session_cont;
47053 };
47054
47055 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47056 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47057 static struct workqueue_struct *iscsi_eh_timer_workq;
47058
47059 static DEFINE_IDA(iscsi_sess_ida);
47060 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47061 int err;
47062
47063 ihost = shost->shost_data;
47064 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47065 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47066
47067 if (target_id == ISCSI_MAX_TARGET) {
47068 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47069 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47070 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47071 ISCSI_TRANSPORT_VERSION);
47072
47073 - atomic_set(&iscsi_session_nr, 0);
47074 + atomic_set_unchecked(&iscsi_session_nr, 0);
47075
47076 err = class_register(&iscsi_transport_class);
47077 if (err)
47078 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47079 index f379c7f..e8fc69c 100644
47080 --- a/drivers/scsi/scsi_transport_srp.c
47081 +++ b/drivers/scsi/scsi_transport_srp.c
47082 @@ -33,7 +33,7 @@
47083 #include "scsi_transport_srp_internal.h"
47084
47085 struct srp_host_attrs {
47086 - atomic_t next_port_id;
47087 + atomic_unchecked_t next_port_id;
47088 };
47089 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47090
47091 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47092 struct Scsi_Host *shost = dev_to_shost(dev);
47093 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47094
47095 - atomic_set(&srp_host->next_port_id, 0);
47096 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47097 return 0;
47098 }
47099
47100 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47101 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47102 rport->roles = ids->roles;
47103
47104 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47105 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47106 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47107
47108 transport_setup_device(&rport->dev);
47109 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47110 index 83e9070..9cb646f 100644
47111 --- a/drivers/scsi/sd.c
47112 +++ b/drivers/scsi/sd.c
47113 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47114 sdkp->disk = gd;
47115 sdkp->index = index;
47116 atomic_set(&sdkp->openers, 0);
47117 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47118 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47119
47120 if (!sdp->request_queue->rq_timeout) {
47121 if (sdp->type != TYPE_MOD)
47122 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47123 index df5e961..df6b97f 100644
47124 --- a/drivers/scsi/sg.c
47125 +++ b/drivers/scsi/sg.c
47126 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47127 sdp->disk->disk_name,
47128 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47129 NULL,
47130 - (char *)arg);
47131 + (char __user *)arg);
47132 case BLKTRACESTART:
47133 return blk_trace_startstop(sdp->device->request_queue, 1);
47134 case BLKTRACESTOP:
47135 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47136 index 978dda2..cb19aa0 100644
47137 --- a/drivers/spi/spi.c
47138 +++ b/drivers/spi/spi.c
47139 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47140 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47141
47142 /* portable code must never pass more than 32 bytes */
47143 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47144 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47145
47146 static u8 *buf;
47147
47148 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47149 index ee3a57f..18368c1 100644
47150 --- a/drivers/staging/android/timed_output.c
47151 +++ b/drivers/staging/android/timed_output.c
47152 @@ -25,7 +25,7 @@
47153 #include "timed_output.h"
47154
47155 static struct class *timed_output_class;
47156 -static atomic_t device_count;
47157 +static atomic_unchecked_t device_count;
47158
47159 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47160 char *buf)
47161 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47162 timed_output_class = class_create(THIS_MODULE, "timed_output");
47163 if (IS_ERR(timed_output_class))
47164 return PTR_ERR(timed_output_class);
47165 - atomic_set(&device_count, 0);
47166 + atomic_set_unchecked(&device_count, 0);
47167 }
47168
47169 return 0;
47170 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47171 if (ret < 0)
47172 return ret;
47173
47174 - tdev->index = atomic_inc_return(&device_count);
47175 + tdev->index = atomic_inc_return_unchecked(&device_count);
47176 tdev->dev = device_create(timed_output_class, NULL,
47177 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47178 if (IS_ERR(tdev->dev))
47179 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47180 index 3675020..e80d92c 100644
47181 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47182 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47183 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47184
47185 static int solo_sysfs_init(struct solo_dev *solo_dev)
47186 {
47187 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47188 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47189 struct device *dev = &solo_dev->dev;
47190 const char *driver;
47191 int i;
47192 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47193 index 3335941..2b26186 100644
47194 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47195 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47196 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47197
47198 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47199 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47200 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47201 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47202 if (p2m_id < 0)
47203 p2m_id = -p2m_id;
47204 }
47205 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47206 index 6f91d2e..3f011d2 100644
47207 --- a/drivers/staging/media/solo6x10/solo6x10.h
47208 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47209 @@ -238,7 +238,7 @@ struct solo_dev {
47210
47211 /* P2M DMA Engine */
47212 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47213 - atomic_t p2m_count;
47214 + atomic_unchecked_t p2m_count;
47215 int p2m_jiffies;
47216 unsigned int p2m_timeouts;
47217
47218 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47219 index 34afc16..ffe44dd 100644
47220 --- a/drivers/staging/octeon/ethernet-rx.c
47221 +++ b/drivers/staging/octeon/ethernet-rx.c
47222 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47223 /* Increment RX stats for virtual ports */
47224 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47225 #ifdef CONFIG_64BIT
47226 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47227 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47228 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47229 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47230 #else
47231 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47232 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47233 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47234 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47235 #endif
47236 }
47237 netif_receive_skb(skb);
47238 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47239 dev->name);
47240 */
47241 #ifdef CONFIG_64BIT
47242 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47243 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47244 #else
47245 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47246 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47247 #endif
47248 dev_kfree_skb_irq(skb);
47249 }
47250 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47251 index c3a90e7..023619a 100644
47252 --- a/drivers/staging/octeon/ethernet.c
47253 +++ b/drivers/staging/octeon/ethernet.c
47254 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47255 * since the RX tasklet also increments it.
47256 */
47257 #ifdef CONFIG_64BIT
47258 - atomic64_add(rx_status.dropped_packets,
47259 - (atomic64_t *)&priv->stats.rx_dropped);
47260 + atomic64_add_unchecked(rx_status.dropped_packets,
47261 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47262 #else
47263 - atomic_add(rx_status.dropped_packets,
47264 - (atomic_t *)&priv->stats.rx_dropped);
47265 + atomic_add_unchecked(rx_status.dropped_packets,
47266 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47267 #endif
47268 }
47269
47270 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47271 index dc23395..cf7e9b1 100644
47272 --- a/drivers/staging/rtl8712/rtl871x_io.h
47273 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47274 @@ -108,7 +108,7 @@ struct _io_ops {
47275 u8 *pmem);
47276 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47277 u8 *pmem);
47278 -};
47279 +} __no_const;
47280
47281 struct io_req {
47282 struct list_head list;
47283 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47284 index 1f5088b..0e59820 100644
47285 --- a/drivers/staging/sbe-2t3e3/netdev.c
47286 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47287 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47288 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47289
47290 if (rlen)
47291 - if (copy_to_user(data, &resp, rlen))
47292 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47293 return -EFAULT;
47294
47295 return 0;
47296 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47297 index a863a98..d272795 100644
47298 --- a/drivers/staging/usbip/vhci.h
47299 +++ b/drivers/staging/usbip/vhci.h
47300 @@ -83,7 +83,7 @@ struct vhci_hcd {
47301 unsigned resuming:1;
47302 unsigned long re_timeout;
47303
47304 - atomic_t seqnum;
47305 + atomic_unchecked_t seqnum;
47306
47307 /*
47308 * NOTE:
47309 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47310 index d7974cb..d78076b 100644
47311 --- a/drivers/staging/usbip/vhci_hcd.c
47312 +++ b/drivers/staging/usbip/vhci_hcd.c
47313 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47314
47315 spin_lock(&vdev->priv_lock);
47316
47317 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47318 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47319 if (priv->seqnum == 0xffff)
47320 dev_info(&urb->dev->dev, "seqnum max\n");
47321
47322 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47323 return -ENOMEM;
47324 }
47325
47326 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47327 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47328 if (unlink->seqnum == 0xffff)
47329 pr_info("seqnum max\n");
47330
47331 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47332 vdev->rhport = rhport;
47333 }
47334
47335 - atomic_set(&vhci->seqnum, 0);
47336 + atomic_set_unchecked(&vhci->seqnum, 0);
47337 spin_lock_init(&vhci->lock);
47338
47339 hcd->power_budget = 0; /* no limit */
47340 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47341 index d07fcb5..358e1e1 100644
47342 --- a/drivers/staging/usbip/vhci_rx.c
47343 +++ b/drivers/staging/usbip/vhci_rx.c
47344 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47345 if (!urb) {
47346 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47347 pr_info("max seqnum %d\n",
47348 - atomic_read(&the_controller->seqnum));
47349 + atomic_read_unchecked(&the_controller->seqnum));
47350 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47351 return;
47352 }
47353 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47354 index 57a08c5..5b4bb7c 100644
47355 --- a/drivers/staging/vt6655/hostap.c
47356 +++ b/drivers/staging/vt6655/hostap.c
47357 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47358 *
47359 */
47360
47361 +static net_device_ops_no_const apdev_netdev_ops;
47362 +
47363 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47364 {
47365 PSDevice apdev_priv;
47366 struct net_device *dev = pDevice->dev;
47367 int ret;
47368 - const struct net_device_ops apdev_netdev_ops = {
47369 - .ndo_start_xmit = pDevice->tx_80211,
47370 - };
47371
47372 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47373
47374 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47375 *apdev_priv = *pDevice;
47376 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47377
47378 + /* only half broken now */
47379 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47380 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47381
47382 pDevice->apdev->type = ARPHRD_IEEE80211;
47383 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47384 index c699a30..b90a5fd 100644
47385 --- a/drivers/staging/vt6656/hostap.c
47386 +++ b/drivers/staging/vt6656/hostap.c
47387 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47388 *
47389 */
47390
47391 +static net_device_ops_no_const apdev_netdev_ops;
47392 +
47393 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47394 {
47395 struct vnt_private *apdev_priv;
47396 struct net_device *dev = pDevice->dev;
47397 int ret;
47398 - const struct net_device_ops apdev_netdev_ops = {
47399 - .ndo_start_xmit = pDevice->tx_80211,
47400 - };
47401
47402 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47403
47404 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47405 *apdev_priv = *pDevice;
47406 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47407
47408 + /* only half broken now */
47409 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47410 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47411
47412 pDevice->apdev->type = ARPHRD_IEEE80211;
47413 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47414 index d128ce2..fc1f9a1 100644
47415 --- a/drivers/staging/zcache/tmem.h
47416 +++ b/drivers/staging/zcache/tmem.h
47417 @@ -225,7 +225,7 @@ struct tmem_pamops {
47418 bool (*is_remote)(void *);
47419 int (*replace_in_obj)(void *, struct tmem_obj *);
47420 #endif
47421 -};
47422 +} __no_const;
47423 extern void tmem_register_pamops(struct tmem_pamops *m);
47424
47425 /* memory allocation methods provided by the host implementation */
47426 @@ -234,7 +234,7 @@ struct tmem_hostops {
47427 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47428 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47429 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47430 -};
47431 +} __no_const;
47432 extern void tmem_register_hostops(struct tmem_hostops *m);
47433
47434 /* core tmem accessor functions */
47435 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47436 index e51b09a..5ebac31 100644
47437 --- a/drivers/target/sbp/sbp_target.c
47438 +++ b/drivers/target/sbp/sbp_target.c
47439 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47440
47441 #define SESSION_MAINTENANCE_INTERVAL HZ
47442
47443 -static atomic_t login_id = ATOMIC_INIT(0);
47444 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47445
47446 static void session_maintenance_work(struct work_struct *);
47447 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47448 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47449 login->lun = se_lun;
47450 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47451 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47452 - login->login_id = atomic_inc_return(&login_id);
47453 + login->login_id = atomic_inc_return_unchecked(&login_id);
47454
47455 login->tgt_agt = sbp_target_agent_register(login);
47456 if (IS_ERR(login->tgt_agt)) {
47457 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47458 index 8f4142f..b127f7d 100644
47459 --- a/drivers/target/target_core_device.c
47460 +++ b/drivers/target/target_core_device.c
47461 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47462 spin_lock_init(&dev->se_port_lock);
47463 spin_lock_init(&dev->se_tmr_lock);
47464 spin_lock_init(&dev->qf_cmd_lock);
47465 - atomic_set(&dev->dev_ordered_id, 0);
47466 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47467 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47468 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47469 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47470 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47471 index d8e49d7..6fcfdec 100644
47472 --- a/drivers/target/target_core_transport.c
47473 +++ b/drivers/target/target_core_transport.c
47474 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47475 * Used to determine when ORDERED commands should go from
47476 * Dormant to Active status.
47477 */
47478 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47479 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47480 smp_mb__after_atomic_inc();
47481 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47482 cmd->se_ordered_id, cmd->sam_task_attr,
47483 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47484 index 33f83fe..d80f8e1 100644
47485 --- a/drivers/tty/cyclades.c
47486 +++ b/drivers/tty/cyclades.c
47487 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47488 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47489 info->port.count);
47490 #endif
47491 - info->port.count++;
47492 + atomic_inc(&info->port.count);
47493 #ifdef CY_DEBUG_COUNT
47494 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47495 - current->pid, info->port.count);
47496 + current->pid, atomic_read(&info->port.count));
47497 #endif
47498
47499 /*
47500 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47501 for (j = 0; j < cy_card[i].nports; j++) {
47502 info = &cy_card[i].ports[j];
47503
47504 - if (info->port.count) {
47505 + if (atomic_read(&info->port.count)) {
47506 /* XXX is the ldisc num worth this? */
47507 struct tty_struct *tty;
47508 struct tty_ldisc *ld;
47509 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47510 index eb255e8..f637a57 100644
47511 --- a/drivers/tty/hvc/hvc_console.c
47512 +++ b/drivers/tty/hvc/hvc_console.c
47513 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47514
47515 spin_lock_irqsave(&hp->port.lock, flags);
47516 /* Check and then increment for fast path open. */
47517 - if (hp->port.count++ > 0) {
47518 + if (atomic_inc_return(&hp->port.count) > 1) {
47519 spin_unlock_irqrestore(&hp->port.lock, flags);
47520 hvc_kick();
47521 return 0;
47522 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47523
47524 spin_lock_irqsave(&hp->port.lock, flags);
47525
47526 - if (--hp->port.count == 0) {
47527 + if (atomic_dec_return(&hp->port.count) == 0) {
47528 spin_unlock_irqrestore(&hp->port.lock, flags);
47529 /* We are done with the tty pointer now. */
47530 tty_port_tty_set(&hp->port, NULL);
47531 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47532 */
47533 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47534 } else {
47535 - if (hp->port.count < 0)
47536 + if (atomic_read(&hp->port.count) < 0)
47537 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47538 - hp->vtermno, hp->port.count);
47539 + hp->vtermno, atomic_read(&hp->port.count));
47540 spin_unlock_irqrestore(&hp->port.lock, flags);
47541 }
47542 }
47543 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47544 * open->hangup case this can be called after the final close so prevent
47545 * that from happening for now.
47546 */
47547 - if (hp->port.count <= 0) {
47548 + if (atomic_read(&hp->port.count) <= 0) {
47549 spin_unlock_irqrestore(&hp->port.lock, flags);
47550 return;
47551 }
47552
47553 - hp->port.count = 0;
47554 + atomic_set(&hp->port.count, 0);
47555 spin_unlock_irqrestore(&hp->port.lock, flags);
47556 tty_port_tty_set(&hp->port, NULL);
47557
47558 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47559 return -EPIPE;
47560
47561 /* FIXME what's this (unprotected) check for? */
47562 - if (hp->port.count <= 0)
47563 + if (atomic_read(&hp->port.count) <= 0)
47564 return -EIO;
47565
47566 spin_lock_irqsave(&hp->lock, flags);
47567 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47568 index 81e939e..95ead10 100644
47569 --- a/drivers/tty/hvc/hvcs.c
47570 +++ b/drivers/tty/hvc/hvcs.c
47571 @@ -83,6 +83,7 @@
47572 #include <asm/hvcserver.h>
47573 #include <asm/uaccess.h>
47574 #include <asm/vio.h>
47575 +#include <asm/local.h>
47576
47577 /*
47578 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47579 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47580
47581 spin_lock_irqsave(&hvcsd->lock, flags);
47582
47583 - if (hvcsd->port.count > 0) {
47584 + if (atomic_read(&hvcsd->port.count) > 0) {
47585 spin_unlock_irqrestore(&hvcsd->lock, flags);
47586 printk(KERN_INFO "HVCS: vterm state unchanged. "
47587 "The hvcs device node is still in use.\n");
47588 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47589 }
47590 }
47591
47592 - hvcsd->port.count = 0;
47593 + atomic_set(&hvcsd->port.count, 0);
47594 hvcsd->port.tty = tty;
47595 tty->driver_data = hvcsd;
47596
47597 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47598 unsigned long flags;
47599
47600 spin_lock_irqsave(&hvcsd->lock, flags);
47601 - hvcsd->port.count++;
47602 + atomic_inc(&hvcsd->port.count);
47603 hvcsd->todo_mask |= HVCS_SCHED_READ;
47604 spin_unlock_irqrestore(&hvcsd->lock, flags);
47605
47606 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47607 hvcsd = tty->driver_data;
47608
47609 spin_lock_irqsave(&hvcsd->lock, flags);
47610 - if (--hvcsd->port.count == 0) {
47611 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47612
47613 vio_disable_interrupts(hvcsd->vdev);
47614
47615 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47616
47617 free_irq(irq, hvcsd);
47618 return;
47619 - } else if (hvcsd->port.count < 0) {
47620 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47621 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47622 " is missmanaged.\n",
47623 - hvcsd->vdev->unit_address, hvcsd->port.count);
47624 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47625 }
47626
47627 spin_unlock_irqrestore(&hvcsd->lock, flags);
47628 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47629
47630 spin_lock_irqsave(&hvcsd->lock, flags);
47631 /* Preserve this so that we know how many kref refs to put */
47632 - temp_open_count = hvcsd->port.count;
47633 + temp_open_count = atomic_read(&hvcsd->port.count);
47634
47635 /*
47636 * Don't kref put inside the spinlock because the destruction
47637 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47638 tty->driver_data = NULL;
47639 hvcsd->port.tty = NULL;
47640
47641 - hvcsd->port.count = 0;
47642 + atomic_set(&hvcsd->port.count, 0);
47643
47644 /* This will drop any buffered data on the floor which is OK in a hangup
47645 * scenario. */
47646 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47647 * the middle of a write operation? This is a crummy place to do this
47648 * but we want to keep it all in the spinlock.
47649 */
47650 - if (hvcsd->port.count <= 0) {
47651 + if (atomic_read(&hvcsd->port.count) <= 0) {
47652 spin_unlock_irqrestore(&hvcsd->lock, flags);
47653 return -ENODEV;
47654 }
47655 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47656 {
47657 struct hvcs_struct *hvcsd = tty->driver_data;
47658
47659 - if (!hvcsd || hvcsd->port.count <= 0)
47660 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47661 return 0;
47662
47663 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47664 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47665 index 4190199..48f2920 100644
47666 --- a/drivers/tty/hvc/hvsi.c
47667 +++ b/drivers/tty/hvc/hvsi.c
47668 @@ -85,7 +85,7 @@ struct hvsi_struct {
47669 int n_outbuf;
47670 uint32_t vtermno;
47671 uint32_t virq;
47672 - atomic_t seqno; /* HVSI packet sequence number */
47673 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47674 uint16_t mctrl;
47675 uint8_t state; /* HVSI protocol state */
47676 uint8_t flags;
47677 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47678
47679 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47680 packet.hdr.len = sizeof(struct hvsi_query_response);
47681 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47682 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47683 packet.verb = VSV_SEND_VERSION_NUMBER;
47684 packet.u.version = HVSI_VERSION;
47685 packet.query_seqno = query_seqno+1;
47686 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47687
47688 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47689 packet.hdr.len = sizeof(struct hvsi_query);
47690 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47691 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47692 packet.verb = verb;
47693
47694 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47695 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47696 int wrote;
47697
47698 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47699 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47700 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47701 packet.hdr.len = sizeof(struct hvsi_control);
47702 packet.verb = VSV_SET_MODEM_CTL;
47703 packet.mask = HVSI_TSDTR;
47704 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47705 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47706
47707 packet.hdr.type = VS_DATA_PACKET_HEADER;
47708 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47709 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47710 packet.hdr.len = count + sizeof(struct hvsi_header);
47711 memcpy(&packet.data, buf, count);
47712
47713 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47714 struct hvsi_control packet __ALIGNED__;
47715
47716 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47717 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47718 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47719 packet.hdr.len = 6;
47720 packet.verb = VSV_CLOSE_PROTOCOL;
47721
47722 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47723 index ac27671..0f627ee 100644
47724 --- a/drivers/tty/hvc/hvsi_lib.c
47725 +++ b/drivers/tty/hvc/hvsi_lib.c
47726 @@ -9,7 +9,7 @@
47727
47728 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47729 {
47730 - packet->seqno = atomic_inc_return(&pv->seqno);
47731 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47732
47733 /* Assumes that always succeeds, works in practice */
47734 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47735 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47736
47737 /* Reset state */
47738 pv->established = 0;
47739 - atomic_set(&pv->seqno, 0);
47740 + atomic_set_unchecked(&pv->seqno, 0);
47741
47742 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47743
47744 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47745 pv->mctrl_update = 0;
47746 q.hdr.type = VS_QUERY_PACKET_HEADER;
47747 q.hdr.len = sizeof(struct hvsi_query);
47748 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47749 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47750 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47751 rc = hvsi_send_packet(pv, &q.hdr);
47752 if (rc <= 0) {
47753 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47754 index 8fd72ff..34a0bed 100644
47755 --- a/drivers/tty/ipwireless/tty.c
47756 +++ b/drivers/tty/ipwireless/tty.c
47757 @@ -29,6 +29,7 @@
47758 #include <linux/tty_driver.h>
47759 #include <linux/tty_flip.h>
47760 #include <linux/uaccess.h>
47761 +#include <asm/local.h>
47762
47763 #include "tty.h"
47764 #include "network.h"
47765 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47766 mutex_unlock(&tty->ipw_tty_mutex);
47767 return -ENODEV;
47768 }
47769 - if (tty->port.count == 0)
47770 + if (atomic_read(&tty->port.count) == 0)
47771 tty->tx_bytes_queued = 0;
47772
47773 - tty->port.count++;
47774 + atomic_inc(&tty->port.count);
47775
47776 tty->port.tty = linux_tty;
47777 linux_tty->driver_data = tty;
47778 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47779
47780 static void do_ipw_close(struct ipw_tty *tty)
47781 {
47782 - tty->port.count--;
47783 -
47784 - if (tty->port.count == 0) {
47785 + if (atomic_dec_return(&tty->port.count) == 0) {
47786 struct tty_struct *linux_tty = tty->port.tty;
47787
47788 if (linux_tty != NULL) {
47789 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47790 return;
47791
47792 mutex_lock(&tty->ipw_tty_mutex);
47793 - if (tty->port.count == 0) {
47794 + if (atomic_read(&tty->port.count) == 0) {
47795 mutex_unlock(&tty->ipw_tty_mutex);
47796 return;
47797 }
47798 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47799
47800 mutex_lock(&tty->ipw_tty_mutex);
47801
47802 - if (!tty->port.count) {
47803 + if (!atomic_read(&tty->port.count)) {
47804 mutex_unlock(&tty->ipw_tty_mutex);
47805 return;
47806 }
47807 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47808 return -ENODEV;
47809
47810 mutex_lock(&tty->ipw_tty_mutex);
47811 - if (!tty->port.count) {
47812 + if (!atomic_read(&tty->port.count)) {
47813 mutex_unlock(&tty->ipw_tty_mutex);
47814 return -EINVAL;
47815 }
47816 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47817 if (!tty)
47818 return -ENODEV;
47819
47820 - if (!tty->port.count)
47821 + if (!atomic_read(&tty->port.count))
47822 return -EINVAL;
47823
47824 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47825 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47826 if (!tty)
47827 return 0;
47828
47829 - if (!tty->port.count)
47830 + if (!atomic_read(&tty->port.count))
47831 return 0;
47832
47833 return tty->tx_bytes_queued;
47834 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47835 if (!tty)
47836 return -ENODEV;
47837
47838 - if (!tty->port.count)
47839 + if (!atomic_read(&tty->port.count))
47840 return -EINVAL;
47841
47842 return get_control_lines(tty);
47843 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47844 if (!tty)
47845 return -ENODEV;
47846
47847 - if (!tty->port.count)
47848 + if (!atomic_read(&tty->port.count))
47849 return -EINVAL;
47850
47851 return set_control_lines(tty, set, clear);
47852 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47853 if (!tty)
47854 return -ENODEV;
47855
47856 - if (!tty->port.count)
47857 + if (!atomic_read(&tty->port.count))
47858 return -EINVAL;
47859
47860 /* FIXME: Exactly how is the tty object locked here .. */
47861 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47862 * are gone */
47863 mutex_lock(&ttyj->ipw_tty_mutex);
47864 }
47865 - while (ttyj->port.count)
47866 + while (atomic_read(&ttyj->port.count))
47867 do_ipw_close(ttyj);
47868 ipwireless_disassociate_network_ttys(network,
47869 ttyj->channel_idx);
47870 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47871 index 1deaca4..c8582d4 100644
47872 --- a/drivers/tty/moxa.c
47873 +++ b/drivers/tty/moxa.c
47874 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47875 }
47876
47877 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47878 - ch->port.count++;
47879 + atomic_inc(&ch->port.count);
47880 tty->driver_data = ch;
47881 tty_port_tty_set(&ch->port, tty);
47882 mutex_lock(&ch->port.mutex);
47883 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47884 index 6422390..49003ac8 100644
47885 --- a/drivers/tty/n_gsm.c
47886 +++ b/drivers/tty/n_gsm.c
47887 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47888 spin_lock_init(&dlci->lock);
47889 mutex_init(&dlci->mutex);
47890 dlci->fifo = &dlci->_fifo;
47891 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47892 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47893 kfree(dlci);
47894 return NULL;
47895 }
47896 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47897 struct gsm_dlci *dlci = tty->driver_data;
47898 struct tty_port *port = &dlci->port;
47899
47900 - port->count++;
47901 + atomic_inc(&port->count);
47902 dlci_get(dlci);
47903 dlci_get(dlci->gsm->dlci[0]);
47904 mux_get(dlci->gsm);
47905 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47906 index 4bf0fc0..433bd58 100644
47907 --- a/drivers/tty/n_tty.c
47908 +++ b/drivers/tty/n_tty.c
47909 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47910 {
47911 *ops = tty_ldisc_N_TTY;
47912 ops->owner = NULL;
47913 - ops->refcount = ops->flags = 0;
47914 + atomic_set(&ops->refcount, 0);
47915 + ops->flags = 0;
47916 }
47917 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47918 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47919 index abfd990..5ab5da9 100644
47920 --- a/drivers/tty/pty.c
47921 +++ b/drivers/tty/pty.c
47922 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47923 panic("Couldn't register Unix98 pts driver");
47924
47925 /* Now create the /dev/ptmx special device */
47926 + pax_open_kernel();
47927 tty_default_fops(&ptmx_fops);
47928 - ptmx_fops.open = ptmx_open;
47929 + *(void **)&ptmx_fops.open = ptmx_open;
47930 + pax_close_kernel();
47931
47932 cdev_init(&ptmx_cdev, &ptmx_fops);
47933 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47934 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47935 index 354564e..fe50d9a 100644
47936 --- a/drivers/tty/rocket.c
47937 +++ b/drivers/tty/rocket.c
47938 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47939 tty->driver_data = info;
47940 tty_port_tty_set(port, tty);
47941
47942 - if (port->count++ == 0) {
47943 + if (atomic_inc_return(&port->count) == 1) {
47944 atomic_inc(&rp_num_ports_open);
47945
47946 #ifdef ROCKET_DEBUG_OPEN
47947 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47948 #endif
47949 }
47950 #ifdef ROCKET_DEBUG_OPEN
47951 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47952 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47953 #endif
47954
47955 /*
47956 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47957 spin_unlock_irqrestore(&info->port.lock, flags);
47958 return;
47959 }
47960 - if (info->port.count)
47961 + if (atomic_read(&info->port.count))
47962 atomic_dec(&rp_num_ports_open);
47963 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47964 spin_unlock_irqrestore(&info->port.lock, flags);
47965 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47966 index e2520ab..034e20b 100644
47967 --- a/drivers/tty/serial/ioc4_serial.c
47968 +++ b/drivers/tty/serial/ioc4_serial.c
47969 @@ -437,7 +437,7 @@ struct ioc4_soft {
47970 } is_intr_info[MAX_IOC4_INTR_ENTS];
47971
47972 /* Number of entries active in the above array */
47973 - atomic_t is_num_intrs;
47974 + atomic_unchecked_t is_num_intrs;
47975 } is_intr_type[IOC4_NUM_INTR_TYPES];
47976
47977 /* is_ir_lock must be held while
47978 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47979 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47980 || (type == IOC4_OTHER_INTR_TYPE)));
47981
47982 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47983 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47984 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47985
47986 /* Save off the lower level interrupt handler */
47987 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47988
47989 soft = arg;
47990 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47991 - num_intrs = (int)atomic_read(
47992 + num_intrs = (int)atomic_read_unchecked(
47993 &soft->is_intr_type[intr_type].is_num_intrs);
47994
47995 this_mir = this_ir = pending_intrs(soft, intr_type);
47996 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47997 index 1002054..dd644a8 100644
47998 --- a/drivers/tty/serial/kgdboc.c
47999 +++ b/drivers/tty/serial/kgdboc.c
48000 @@ -24,8 +24,9 @@
48001 #define MAX_CONFIG_LEN 40
48002
48003 static struct kgdb_io kgdboc_io_ops;
48004 +static struct kgdb_io kgdboc_io_ops_console;
48005
48006 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48007 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48008 static int configured = -1;
48009
48010 static char config[MAX_CONFIG_LEN];
48011 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48012 kgdboc_unregister_kbd();
48013 if (configured == 1)
48014 kgdb_unregister_io_module(&kgdboc_io_ops);
48015 + else if (configured == 2)
48016 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48017 }
48018
48019 static int configure_kgdboc(void)
48020 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48021 int err;
48022 char *cptr = config;
48023 struct console *cons;
48024 + int is_console = 0;
48025
48026 err = kgdboc_option_setup(config);
48027 if (err || !strlen(config) || isspace(config[0]))
48028 goto noconfig;
48029
48030 err = -ENODEV;
48031 - kgdboc_io_ops.is_console = 0;
48032 kgdb_tty_driver = NULL;
48033
48034 kgdboc_use_kms = 0;
48035 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48036 int idx;
48037 if (cons->device && cons->device(cons, &idx) == p &&
48038 idx == tty_line) {
48039 - kgdboc_io_ops.is_console = 1;
48040 + is_console = 1;
48041 break;
48042 }
48043 cons = cons->next;
48044 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48045 kgdb_tty_line = tty_line;
48046
48047 do_register:
48048 - err = kgdb_register_io_module(&kgdboc_io_ops);
48049 + if (is_console) {
48050 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48051 + configured = 2;
48052 + } else {
48053 + err = kgdb_register_io_module(&kgdboc_io_ops);
48054 + configured = 1;
48055 + }
48056 if (err)
48057 goto noconfig;
48058
48059 @@ -205,8 +214,6 @@ do_register:
48060 if (err)
48061 goto nmi_con_failed;
48062
48063 - configured = 1;
48064 -
48065 return 0;
48066
48067 nmi_con_failed:
48068 @@ -223,7 +230,7 @@ noconfig:
48069 static int __init init_kgdboc(void)
48070 {
48071 /* Already configured? */
48072 - if (configured == 1)
48073 + if (configured >= 1)
48074 return 0;
48075
48076 return configure_kgdboc();
48077 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48078 if (config[len - 1] == '\n')
48079 config[len - 1] = '\0';
48080
48081 - if (configured == 1)
48082 + if (configured >= 1)
48083 cleanup_kgdboc();
48084
48085 /* Go and configure with the new params. */
48086 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48087 .post_exception = kgdboc_post_exp_handler,
48088 };
48089
48090 +static struct kgdb_io kgdboc_io_ops_console = {
48091 + .name = "kgdboc",
48092 + .read_char = kgdboc_get_char,
48093 + .write_char = kgdboc_put_char,
48094 + .pre_exception = kgdboc_pre_exp_handler,
48095 + .post_exception = kgdboc_post_exp_handler,
48096 + .is_console = 1
48097 +};
48098 +
48099 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48100 /* This is only available if kgdboc is a built in for early debugging */
48101 static int __init kgdboc_early_init(char *opt)
48102 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48103 index 2c6cfb3..048274e 100644
48104 --- a/drivers/tty/serial/msm_serial.c
48105 +++ b/drivers/tty/serial/msm_serial.c
48106 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48107 .cons = MSM_CONSOLE,
48108 };
48109
48110 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48111 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48112
48113 static int __init msm_serial_probe(struct platform_device *pdev)
48114 {
48115 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48116 int irq;
48117
48118 if (pdev->id == -1)
48119 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48120 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48121
48122 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48123 return -ENXIO;
48124 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48125 index 376079b..d8de7aa 100644
48126 --- a/drivers/tty/serial/samsung.c
48127 +++ b/drivers/tty/serial/samsung.c
48128 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48129 }
48130 }
48131
48132 +static int s3c64xx_serial_startup(struct uart_port *port);
48133 static int s3c24xx_serial_startup(struct uart_port *port)
48134 {
48135 struct s3c24xx_uart_port *ourport = to_ourport(port);
48136 int ret;
48137
48138 + /* Startup sequence is different for s3c64xx and higher SoC's */
48139 + if (s3c24xx_serial_has_interrupt_mask(port))
48140 + return s3c64xx_serial_startup(port);
48141 +
48142 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48143 port->mapbase, port->membase);
48144
48145 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48146 /* setup info for port */
48147 port->dev = &platdev->dev;
48148
48149 - /* Startup sequence is different for s3c64xx and higher SoC's */
48150 - if (s3c24xx_serial_has_interrupt_mask(port))
48151 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48152 -
48153 port->uartclk = 1;
48154
48155 if (cfg->uart_flags & UPF_CONS_FLOW) {
48156 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48157 index 28cdd28..56f1d60 100644
48158 --- a/drivers/tty/serial/serial_core.c
48159 +++ b/drivers/tty/serial/serial_core.c
48160 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48161 uart_flush_buffer(tty);
48162 uart_shutdown(tty, state);
48163 spin_lock_irqsave(&port->lock, flags);
48164 - port->count = 0;
48165 + atomic_set(&port->count, 0);
48166 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48167 spin_unlock_irqrestore(&port->lock, flags);
48168 tty_port_tty_set(port, NULL);
48169 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48170 goto end;
48171 }
48172
48173 - port->count++;
48174 + atomic_inc(&port->count);
48175 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48176 retval = -ENXIO;
48177 goto err_dec_count;
48178 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48179 /*
48180 * Make sure the device is in D0 state.
48181 */
48182 - if (port->count == 1)
48183 + if (atomic_read(&port->count) == 1)
48184 uart_change_pm(state, UART_PM_STATE_ON);
48185
48186 /*
48187 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48188 end:
48189 return retval;
48190 err_dec_count:
48191 - port->count--;
48192 + atomic_inc(&port->count);
48193 mutex_unlock(&port->mutex);
48194 goto end;
48195 }
48196 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48197 index 8eaf1ab..85c030d 100644
48198 --- a/drivers/tty/synclink.c
48199 +++ b/drivers/tty/synclink.c
48200 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48201
48202 if (debug_level >= DEBUG_LEVEL_INFO)
48203 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48204 - __FILE__,__LINE__, info->device_name, info->port.count);
48205 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48206
48207 if (tty_port_close_start(&info->port, tty, filp) == 0)
48208 goto cleanup;
48209 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48210 cleanup:
48211 if (debug_level >= DEBUG_LEVEL_INFO)
48212 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48213 - tty->driver->name, info->port.count);
48214 + tty->driver->name, atomic_read(&info->port.count));
48215
48216 } /* end of mgsl_close() */
48217
48218 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48219
48220 mgsl_flush_buffer(tty);
48221 shutdown(info);
48222 -
48223 - info->port.count = 0;
48224 +
48225 + atomic_set(&info->port.count, 0);
48226 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48227 info->port.tty = NULL;
48228
48229 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48230
48231 if (debug_level >= DEBUG_LEVEL_INFO)
48232 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48233 - __FILE__,__LINE__, tty->driver->name, port->count );
48234 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48235
48236 spin_lock_irqsave(&info->irq_spinlock, flags);
48237 if (!tty_hung_up_p(filp)) {
48238 extra_count = true;
48239 - port->count--;
48240 + atomic_dec(&port->count);
48241 }
48242 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48243 port->blocked_open++;
48244 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48245
48246 if (debug_level >= DEBUG_LEVEL_INFO)
48247 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48248 - __FILE__,__LINE__, tty->driver->name, port->count );
48249 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48250
48251 tty_unlock(tty);
48252 schedule();
48253 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48254
48255 /* FIXME: Racy on hangup during close wait */
48256 if (extra_count)
48257 - port->count++;
48258 + atomic_inc(&port->count);
48259 port->blocked_open--;
48260
48261 if (debug_level >= DEBUG_LEVEL_INFO)
48262 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48263 - __FILE__,__LINE__, tty->driver->name, port->count );
48264 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48265
48266 if (!retval)
48267 port->flags |= ASYNC_NORMAL_ACTIVE;
48268 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48269
48270 if (debug_level >= DEBUG_LEVEL_INFO)
48271 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48272 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48273 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48274
48275 /* If port is closing, signal caller to try again */
48276 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48277 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48278 spin_unlock_irqrestore(&info->netlock, flags);
48279 goto cleanup;
48280 }
48281 - info->port.count++;
48282 + atomic_inc(&info->port.count);
48283 spin_unlock_irqrestore(&info->netlock, flags);
48284
48285 - if (info->port.count == 1) {
48286 + if (atomic_read(&info->port.count) == 1) {
48287 /* 1st open on this device, init hardware */
48288 retval = startup(info);
48289 if (retval < 0)
48290 @@ -3446,8 +3446,8 @@ cleanup:
48291 if (retval) {
48292 if (tty->count == 1)
48293 info->port.tty = NULL; /* tty layer will release tty struct */
48294 - if(info->port.count)
48295 - info->port.count--;
48296 + if (atomic_read(&info->port.count))
48297 + atomic_dec(&info->port.count);
48298 }
48299
48300 return retval;
48301 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48302 unsigned short new_crctype;
48303
48304 /* return error if TTY interface open */
48305 - if (info->port.count)
48306 + if (atomic_read(&info->port.count))
48307 return -EBUSY;
48308
48309 switch (encoding)
48310 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48311
48312 /* arbitrate between network and tty opens */
48313 spin_lock_irqsave(&info->netlock, flags);
48314 - if (info->port.count != 0 || info->netcount != 0) {
48315 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48316 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48317 spin_unlock_irqrestore(&info->netlock, flags);
48318 return -EBUSY;
48319 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48320 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48321
48322 /* return error if TTY interface open */
48323 - if (info->port.count)
48324 + if (atomic_read(&info->port.count))
48325 return -EBUSY;
48326
48327 if (cmd != SIOCWANDEV)
48328 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48329 index 1abf946..1ee34fc 100644
48330 --- a/drivers/tty/synclink_gt.c
48331 +++ b/drivers/tty/synclink_gt.c
48332 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48333 tty->driver_data = info;
48334 info->port.tty = tty;
48335
48336 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48337 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48338
48339 /* If port is closing, signal caller to try again */
48340 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48341 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48342 mutex_unlock(&info->port.mutex);
48343 goto cleanup;
48344 }
48345 - info->port.count++;
48346 + atomic_inc(&info->port.count);
48347 spin_unlock_irqrestore(&info->netlock, flags);
48348
48349 - if (info->port.count == 1) {
48350 + if (atomic_read(&info->port.count) == 1) {
48351 /* 1st open on this device, init hardware */
48352 retval = startup(info);
48353 if (retval < 0) {
48354 @@ -715,8 +715,8 @@ cleanup:
48355 if (retval) {
48356 if (tty->count == 1)
48357 info->port.tty = NULL; /* tty layer will release tty struct */
48358 - if(info->port.count)
48359 - info->port.count--;
48360 + if(atomic_read(&info->port.count))
48361 + atomic_dec(&info->port.count);
48362 }
48363
48364 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48365 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48366
48367 if (sanity_check(info, tty->name, "close"))
48368 return;
48369 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48370 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48371
48372 if (tty_port_close_start(&info->port, tty, filp) == 0)
48373 goto cleanup;
48374 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48375 tty_port_close_end(&info->port, tty);
48376 info->port.tty = NULL;
48377 cleanup:
48378 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48379 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48380 }
48381
48382 static void hangup(struct tty_struct *tty)
48383 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48384 shutdown(info);
48385
48386 spin_lock_irqsave(&info->port.lock, flags);
48387 - info->port.count = 0;
48388 + atomic_set(&info->port.count, 0);
48389 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48390 info->port.tty = NULL;
48391 spin_unlock_irqrestore(&info->port.lock, flags);
48392 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48393 unsigned short new_crctype;
48394
48395 /* return error if TTY interface open */
48396 - if (info->port.count)
48397 + if (atomic_read(&info->port.count))
48398 return -EBUSY;
48399
48400 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48401 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48402
48403 /* arbitrate between network and tty opens */
48404 spin_lock_irqsave(&info->netlock, flags);
48405 - if (info->port.count != 0 || info->netcount != 0) {
48406 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48407 DBGINFO(("%s hdlc_open busy\n", dev->name));
48408 spin_unlock_irqrestore(&info->netlock, flags);
48409 return -EBUSY;
48410 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48411 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48412
48413 /* return error if TTY interface open */
48414 - if (info->port.count)
48415 + if (atomic_read(&info->port.count))
48416 return -EBUSY;
48417
48418 if (cmd != SIOCWANDEV)
48419 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48420 if (port == NULL)
48421 continue;
48422 spin_lock(&port->lock);
48423 - if ((port->port.count || port->netcount) &&
48424 + if ((atomic_read(&port->port.count) || port->netcount) &&
48425 port->pending_bh && !port->bh_running &&
48426 !port->bh_requested) {
48427 DBGISR(("%s bh queued\n", port->device_name));
48428 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48429 spin_lock_irqsave(&info->lock, flags);
48430 if (!tty_hung_up_p(filp)) {
48431 extra_count = true;
48432 - port->count--;
48433 + atomic_dec(&port->count);
48434 }
48435 spin_unlock_irqrestore(&info->lock, flags);
48436 port->blocked_open++;
48437 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48438 remove_wait_queue(&port->open_wait, &wait);
48439
48440 if (extra_count)
48441 - port->count++;
48442 + atomic_inc(&port->count);
48443 port->blocked_open--;
48444
48445 if (!retval)
48446 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48447 index dc6e969..5dc8786 100644
48448 --- a/drivers/tty/synclinkmp.c
48449 +++ b/drivers/tty/synclinkmp.c
48450 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48451
48452 if (debug_level >= DEBUG_LEVEL_INFO)
48453 printk("%s(%d):%s open(), old ref count = %d\n",
48454 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48455 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48456
48457 /* If port is closing, signal caller to try again */
48458 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48459 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48460 spin_unlock_irqrestore(&info->netlock, flags);
48461 goto cleanup;
48462 }
48463 - info->port.count++;
48464 + atomic_inc(&info->port.count);
48465 spin_unlock_irqrestore(&info->netlock, flags);
48466
48467 - if (info->port.count == 1) {
48468 + if (atomic_read(&info->port.count) == 1) {
48469 /* 1st open on this device, init hardware */
48470 retval = startup(info);
48471 if (retval < 0)
48472 @@ -796,8 +796,8 @@ cleanup:
48473 if (retval) {
48474 if (tty->count == 1)
48475 info->port.tty = NULL; /* tty layer will release tty struct */
48476 - if(info->port.count)
48477 - info->port.count--;
48478 + if(atomic_read(&info->port.count))
48479 + atomic_dec(&info->port.count);
48480 }
48481
48482 return retval;
48483 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48484
48485 if (debug_level >= DEBUG_LEVEL_INFO)
48486 printk("%s(%d):%s close() entry, count=%d\n",
48487 - __FILE__,__LINE__, info->device_name, info->port.count);
48488 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48489
48490 if (tty_port_close_start(&info->port, tty, filp) == 0)
48491 goto cleanup;
48492 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48493 cleanup:
48494 if (debug_level >= DEBUG_LEVEL_INFO)
48495 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48496 - tty->driver->name, info->port.count);
48497 + tty->driver->name, atomic_read(&info->port.count));
48498 }
48499
48500 /* Called by tty_hangup() when a hangup is signaled.
48501 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48502 shutdown(info);
48503
48504 spin_lock_irqsave(&info->port.lock, flags);
48505 - info->port.count = 0;
48506 + atomic_set(&info->port.count, 0);
48507 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48508 info->port.tty = NULL;
48509 spin_unlock_irqrestore(&info->port.lock, flags);
48510 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48511 unsigned short new_crctype;
48512
48513 /* return error if TTY interface open */
48514 - if (info->port.count)
48515 + if (atomic_read(&info->port.count))
48516 return -EBUSY;
48517
48518 switch (encoding)
48519 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48520
48521 /* arbitrate between network and tty opens */
48522 spin_lock_irqsave(&info->netlock, flags);
48523 - if (info->port.count != 0 || info->netcount != 0) {
48524 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48525 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48526 spin_unlock_irqrestore(&info->netlock, flags);
48527 return -EBUSY;
48528 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48529 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48530
48531 /* return error if TTY interface open */
48532 - if (info->port.count)
48533 + if (atomic_read(&info->port.count))
48534 return -EBUSY;
48535
48536 if (cmd != SIOCWANDEV)
48537 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48538 * do not request bottom half processing if the
48539 * device is not open in a normal mode.
48540 */
48541 - if ( port && (port->port.count || port->netcount) &&
48542 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48543 port->pending_bh && !port->bh_running &&
48544 !port->bh_requested ) {
48545 if ( debug_level >= DEBUG_LEVEL_ISR )
48546 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48547
48548 if (debug_level >= DEBUG_LEVEL_INFO)
48549 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48550 - __FILE__,__LINE__, tty->driver->name, port->count );
48551 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48552
48553 spin_lock_irqsave(&info->lock, flags);
48554 if (!tty_hung_up_p(filp)) {
48555 extra_count = true;
48556 - port->count--;
48557 + atomic_dec(&port->count);
48558 }
48559 spin_unlock_irqrestore(&info->lock, flags);
48560 port->blocked_open++;
48561 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48562
48563 if (debug_level >= DEBUG_LEVEL_INFO)
48564 printk("%s(%d):%s block_til_ready() count=%d\n",
48565 - __FILE__,__LINE__, tty->driver->name, port->count );
48566 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48567
48568 tty_unlock(tty);
48569 schedule();
48570 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48571 remove_wait_queue(&port->open_wait, &wait);
48572
48573 if (extra_count)
48574 - port->count++;
48575 + atomic_inc(&port->count);
48576 port->blocked_open--;
48577
48578 if (debug_level >= DEBUG_LEVEL_INFO)
48579 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48580 - __FILE__,__LINE__, tty->driver->name, port->count );
48581 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48582
48583 if (!retval)
48584 port->flags |= ASYNC_NORMAL_ACTIVE;
48585 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48586 index d5cc3ac..3263411 100644
48587 --- a/drivers/tty/sysrq.c
48588 +++ b/drivers/tty/sysrq.c
48589 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48590 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48591 size_t count, loff_t *ppos)
48592 {
48593 - if (count) {
48594 + if (count && capable(CAP_SYS_ADMIN)) {
48595 char c;
48596
48597 if (get_user(c, buf))
48598 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48599 index 20689b9..7fd3a31 100644
48600 --- a/drivers/tty/tty_io.c
48601 +++ b/drivers/tty/tty_io.c
48602 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48603
48604 void tty_default_fops(struct file_operations *fops)
48605 {
48606 - *fops = tty_fops;
48607 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48608 }
48609
48610 /*
48611 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48612 index 1afe192..73d2c20 100644
48613 --- a/drivers/tty/tty_ldisc.c
48614 +++ b/drivers/tty/tty_ldisc.c
48615 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48616 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48617 tty_ldiscs[disc] = new_ldisc;
48618 new_ldisc->num = disc;
48619 - new_ldisc->refcount = 0;
48620 + atomic_set(&new_ldisc->refcount, 0);
48621 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48622
48623 return ret;
48624 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48625 return -EINVAL;
48626
48627 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48628 - if (tty_ldiscs[disc]->refcount)
48629 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48630 ret = -EBUSY;
48631 else
48632 tty_ldiscs[disc] = NULL;
48633 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48634 if (ldops) {
48635 ret = ERR_PTR(-EAGAIN);
48636 if (try_module_get(ldops->owner)) {
48637 - ldops->refcount++;
48638 + atomic_inc(&ldops->refcount);
48639 ret = ldops;
48640 }
48641 }
48642 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48643 unsigned long flags;
48644
48645 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48646 - ldops->refcount--;
48647 + atomic_dec(&ldops->refcount);
48648 module_put(ldops->owner);
48649 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48650 }
48651 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48652 /* unreleased reader reference(s) will cause this WARN */
48653 WARN_ON(!atomic_dec_and_test(&ld->users));
48654
48655 - ld->ops->refcount--;
48656 + atomic_dec(&ld->ops->refcount);
48657 module_put(ld->ops->owner);
48658 kfree(ld);
48659 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48660 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48661 index f597e88..b7f68ed 100644
48662 --- a/drivers/tty/tty_port.c
48663 +++ b/drivers/tty/tty_port.c
48664 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48665 unsigned long flags;
48666
48667 spin_lock_irqsave(&port->lock, flags);
48668 - port->count = 0;
48669 + atomic_set(&port->count, 0);
48670 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48671 tty = port->tty;
48672 if (tty)
48673 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48674 /* The port lock protects the port counts */
48675 spin_lock_irqsave(&port->lock, flags);
48676 if (!tty_hung_up_p(filp))
48677 - port->count--;
48678 + atomic_dec(&port->count);
48679 port->blocked_open++;
48680 spin_unlock_irqrestore(&port->lock, flags);
48681
48682 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48683 we must not mess that up further */
48684 spin_lock_irqsave(&port->lock, flags);
48685 if (!tty_hung_up_p(filp))
48686 - port->count++;
48687 + atomic_inc(&port->count);
48688 port->blocked_open--;
48689 if (retval == 0)
48690 port->flags |= ASYNC_NORMAL_ACTIVE;
48691 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48692 return 0;
48693 }
48694
48695 - if (tty->count == 1 && port->count != 1) {
48696 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48697 printk(KERN_WARNING
48698 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48699 - port->count);
48700 - port->count = 1;
48701 + atomic_read(&port->count));
48702 + atomic_set(&port->count, 1);
48703 }
48704 - if (--port->count < 0) {
48705 + if (atomic_dec_return(&port->count) < 0) {
48706 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48707 - port->count);
48708 - port->count = 0;
48709 + atomic_read(&port->count));
48710 + atomic_set(&port->count, 0);
48711 }
48712
48713 - if (port->count) {
48714 + if (atomic_read(&port->count)) {
48715 spin_unlock_irqrestore(&port->lock, flags);
48716 if (port->ops->drop)
48717 port->ops->drop(port);
48718 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48719 {
48720 spin_lock_irq(&port->lock);
48721 if (!tty_hung_up_p(filp))
48722 - ++port->count;
48723 + atomic_inc(&port->count);
48724 spin_unlock_irq(&port->lock);
48725 tty_port_tty_set(port, tty);
48726
48727 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48728 index a9af1b9a..1e08e7f 100644
48729 --- a/drivers/tty/vt/keyboard.c
48730 +++ b/drivers/tty/vt/keyboard.c
48731 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48732 kbd->kbdmode == VC_OFF) &&
48733 value != KVAL(K_SAK))
48734 return; /* SAK is allowed even in raw mode */
48735 +
48736 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48737 + {
48738 + void *func = fn_handler[value];
48739 + if (func == fn_show_state || func == fn_show_ptregs ||
48740 + func == fn_show_mem)
48741 + return;
48742 + }
48743 +#endif
48744 +
48745 fn_handler[value](vc);
48746 }
48747
48748 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48749 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48750 return -EFAULT;
48751
48752 - if (!capable(CAP_SYS_TTY_CONFIG))
48753 - perm = 0;
48754 -
48755 switch (cmd) {
48756 case KDGKBENT:
48757 /* Ensure another thread doesn't free it under us */
48758 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48759 spin_unlock_irqrestore(&kbd_event_lock, flags);
48760 return put_user(val, &user_kbe->kb_value);
48761 case KDSKBENT:
48762 + if (!capable(CAP_SYS_TTY_CONFIG))
48763 + perm = 0;
48764 +
48765 if (!perm)
48766 return -EPERM;
48767 if (!i && v == K_NOSUCHMAP) {
48768 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48769 int i, j, k;
48770 int ret;
48771
48772 - if (!capable(CAP_SYS_TTY_CONFIG))
48773 - perm = 0;
48774 -
48775 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48776 if (!kbs) {
48777 ret = -ENOMEM;
48778 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48779 kfree(kbs);
48780 return ((p && *p) ? -EOVERFLOW : 0);
48781 case KDSKBSENT:
48782 + if (!capable(CAP_SYS_TTY_CONFIG))
48783 + perm = 0;
48784 +
48785 if (!perm) {
48786 ret = -EPERM;
48787 goto reterr;
48788 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48789 index 4bf4bb2..52ae8c7 100644
48790 --- a/drivers/uio/uio.c
48791 +++ b/drivers/uio/uio.c
48792 @@ -25,6 +25,7 @@
48793 #include <linux/kobject.h>
48794 #include <linux/cdev.h>
48795 #include <linux/uio_driver.h>
48796 +#include <asm/local.h>
48797
48798 #define UIO_MAX_DEVICES (1U << MINORBITS)
48799
48800 @@ -32,10 +33,10 @@ struct uio_device {
48801 struct module *owner;
48802 struct device *dev;
48803 int minor;
48804 - atomic_t event;
48805 + atomic_unchecked_t event;
48806 struct fasync_struct *async_queue;
48807 wait_queue_head_t wait;
48808 - int vma_count;
48809 + local_t vma_count;
48810 struct uio_info *info;
48811 struct kobject *map_dir;
48812 struct kobject *portio_dir;
48813 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48814 struct device_attribute *attr, char *buf)
48815 {
48816 struct uio_device *idev = dev_get_drvdata(dev);
48817 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48818 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48819 }
48820
48821 static struct device_attribute uio_class_attributes[] = {
48822 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48823 {
48824 struct uio_device *idev = info->uio_dev;
48825
48826 - atomic_inc(&idev->event);
48827 + atomic_inc_unchecked(&idev->event);
48828 wake_up_interruptible(&idev->wait);
48829 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48830 }
48831 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48832 }
48833
48834 listener->dev = idev;
48835 - listener->event_count = atomic_read(&idev->event);
48836 + listener->event_count = atomic_read_unchecked(&idev->event);
48837 filep->private_data = listener;
48838
48839 if (idev->info->open) {
48840 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48841 return -EIO;
48842
48843 poll_wait(filep, &idev->wait, wait);
48844 - if (listener->event_count != atomic_read(&idev->event))
48845 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48846 return POLLIN | POLLRDNORM;
48847 return 0;
48848 }
48849 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48850 do {
48851 set_current_state(TASK_INTERRUPTIBLE);
48852
48853 - event_count = atomic_read(&idev->event);
48854 + event_count = atomic_read_unchecked(&idev->event);
48855 if (event_count != listener->event_count) {
48856 if (copy_to_user(buf, &event_count, count))
48857 retval = -EFAULT;
48858 @@ -584,9 +585,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48859 static int uio_find_mem_index(struct vm_area_struct *vma)
48860 {
48861 struct uio_device *idev = vma->vm_private_data;
48862 + unsigned long size;
48863
48864 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48865 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48866 + size = idev->info->mem[vma->vm_pgoff].size;
48867 + if (size == 0)
48868 + return -1;
48869 + if (vma->vm_end - vma->vm_start > size)
48870 return -1;
48871 return (int)vma->vm_pgoff;
48872 }
48873 @@ -596,13 +601,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48874 static void uio_vma_open(struct vm_area_struct *vma)
48875 {
48876 struct uio_device *idev = vma->vm_private_data;
48877 - idev->vma_count++;
48878 + local_inc(&idev->vma_count);
48879 }
48880
48881 static void uio_vma_close(struct vm_area_struct *vma)
48882 {
48883 struct uio_device *idev = vma->vm_private_data;
48884 - idev->vma_count--;
48885 + local_dec(&idev->vma_count);
48886 }
48887
48888 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48889 @@ -830,7 +835,7 @@ int __uio_register_device(struct module *owner,
48890 idev->owner = owner;
48891 idev->info = info;
48892 init_waitqueue_head(&idev->wait);
48893 - atomic_set(&idev->event, 0);
48894 + atomic_set_unchecked(&idev->event, 0);
48895
48896 ret = uio_get_minor(idev);
48897 if (ret)
48898 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48899 index 8a7eb77..c00402f 100644
48900 --- a/drivers/usb/atm/cxacru.c
48901 +++ b/drivers/usb/atm/cxacru.c
48902 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48903 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48904 if (ret < 2)
48905 return -EINVAL;
48906 - if (index < 0 || index > 0x7f)
48907 + if (index > 0x7f)
48908 return -EINVAL;
48909 pos += tmp;
48910
48911 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48912 index 5e0d33a..cc10579 100644
48913 --- a/drivers/usb/atm/usbatm.c
48914 +++ b/drivers/usb/atm/usbatm.c
48915 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48916 if (printk_ratelimit())
48917 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48918 __func__, vpi, vci);
48919 - atomic_inc(&vcc->stats->rx_err);
48920 + atomic_inc_unchecked(&vcc->stats->rx_err);
48921 return;
48922 }
48923
48924 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48925 if (length > ATM_MAX_AAL5_PDU) {
48926 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48927 __func__, length, vcc);
48928 - atomic_inc(&vcc->stats->rx_err);
48929 + atomic_inc_unchecked(&vcc->stats->rx_err);
48930 goto out;
48931 }
48932
48933 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48934 if (sarb->len < pdu_length) {
48935 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48936 __func__, pdu_length, sarb->len, vcc);
48937 - atomic_inc(&vcc->stats->rx_err);
48938 + atomic_inc_unchecked(&vcc->stats->rx_err);
48939 goto out;
48940 }
48941
48942 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48943 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48944 __func__, vcc);
48945 - atomic_inc(&vcc->stats->rx_err);
48946 + atomic_inc_unchecked(&vcc->stats->rx_err);
48947 goto out;
48948 }
48949
48950 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48951 if (printk_ratelimit())
48952 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48953 __func__, length);
48954 - atomic_inc(&vcc->stats->rx_drop);
48955 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48956 goto out;
48957 }
48958
48959 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48960
48961 vcc->push(vcc, skb);
48962
48963 - atomic_inc(&vcc->stats->rx);
48964 + atomic_inc_unchecked(&vcc->stats->rx);
48965 out:
48966 skb_trim(sarb, 0);
48967 }
48968 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
48969 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48970
48971 usbatm_pop(vcc, skb);
48972 - atomic_inc(&vcc->stats->tx);
48973 + atomic_inc_unchecked(&vcc->stats->tx);
48974
48975 skb = skb_dequeue(&instance->sndqueue);
48976 }
48977 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48978 if (!left--)
48979 return sprintf(page,
48980 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48981 - atomic_read(&atm_dev->stats.aal5.tx),
48982 - atomic_read(&atm_dev->stats.aal5.tx_err),
48983 - atomic_read(&atm_dev->stats.aal5.rx),
48984 - atomic_read(&atm_dev->stats.aal5.rx_err),
48985 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48986 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48987 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48988 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48989 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48990 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48991
48992 if (!left--) {
48993 if (instance->disconnected)
48994 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48995 index 2a3bbdf..91d72cf 100644
48996 --- a/drivers/usb/core/devices.c
48997 +++ b/drivers/usb/core/devices.c
48998 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48999 * time it gets called.
49000 */
49001 static struct device_connect_event {
49002 - atomic_t count;
49003 + atomic_unchecked_t count;
49004 wait_queue_head_t wait;
49005 } device_event = {
49006 .count = ATOMIC_INIT(1),
49007 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49008
49009 void usbfs_conn_disc_event(void)
49010 {
49011 - atomic_add(2, &device_event.count);
49012 + atomic_add_unchecked(2, &device_event.count);
49013 wake_up(&device_event.wait);
49014 }
49015
49016 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49017
49018 poll_wait(file, &device_event.wait, wait);
49019
49020 - event_count = atomic_read(&device_event.count);
49021 + event_count = atomic_read_unchecked(&device_event.count);
49022 if (file->f_version != event_count) {
49023 file->f_version = event_count;
49024 return POLLIN | POLLRDNORM;
49025 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49026 index 7b8bc0b..31bd7ad 100644
49027 --- a/drivers/usb/core/hcd.c
49028 +++ b/drivers/usb/core/hcd.c
49029 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49030 */
49031 usb_get_urb(urb);
49032 atomic_inc(&urb->use_count);
49033 - atomic_inc(&urb->dev->urbnum);
49034 + atomic_inc_unchecked(&urb->dev->urbnum);
49035 usbmon_urb_submit(&hcd->self, urb);
49036
49037 /* NOTE requirements on root-hub callers (usbfs and the hub
49038 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49039 urb->hcpriv = NULL;
49040 INIT_LIST_HEAD(&urb->urb_list);
49041 atomic_dec(&urb->use_count);
49042 - atomic_dec(&urb->dev->urbnum);
49043 + atomic_dec_unchecked(&urb->dev->urbnum);
49044 if (atomic_read(&urb->reject))
49045 wake_up(&usb_kill_urb_queue);
49046 usb_put_urb(urb);
49047 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49048 index 1c11089..db98d78 100644
49049 --- a/drivers/usb/core/hub.c
49050 +++ b/drivers/usb/core/hub.c
49051 @@ -27,6 +27,7 @@
49052 #include <linux/freezer.h>
49053 #include <linux/random.h>
49054 #include <linux/pm_qos.h>
49055 +#include <linux/grsecurity.h>
49056
49057 #include <asm/uaccess.h>
49058 #include <asm/byteorder.h>
49059 @@ -4433,6 +4434,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49060 goto done;
49061 return;
49062 }
49063 +
49064 + if (gr_handle_new_usb())
49065 + goto done;
49066 +
49067 if (hub_is_superspeed(hub->hdev))
49068 unit_load = 150;
49069 else
49070 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49071 index e7ee1e4..1dfc9ea4 100644
49072 --- a/drivers/usb/core/message.c
49073 +++ b/drivers/usb/core/message.c
49074 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49075 * method can wait for it to complete. Since you don't have a handle on the
49076 * URB used, you can't cancel the request.
49077 */
49078 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49079 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49080 __u8 requesttype, __u16 value, __u16 index, void *data,
49081 __u16 size, int timeout)
49082 {
49083 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49084 index d9284b9..17023c7 100644
49085 --- a/drivers/usb/core/sysfs.c
49086 +++ b/drivers/usb/core/sysfs.c
49087 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49088 struct usb_device *udev;
49089
49090 udev = to_usb_device(dev);
49091 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49092 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49093 }
49094 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49095
49096 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49097 index 7dad603..350f7a9 100644
49098 --- a/drivers/usb/core/usb.c
49099 +++ b/drivers/usb/core/usb.c
49100 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49101 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49102 dev->state = USB_STATE_ATTACHED;
49103 dev->lpm_disable_count = 1;
49104 - atomic_set(&dev->urbnum, 0);
49105 + atomic_set_unchecked(&dev->urbnum, 0);
49106
49107 INIT_LIST_HEAD(&dev->ep0.urb_list);
49108 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49109 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49110 index 14d28d6..5f511ac 100644
49111 --- a/drivers/usb/dwc3/gadget.c
49112 +++ b/drivers/usb/dwc3/gadget.c
49113 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49114 if (!usb_endpoint_xfer_isoc(desc))
49115 return 0;
49116
49117 - memset(&trb_link, 0, sizeof(trb_link));
49118 -
49119 /* Link TRB for ISOC. The HWO bit is never reset */
49120 trb_st_hw = &dep->trb_pool[0];
49121
49122 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49123 index 5e29dde..eca992f 100644
49124 --- a/drivers/usb/early/ehci-dbgp.c
49125 +++ b/drivers/usb/early/ehci-dbgp.c
49126 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49127
49128 #ifdef CONFIG_KGDB
49129 static struct kgdb_io kgdbdbgp_io_ops;
49130 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49131 +static struct kgdb_io kgdbdbgp_io_ops_console;
49132 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49133 #else
49134 #define dbgp_kgdb_mode (0)
49135 #endif
49136 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49137 .write_char = kgdbdbgp_write_char,
49138 };
49139
49140 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49141 + .name = "kgdbdbgp",
49142 + .read_char = kgdbdbgp_read_char,
49143 + .write_char = kgdbdbgp_write_char,
49144 + .is_console = 1
49145 +};
49146 +
49147 static int kgdbdbgp_wait_time;
49148
49149 static int __init kgdbdbgp_parse_config(char *str)
49150 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49151 ptr++;
49152 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49153 }
49154 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49155 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49156 + if (early_dbgp_console.index != -1)
49157 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49158 + else
49159 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49160
49161 return 0;
49162 }
49163 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49164 index b369292..9f3ba40 100644
49165 --- a/drivers/usb/gadget/u_serial.c
49166 +++ b/drivers/usb/gadget/u_serial.c
49167 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49168 spin_lock_irq(&port->port_lock);
49169
49170 /* already open? Great. */
49171 - if (port->port.count) {
49172 + if (atomic_read(&port->port.count)) {
49173 status = 0;
49174 - port->port.count++;
49175 + atomic_inc(&port->port.count);
49176
49177 /* currently opening/closing? wait ... */
49178 } else if (port->openclose) {
49179 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49180 tty->driver_data = port;
49181 port->port.tty = tty;
49182
49183 - port->port.count = 1;
49184 + atomic_set(&port->port.count, 1);
49185 port->openclose = false;
49186
49187 /* if connected, start the I/O stream */
49188 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49189
49190 spin_lock_irq(&port->port_lock);
49191
49192 - if (port->port.count != 1) {
49193 - if (port->port.count == 0)
49194 + if (atomic_read(&port->port.count) != 1) {
49195 + if (atomic_read(&port->port.count) == 0)
49196 WARN_ON(1);
49197 else
49198 - --port->port.count;
49199 + atomic_dec(&port->port.count);
49200 goto exit;
49201 }
49202
49203 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49204 * and sleep if necessary
49205 */
49206 port->openclose = true;
49207 - port->port.count = 0;
49208 + atomic_set(&port->port.count, 0);
49209
49210 gser = port->port_usb;
49211 if (gser && gser->disconnect)
49212 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49213 int cond;
49214
49215 spin_lock_irq(&port->port_lock);
49216 - cond = (port->port.count == 0) && !port->openclose;
49217 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49218 spin_unlock_irq(&port->port_lock);
49219 return cond;
49220 }
49221 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49222 /* if it's already open, start I/O ... and notify the serial
49223 * protocol about open/close status (connect/disconnect).
49224 */
49225 - if (port->port.count) {
49226 + if (atomic_read(&port->port.count)) {
49227 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49228 gs_start_io(port);
49229 if (gser->connect)
49230 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49231
49232 port->port_usb = NULL;
49233 gser->ioport = NULL;
49234 - if (port->port.count > 0 || port->openclose) {
49235 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49236 wake_up_interruptible(&port->drain_wait);
49237 if (port->port.tty)
49238 tty_hangup(port->port.tty);
49239 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49240
49241 /* finally, free any unused/unusable I/O buffers */
49242 spin_lock_irqsave(&port->port_lock, flags);
49243 - if (port->port.count == 0 && !port->openclose)
49244 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49245 gs_buf_free(&port->port_write_buf);
49246 gs_free_requests(gser->out, &port->read_pool, NULL);
49247 gs_free_requests(gser->out, &port->read_queue, NULL);
49248 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49249 index ba6a5d6..f88f7f3 100644
49250 --- a/drivers/usb/misc/appledisplay.c
49251 +++ b/drivers/usb/misc/appledisplay.c
49252 @@ -83,7 +83,7 @@ struct appledisplay {
49253 spinlock_t lock;
49254 };
49255
49256 -static atomic_t count_displays = ATOMIC_INIT(0);
49257 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49258 static struct workqueue_struct *wq;
49259
49260 static void appledisplay_complete(struct urb *urb)
49261 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49262
49263 /* Register backlight device */
49264 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49265 - atomic_inc_return(&count_displays) - 1);
49266 + atomic_inc_return_unchecked(&count_displays) - 1);
49267 memset(&props, 0, sizeof(struct backlight_properties));
49268 props.type = BACKLIGHT_RAW;
49269 props.max_brightness = 0xff;
49270 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49271 index afb50ea..6b837ab 100644
49272 --- a/drivers/usb/serial/console.c
49273 +++ b/drivers/usb/serial/console.c
49274 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49275
49276 info->port = port;
49277
49278 - ++port->port.count;
49279 + atomic_inc(&port->port.count);
49280 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49281 if (serial->type->set_termios) {
49282 /*
49283 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49284 }
49285 /* Now that any required fake tty operations are completed restore
49286 * the tty port count */
49287 - --port->port.count;
49288 + atomic_dec(&port->port.count);
49289 /* The console is special in terms of closing the device so
49290 * indicate this port is now acting as a system console. */
49291 port->port.console = 1;
49292 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49293 free_tty:
49294 kfree(tty);
49295 reset_open_count:
49296 - port->port.count = 0;
49297 + atomic_set(&port->port.count, 0);
49298 usb_autopm_put_interface(serial->interface);
49299 error_get_interface:
49300 usb_serial_put(serial);
49301 @@ -198,7 +198,7 @@ static int usb_console_setup(struct console *co, char *options)
49302 static void usb_console_write(struct console *co,
49303 const char *buf, unsigned count)
49304 {
49305 - static struct usbcons_info *info = &usbcons_info;
49306 + struct usbcons_info *info = &usbcons_info;
49307 struct usb_serial_port *port = info->port;
49308 struct usb_serial *serial;
49309 int retval = -ENODEV;
49310 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49311 index 75f70f0..d467e1a 100644
49312 --- a/drivers/usb/storage/usb.h
49313 +++ b/drivers/usb/storage/usb.h
49314 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49315 __u8 useProtocol;
49316 __u8 useTransport;
49317 int (*initFunction)(struct us_data *);
49318 -};
49319 +} __do_const;
49320
49321
49322 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49323 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49324 index d6bea3e..60b250e 100644
49325 --- a/drivers/usb/wusbcore/wa-hc.h
49326 +++ b/drivers/usb/wusbcore/wa-hc.h
49327 @@ -192,7 +192,7 @@ struct wahc {
49328 struct list_head xfer_delayed_list;
49329 spinlock_t xfer_list_lock;
49330 struct work_struct xfer_work;
49331 - atomic_t xfer_id_count;
49332 + atomic_unchecked_t xfer_id_count;
49333 };
49334
49335
49336 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49337 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49338 spin_lock_init(&wa->xfer_list_lock);
49339 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49340 - atomic_set(&wa->xfer_id_count, 1);
49341 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49342 }
49343
49344 /**
49345 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49346 index d3493ca..0c33b7e 100644
49347 --- a/drivers/usb/wusbcore/wa-xfer.c
49348 +++ b/drivers/usb/wusbcore/wa-xfer.c
49349 @@ -297,7 +297,7 @@ out:
49350 */
49351 static void wa_xfer_id_init(struct wa_xfer *xfer)
49352 {
49353 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49354 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49355 }
49356
49357 /*
49358 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49359 index 842f450..d1d7409 100644
49360 --- a/drivers/vfio/vfio.c
49361 +++ b/drivers/vfio/vfio.c
49362 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49363 return 0;
49364
49365 /* TODO Prevent device auto probing */
49366 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49367 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49368 iommu_group_id(group->iommu_group));
49369
49370 return 0;
49371 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49372 index 5174eba..86e764a 100644
49373 --- a/drivers/vhost/vringh.c
49374 +++ b/drivers/vhost/vringh.c
49375 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49376
49377 static inline int putu16_kern(u16 *p, u16 val)
49378 {
49379 - ACCESS_ONCE(*p) = val;
49380 + ACCESS_ONCE_RW(*p) = val;
49381 return 0;
49382 }
49383
49384 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49385 index e43401a..dd49b3f 100644
49386 --- a/drivers/video/arcfb.c
49387 +++ b/drivers/video/arcfb.c
49388 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49389 return -ENOSPC;
49390
49391 err = 0;
49392 - if ((count + p) > fbmemlength) {
49393 + if (count > (fbmemlength - p)) {
49394 count = fbmemlength - p;
49395 err = -ENOSPC;
49396 }
49397 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49398 index a4dfe8c..297ddd9 100644
49399 --- a/drivers/video/aty/aty128fb.c
49400 +++ b/drivers/video/aty/aty128fb.c
49401 @@ -149,7 +149,7 @@ enum {
49402 };
49403
49404 /* Must match above enum */
49405 -static char * const r128_family[] = {
49406 +static const char * const r128_family[] = {
49407 "AGP",
49408 "PCI",
49409 "PRO AGP",
49410 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49411 index 9b0f12c..024673d 100644
49412 --- a/drivers/video/aty/atyfb_base.c
49413 +++ b/drivers/video/aty/atyfb_base.c
49414 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49415 par->accel_flags = var->accel_flags; /* hack */
49416
49417 if (var->accel_flags) {
49418 - info->fbops->fb_sync = atyfb_sync;
49419 + pax_open_kernel();
49420 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49421 + pax_close_kernel();
49422 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49423 } else {
49424 - info->fbops->fb_sync = NULL;
49425 + pax_open_kernel();
49426 + *(void **)&info->fbops->fb_sync = NULL;
49427 + pax_close_kernel();
49428 info->flags |= FBINFO_HWACCEL_DISABLED;
49429 }
49430
49431 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49432 index 95ec042..e6affdd 100644
49433 --- a/drivers/video/aty/mach64_cursor.c
49434 +++ b/drivers/video/aty/mach64_cursor.c
49435 @@ -7,6 +7,7 @@
49436 #include <linux/string.h>
49437
49438 #include <asm/io.h>
49439 +#include <asm/pgtable.h>
49440
49441 #ifdef __sparc__
49442 #include <asm/fbio.h>
49443 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49444 info->sprite.buf_align = 16; /* and 64 lines tall. */
49445 info->sprite.flags = FB_PIXMAP_IO;
49446
49447 - info->fbops->fb_cursor = atyfb_cursor;
49448 + pax_open_kernel();
49449 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49450 + pax_close_kernel();
49451
49452 return 0;
49453 }
49454 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49455 index bca6ccc..252107e 100644
49456 --- a/drivers/video/backlight/kb3886_bl.c
49457 +++ b/drivers/video/backlight/kb3886_bl.c
49458 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49459 static unsigned long kb3886bl_flags;
49460 #define KB3886BL_SUSPENDED 0x01
49461
49462 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49463 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49464 {
49465 .ident = "Sahara Touch-iT",
49466 .matches = {
49467 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49468 index 900aa4e..6d49418 100644
49469 --- a/drivers/video/fb_defio.c
49470 +++ b/drivers/video/fb_defio.c
49471 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49472
49473 BUG_ON(!fbdefio);
49474 mutex_init(&fbdefio->lock);
49475 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49476 + pax_open_kernel();
49477 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49478 + pax_close_kernel();
49479 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49480 INIT_LIST_HEAD(&fbdefio->pagelist);
49481 if (fbdefio->delay == 0) /* set a default of 1 s */
49482 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49483 page->mapping = NULL;
49484 }
49485
49486 - info->fbops->fb_mmap = NULL;
49487 + *(void **)&info->fbops->fb_mmap = NULL;
49488 mutex_destroy(&fbdefio->lock);
49489 }
49490 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49491 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49492 index 5c3960d..15cf8fc 100644
49493 --- a/drivers/video/fbcmap.c
49494 +++ b/drivers/video/fbcmap.c
49495 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49496 rc = -ENODEV;
49497 goto out;
49498 }
49499 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49500 - !info->fbops->fb_setcmap)) {
49501 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49502 rc = -EINVAL;
49503 goto out1;
49504 }
49505 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49506 index 36e1fe2..c744820 100644
49507 --- a/drivers/video/fbmem.c
49508 +++ b/drivers/video/fbmem.c
49509 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49510 image->dx += image->width + 8;
49511 }
49512 } else if (rotate == FB_ROTATE_UD) {
49513 - for (x = 0; x < num && image->dx >= 0; x++) {
49514 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49515 info->fbops->fb_imageblit(info, image);
49516 image->dx -= image->width + 8;
49517 }
49518 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49519 image->dy += image->height + 8;
49520 }
49521 } else if (rotate == FB_ROTATE_CCW) {
49522 - for (x = 0; x < num && image->dy >= 0; x++) {
49523 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49524 info->fbops->fb_imageblit(info, image);
49525 image->dy -= image->height + 8;
49526 }
49527 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49528 return -EFAULT;
49529 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49530 return -EINVAL;
49531 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49532 + if (con2fb.framebuffer >= FB_MAX)
49533 return -EINVAL;
49534 if (!registered_fb[con2fb.framebuffer])
49535 request_module("fb%d", con2fb.framebuffer);
49536 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49537 index 0f3b33c..b4304eb 100644
49538 --- a/drivers/video/hyperv_fb.c
49539 +++ b/drivers/video/hyperv_fb.c
49540 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49541 static inline int synthvid_send(struct hv_device *hdev,
49542 struct synthvid_msg *msg)
49543 {
49544 - static atomic64_t request_id = ATOMIC64_INIT(0);
49545 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49546 int ret;
49547
49548 msg->pipe_hdr.type = PIPE_MSG_DATA;
49549 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49550
49551 ret = vmbus_sendpacket(hdev->channel, msg,
49552 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49553 - atomic64_inc_return(&request_id),
49554 + atomic64_inc_return_unchecked(&request_id),
49555 VM_PKT_DATA_INBAND, 0);
49556
49557 if (ret)
49558 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49559 index 7672d2e..b56437f 100644
49560 --- a/drivers/video/i810/i810_accel.c
49561 +++ b/drivers/video/i810/i810_accel.c
49562 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49563 }
49564 }
49565 printk("ringbuffer lockup!!!\n");
49566 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49567 i810_report_error(mmio);
49568 par->dev_flags |= LOCKUP;
49569 info->pixmap.scan_align = 1;
49570 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49571 index 285d552..eafa544 100644
49572 --- a/drivers/video/logo/logo_linux_clut224.ppm
49573 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49574 @@ -1,883 +1,1123 @@
49575 P3
49576 80 80
49577 255
49578 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49579 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49580 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49581 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49582 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49583 -10 10 10 6 6 6 6 6 6 6 6 6 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 0 0 0 0 0 0 0 0 0 0 0 0
49585 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49586 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49587 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49588 -
49589 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49590 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49591 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49592 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49593 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49594 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49595 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49596 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49597 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49598 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49599 -
49600 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49601 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49602 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49603 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49604 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49605 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49606 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49607 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49608 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49609 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49610 -
49611 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49612 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49613 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49614 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49615 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49616 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49617 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49618 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49619 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49620 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49621 -
49622 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49623 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49624 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49625 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49626 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49627 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49628 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49629 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49630 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49631 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49632 -
49633 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49634 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49635 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49636 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49637 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49638 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49639 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49640 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49641 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49642 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49643 -
49644 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49645 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49646 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49647 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49648 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49649 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49650 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49651 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49652 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49653 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49654 -
49655 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49656 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49657 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49658 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49659 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49660 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49661 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49662 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49663 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49664 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49665 -
49666 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49667 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49668 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49669 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49670 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49671 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49672 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49673 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49674 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49675 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49676 -
49677 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49678 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49679 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49680 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49681 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49682 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49683 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49684 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49685 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49686 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49687 -
49688 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49689 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49690 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49691 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49692 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49693 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49694 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49695 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49696 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49697 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49698 -
49699 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49700 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49701 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49702 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49703 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49704 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49705 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49706 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49707 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49708 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49709 -
49710 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49711 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49712 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49713 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49714 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49715 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49716 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49717 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49718 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49719 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49720 -
49721 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49722 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49723 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49724 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49725 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49726 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49727 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49728 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49729 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49730 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49731 -
49732 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49733 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49734 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49735 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49736 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49737 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49738 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49739 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49740 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49741 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49742 -
49743 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49744 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49745 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49746 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49747 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49748 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49749 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49750 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49751 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49752 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49753 -
49754 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49755 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49756 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49757 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49758 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49759 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49760 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49761 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49762 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49763 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49764 -
49765 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49766 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49767 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49768 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49769 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49770 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49771 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49772 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49773 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49774 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49775 -
49776 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49777 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49778 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49779 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49780 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49781 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49782 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49783 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49784 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49785 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49786 -
49787 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49788 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49789 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49790 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49791 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49792 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49793 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49794 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49795 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49796 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49797 -
49798 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49799 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49800 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49801 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49802 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49803 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49804 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49805 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49806 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49807 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49808 -
49809 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49810 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49811 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49812 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49813 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49814 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49815 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
49816 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49817 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49818 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49819 -
49820 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49821 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49822 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49823 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49824 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49825 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49826 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
49827 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49828 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49829 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49830 -
49831 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49832 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49833 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49834 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49835 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49836 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49837 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
49838 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49839 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49840 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49841 -
49842 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49843 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49844 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49845 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49846 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49847 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49848 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49849 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49850 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49851 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49852 -
49853 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49854 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49855 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49856 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49857 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49858 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49859 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49860 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49861 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49862 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49863 -
49864 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49865 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49866 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49867 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49868 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49869 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49870 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49871 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49872 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49873 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49874 -
49875 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49876 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49877 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49878 -0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49879 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49880 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49881 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49882 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49883 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49884 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49885 -
49886 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49887 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49888 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49889 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49890 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49891 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49892 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49893 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49894 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49895 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49896 -
49897 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49898 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
49899 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49900 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49901 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49902 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49903 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49904 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49905 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49906 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49907 -
49908 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
49909 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49910 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49911 -0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49912 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49913 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49914 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49915 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49916 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49917 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49918 -
49919 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
49920 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49921 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49922 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
49923 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
49924 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49925 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49926 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49927 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49928 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49929 -
49930 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
49931 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49932 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49933 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
49934 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
49935 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49936 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49937 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
49938 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49939 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49940 -
49941 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49942 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49943 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
49944 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
49945 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
49946 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49947 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49948 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
49949 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49950 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49951 -
49952 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49953 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49954 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49955 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
49956 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
49957 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49958 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49959 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
49960 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49961 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49962 -
49963 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49964 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
49965 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49966 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
49967 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49968 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49969 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49970 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
49971 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49972 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49973 -
49974 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49975 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
49976 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
49977 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
49978 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
49979 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
49980 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49981 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
49982 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49983 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49984 -
49985 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49986 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
49987 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
49988 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
49989 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
49990 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
49991 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
49992 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
49993 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49994 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49995 -
49996 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49997 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
49998 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
49999 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
50000 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
50001 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
50002 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
50003 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
50004 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50005 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50006 -
50007 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50008 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
50009 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
50010 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50011 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50012 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50013 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50014 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50015 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50016 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50017 -
50018 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50019 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50020 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50021 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50022 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50023 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50024 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50025 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50026 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50027 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50028 -
50029 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50030 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
50031 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50032 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50033 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50034 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50035 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50036 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50037 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50038 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50039 -
50040 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50041 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
50042 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50043 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50044 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50045 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50046 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50047 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50048 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50049 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50050 -
50051 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50052 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
50053 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50054 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50055 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50056 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50057 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50058 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50059 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50060 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50061 -
50062 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50063 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50064 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50065 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50066 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50067 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50068 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50069 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50070 -74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50071 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50072 -
50073 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50074 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50075 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50076 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50077 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50078 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50079 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
50080 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50081 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50082 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50083 -
50084 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50085 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50086 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50087 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50088 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50089 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50090 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50091 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50092 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50093 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50094 -
50095 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50096 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50097 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50098 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50099 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50100 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50101 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50102 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50103 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50104 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50105 -
50106 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50107 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50108 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50109 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50110 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50111 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50112 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50113 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50114 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50115 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50116 -
50117 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50118 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50119 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50120 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50121 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50122 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50123 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50124 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50125 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50126 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50127 -
50128 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50129 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50130 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50131 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50132 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50133 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50134 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50135 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50136 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50137 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50138 -
50139 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50140 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50141 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50142 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50143 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50144 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50145 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50146 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50147 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50148 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50149 -
50150 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50151 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50152 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50153 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50154 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50155 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50156 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50157 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50158 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50159 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50160 -
50161 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50162 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50163 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50164 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50165 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50166 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50167 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50168 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50169 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50170 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50171 -
50172 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50173 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50174 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50175 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50176 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50177 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50179 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50180 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50181 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50182 -
50183 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50184 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50185 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50186 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50187 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50188 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50189 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50190 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50191 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50192 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50193 -
50194 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50195 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50196 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50197 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50198 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50199 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50201 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50202 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50203 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50204 -
50205 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50206 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50207 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50208 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50209 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50210 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50211 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50212 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50213 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50214 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50215 -
50216 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50217 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50218 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50219 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50220 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50221 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50222 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50223 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50224 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50225 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50226 -
50227 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50228 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50229 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50230 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50231 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50232 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50233 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50234 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50235 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50236 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50237 -
50238 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50239 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50240 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50241 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50242 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50243 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50244 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50245 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50246 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50247 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50248 -
50249 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50250 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50251 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50252 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50253 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50254 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50255 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50256 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50257 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50258 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50259 -
50260 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50261 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
50262 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50263 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50264 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50265 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50266 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50267 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50268 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50269 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50270 -
50271 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50272 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50273 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50274 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50275 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50276 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50277 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50278 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50279 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50280 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50281 -
50282 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50283 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50284 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50285 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50286 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50287 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50288 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50289 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50290 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50291 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50292 -
50293 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50294 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50295 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50296 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50297 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50298 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50299 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50300 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50301 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50302 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50303 -
50304 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50305 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50306 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50307 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50308 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50309 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50310 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50311 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50312 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50313 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50314 -
50315 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50316 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50317 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50318 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50319 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50320 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50321 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50322 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50323 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50324 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50325 -
50326 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50327 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50328 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50329 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50330 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50331 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50332 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50333 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50334 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50335 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50336 -
50337 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50338 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50339 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50340 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50341 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50342 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50343 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50344 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50345 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50346 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50347 -
50348 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50349 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50350 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50351 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50352 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50353 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50354 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50355 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50356 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50357 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50358 -
50359 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50360 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50361 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50362 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50363 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50364 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50365 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50366 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50367 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50368 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50369 -
50370 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50371 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50372 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50373 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50374 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50375 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50376 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50377 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50378 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50379 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50380 -
50381 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50382 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50383 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50384 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50385 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50386 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50387 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50388 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50389 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50390 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50391 -
50392 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50393 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50394 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50395 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50396 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50397 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50398 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50399 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50400 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50401 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50402 -
50403 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50404 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50405 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50406 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50407 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50408 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50409 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50410 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50411 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50412 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50413 -
50414 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50415 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50416 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50417 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50418 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50419 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50420 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50421 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50422 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50423 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50424 -
50425 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50426 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50427 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50428 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50429 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50430 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50431 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50432 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50433 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50434 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50435 -
50436 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50437 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50438 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50439 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50440 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50441 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50442 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50443 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50444 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50445 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50446 -
50447 -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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50449 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50450 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50451 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50452 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50453 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50454 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50455 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50456 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50457 -
50458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50460 +4 4 4 4 4 4 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
50472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50474 +4 4 4 4 4 4 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
50486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50495 +4 4 4 4 4 4 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
50500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50509 +4 4 4 4 4 4 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
50514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50523 +4 4 4 4 4 4 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
50528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50537 +4 4 4 4 4 4 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
50542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50546 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50547 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50551 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50552 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50553 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50555 +4 4 4 4 4 4
50556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50560 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50561 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50562 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50565 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50566 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50567 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50568 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50569 +4 4 4 4 4 4
50570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50574 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50575 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50576 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50579 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
50580 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50581 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50582 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50583 +4 4 4 4 4 4
50584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50587 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50588 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50589 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50590 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
50591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50592 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50593 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50594 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50595 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50596 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50597 +4 4 4 4 4 4
50598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50601 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50602 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50603 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50604 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50605 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50606 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50607 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50608 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50609 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50610 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50611 +4 4 4 4 4 4
50612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50615 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50616 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50617 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50618 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50619 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50620 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50621 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50622 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50623 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50624 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50625 +4 4 4 4 4 4
50626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50628 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50629 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50630 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50631 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50632 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50633 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50634 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50635 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50636 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50637 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50638 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50639 +4 4 4 4 4 4
50640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50642 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50643 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50644 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50645 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50646 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50647 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50648 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50649 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50650 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50651 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50652 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50653 +4 4 4 4 4 4
50654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50656 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50657 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50658 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50659 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50660 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50661 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50662 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50663 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50664 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50665 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50666 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50667 +4 4 4 4 4 4
50668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50670 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50671 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50672 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50673 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50674 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50675 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50676 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50677 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50678 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50679 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50680 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50681 +4 4 4 4 4 4
50682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50683 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50684 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50685 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50686 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50687 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50688 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50689 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50690 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50691 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50692 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50693 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50694 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50695 +4 4 4 4 4 4
50696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50697 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50698 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50699 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50700 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50701 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50702 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50703 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50704 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50705 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50706 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50707 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50708 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50709 +0 0 0 4 4 4
50710 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50711 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50712 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50713 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50714 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50715 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50716 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50717 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50718 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50719 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50720 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50721 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50722 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50723 +2 0 0 0 0 0
50724 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50725 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50726 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50727 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50728 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50729 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50730 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50731 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50732 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50733 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50734 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50735 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50736 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50737 +37 38 37 0 0 0
50738 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50739 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50740 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50741 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50742 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50743 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50744 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50745 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50746 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50747 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50748 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50749 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50750 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50751 +85 115 134 4 0 0
50752 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50753 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50754 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50755 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50756 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50757 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50758 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50759 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50760 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50761 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50762 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50763 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50764 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50765 +60 73 81 4 0 0
50766 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50767 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50768 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50769 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50770 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50771 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50772 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50773 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50774 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50775 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50776 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50777 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50778 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50779 +16 19 21 4 0 0
50780 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50781 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50782 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50783 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50784 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50785 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50786 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50787 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50788 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50789 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50790 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50791 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50792 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50793 +4 0 0 4 3 3
50794 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50795 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50796 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50798 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50799 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50800 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50801 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50802 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50803 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50804 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50805 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50806 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50807 +3 2 2 4 4 4
50808 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50809 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50810 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50811 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50812 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50813 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50814 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50815 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50816 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50817 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50818 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50819 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50820 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50821 +4 4 4 4 4 4
50822 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50823 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50824 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50825 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50826 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50827 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50828 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50829 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50830 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50831 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50832 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50833 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50834 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50835 +4 4 4 4 4 4
50836 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50837 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50838 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50839 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50840 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50841 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50842 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50843 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50844 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50845 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50846 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50847 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50848 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50849 +5 5 5 5 5 5
50850 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50851 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50852 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50853 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50854 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50855 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50856 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50857 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50858 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50859 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50860 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50861 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50862 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50863 +5 5 5 4 4 4
50864 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50865 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50866 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50867 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50868 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50869 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50870 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50871 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50872 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50873 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50874 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50875 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50877 +4 4 4 4 4 4
50878 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50879 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50880 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50881 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50882 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50883 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50884 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50885 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50886 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50887 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50888 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50889 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50891 +4 4 4 4 4 4
50892 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50893 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50894 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50895 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50896 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50897 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50898 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50899 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50900 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50901 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50902 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50905 +4 4 4 4 4 4
50906 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50907 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50908 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50909 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50910 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50911 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50912 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50913 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50914 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50915 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50916 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50919 +4 4 4 4 4 4
50920 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50921 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
50922 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
50923 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
50924 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50925 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
50926 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50927 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
50928 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
50929 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
50930 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50933 +4 4 4 4 4 4
50934 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
50935 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
50936 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
50937 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
50938 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50939 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
50940 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
50941 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
50942 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
50943 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
50944 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
50945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50947 +4 4 4 4 4 4
50948 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
50949 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
50950 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
50951 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
50952 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50953 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
50954 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
50955 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
50956 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
50957 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
50958 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
50959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50961 +4 4 4 4 4 4
50962 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
50963 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
50964 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
50965 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50966 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
50967 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
50968 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
50969 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
50970 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
50971 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
50972 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50975 +4 4 4 4 4 4
50976 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
50977 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
50978 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
50979 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50980 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50981 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
50982 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
50983 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
50984 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
50985 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
50986 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50989 +4 4 4 4 4 4
50990 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
50991 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
50992 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50993 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50994 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50995 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
50996 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
50997 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
50998 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
50999 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51000 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51003 +4 4 4 4 4 4
51004 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51005 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51006 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51007 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51008 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51009 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51010 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51011 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51012 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51013 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51014 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51017 +4 4 4 4 4 4
51018 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51019 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51020 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51021 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51022 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51023 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51024 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51025 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51026 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51027 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51028 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51031 +4 4 4 4 4 4
51032 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51033 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51034 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51035 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51036 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51037 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51038 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51039 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51040 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51041 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51042 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51045 +4 4 4 4 4 4
51046 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51047 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51048 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51049 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51050 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51051 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51052 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51053 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51054 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51055 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51056 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51058 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51059 +4 4 4 4 4 4
51060 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51061 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51062 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51063 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51064 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51065 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51066 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51067 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51068 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51069 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51070 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51072 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51073 +4 4 4 4 4 4
51074 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51075 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51076 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51077 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51078 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51079 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51080 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51081 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51082 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51083 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51084 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51086 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51087 +4 4 4 4 4 4
51088 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51089 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51090 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51091 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51092 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51093 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51094 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51095 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51096 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51097 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51098 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51101 +4 4 4 4 4 4
51102 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51103 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51104 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51105 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51106 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51107 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51108 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51109 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51110 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51111 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51112 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51115 +4 4 4 4 4 4
51116 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51117 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51118 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51119 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51120 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51121 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51122 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51123 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51124 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51125 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51126 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51129 +4 4 4 4 4 4
51130 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51131 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51132 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51133 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51134 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51135 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51136 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51137 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51138 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51139 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51140 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51143 +4 4 4 4 4 4
51144 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51145 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51146 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51147 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51148 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51149 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51150 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51151 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51152 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51153 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51154 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51157 +4 4 4 4 4 4
51158 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51159 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51160 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51161 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51162 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51163 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51164 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51165 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51166 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51167 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51168 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51169 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51171 +4 4 4 4 4 4
51172 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51173 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51174 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51175 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51176 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51177 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51178 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51179 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51180 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51181 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51182 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51185 +4 4 4 4 4 4
51186 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51187 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51188 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51189 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51190 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51191 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51192 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51193 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51194 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51195 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51196 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51199 +4 4 4 4 4 4
51200 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51201 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51202 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51203 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51204 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51205 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51206 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51207 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51208 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51209 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51210 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51213 +4 4 4 4 4 4
51214 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51215 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51216 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51217 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51218 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51219 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51220 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51221 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51222 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51223 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51224 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51227 +4 4 4 4 4 4
51228 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51229 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51230 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51231 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51232 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51233 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51234 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51235 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51236 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51237 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51238 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51241 +4 4 4 4 4 4
51242 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51243 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51244 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51245 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51246 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51247 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51248 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51249 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51250 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51251 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51252 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51255 +4 4 4 4 4 4
51256 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51257 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51258 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51259 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51260 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51261 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51262 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51263 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51264 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51265 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51266 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51269 +4 4 4 4 4 4
51270 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51271 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51272 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51273 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51274 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51275 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51276 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51277 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51278 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51279 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
51284 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51285 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51286 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51287 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51288 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51289 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51290 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51291 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51292 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51293 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51295 +4 4 4 4 4 4 4 4 4 4 4 4 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
51298 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51299 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51300 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51301 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51302 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51303 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51304 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51305 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51306 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51307 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51309 +4 4 4 4 4 4 4 4 4 4 4 4 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
51312 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51313 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51314 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51315 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51316 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51317 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51318 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51319 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51320 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51321 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51323 +4 4 4 4 4 4 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
51326 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51327 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51328 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51329 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51330 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51331 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51332 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51333 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51334 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
51340 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51341 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51342 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51343 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51344 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51345 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51346 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51347 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51348 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51350 +4 4 4 4 4 4 4 4 4 4 4 4 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
51354 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51355 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51356 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51357 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51358 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51359 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51360 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51361 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51362 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51364 +4 4 4 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
51368 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51369 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51370 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51371 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51372 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51373 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51374 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51375 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
51382 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51383 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51384 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51385 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51386 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51387 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51388 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51389 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51391 +4 4 4 4 4 4 4 4 4 4 4 4 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
51396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51397 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51398 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51399 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51400 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51401 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51402 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51403 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51405 +4 4 4 4 4 4 4 4 4 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
51410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51411 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51412 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51413 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51414 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51415 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51416 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51417 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51419 +4 4 4 4 4 4 4 4 4 4 4 4 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
51424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51425 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51426 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51427 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51428 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51429 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51430 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51431 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51433 +4 4 4 4 4 4 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
51438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51440 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51441 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51442 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51443 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51444 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51445 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51447 +4 4 4 4 4 4 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
51452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51455 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51456 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51457 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51458 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51461 +4 4 4 4 4 4 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
51466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51469 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51470 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51471 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51472 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51475 +4 4 4 4 4 4 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
51480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51483 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51484 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51485 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51486 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51489 +4 4 4 4 4 4 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
51494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51497 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51498 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51499 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51500 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51503 +4 4 4 4 4 4 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
51508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51512 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51513 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51514 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51517 +4 4 4 4 4 4 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
51522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51527 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51528 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51531 +4 4 4 4 4 4 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
51536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51540 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51541 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51542 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51545 +4 4 4 4 4 4 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
51550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51554 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51555 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51559 +4 4 4 4 4 4 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
51564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51568 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51569 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51573 +4 4 4 4 4 4 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
51578 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51579 index fe92eed..106e085 100644
51580 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51581 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51582 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51583 struct mb862xxfb_par *par = info->par;
51584
51585 if (info->var.bits_per_pixel == 32) {
51586 - info->fbops->fb_fillrect = cfb_fillrect;
51587 - info->fbops->fb_copyarea = cfb_copyarea;
51588 - info->fbops->fb_imageblit = cfb_imageblit;
51589 + pax_open_kernel();
51590 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51591 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51592 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51593 + pax_close_kernel();
51594 } else {
51595 outreg(disp, GC_L0EM, 3);
51596 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51597 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51598 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51599 + pax_open_kernel();
51600 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51601 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51602 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51603 + pax_close_kernel();
51604 }
51605 outreg(draw, GDC_REG_DRAW_BASE, 0);
51606 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51607 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51608 index ff22871..b129bed 100644
51609 --- a/drivers/video/nvidia/nvidia.c
51610 +++ b/drivers/video/nvidia/nvidia.c
51611 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51612 info->fix.line_length = (info->var.xres_virtual *
51613 info->var.bits_per_pixel) >> 3;
51614 if (info->var.accel_flags) {
51615 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51616 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51617 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51618 - info->fbops->fb_sync = nvidiafb_sync;
51619 + pax_open_kernel();
51620 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51621 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51622 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51623 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51624 + pax_close_kernel();
51625 info->pixmap.scan_align = 4;
51626 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51627 info->flags |= FBINFO_READS_FAST;
51628 NVResetGraphics(info);
51629 } else {
51630 - info->fbops->fb_imageblit = cfb_imageblit;
51631 - info->fbops->fb_fillrect = cfb_fillrect;
51632 - info->fbops->fb_copyarea = cfb_copyarea;
51633 - info->fbops->fb_sync = NULL;
51634 + pax_open_kernel();
51635 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51636 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51637 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51638 + *(void **)&info->fbops->fb_sync = NULL;
51639 + pax_close_kernel();
51640 info->pixmap.scan_align = 1;
51641 info->flags |= FBINFO_HWACCEL_DISABLED;
51642 info->flags &= ~FBINFO_READS_FAST;
51643 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51644 info->pixmap.size = 8 * 1024;
51645 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51646
51647 - if (!hwcur)
51648 - info->fbops->fb_cursor = NULL;
51649 + if (!hwcur) {
51650 + pax_open_kernel();
51651 + *(void **)&info->fbops->fb_cursor = NULL;
51652 + pax_close_kernel();
51653 + }
51654
51655 info->var.accel_flags = (!noaccel);
51656
51657 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51658 index 05c2dc3..ea1f391 100644
51659 --- a/drivers/video/s1d13xxxfb.c
51660 +++ b/drivers/video/s1d13xxxfb.c
51661 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51662
51663 switch(prod_id) {
51664 case S1D13506_PROD_ID: /* activate acceleration */
51665 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51666 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51667 + pax_open_kernel();
51668 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51669 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51670 + pax_close_kernel();
51671 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51672 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51673 break;
51674 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51675 index e188ada..aac63c8 100644
51676 --- a/drivers/video/smscufx.c
51677 +++ b/drivers/video/smscufx.c
51678 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51679 fb_deferred_io_cleanup(info);
51680 kfree(info->fbdefio);
51681 info->fbdefio = NULL;
51682 - info->fbops->fb_mmap = ufx_ops_mmap;
51683 + pax_open_kernel();
51684 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51685 + pax_close_kernel();
51686 }
51687
51688 pr_debug("released /dev/fb%d user=%d count=%d",
51689 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51690 index d2e5bc3..4cb05d1 100644
51691 --- a/drivers/video/udlfb.c
51692 +++ b/drivers/video/udlfb.c
51693 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51694 dlfb_urb_completion(urb);
51695
51696 error:
51697 - atomic_add(bytes_sent, &dev->bytes_sent);
51698 - atomic_add(bytes_identical, &dev->bytes_identical);
51699 - atomic_add(width*height*2, &dev->bytes_rendered);
51700 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51701 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51702 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51703 end_cycles = get_cycles();
51704 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51705 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51706 >> 10)), /* Kcycles */
51707 &dev->cpu_kcycles_used);
51708
51709 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51710 dlfb_urb_completion(urb);
51711
51712 error:
51713 - atomic_add(bytes_sent, &dev->bytes_sent);
51714 - atomic_add(bytes_identical, &dev->bytes_identical);
51715 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51716 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51717 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51718 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51719 end_cycles = get_cycles();
51720 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51721 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51722 >> 10)), /* Kcycles */
51723 &dev->cpu_kcycles_used);
51724 }
51725 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51726 fb_deferred_io_cleanup(info);
51727 kfree(info->fbdefio);
51728 info->fbdefio = NULL;
51729 - info->fbops->fb_mmap = dlfb_ops_mmap;
51730 + pax_open_kernel();
51731 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51732 + pax_close_kernel();
51733 }
51734
51735 pr_warn("released /dev/fb%d user=%d count=%d\n",
51736 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51737 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51738 struct dlfb_data *dev = fb_info->par;
51739 return snprintf(buf, PAGE_SIZE, "%u\n",
51740 - atomic_read(&dev->bytes_rendered));
51741 + atomic_read_unchecked(&dev->bytes_rendered));
51742 }
51743
51744 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51745 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51746 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51747 struct dlfb_data *dev = fb_info->par;
51748 return snprintf(buf, PAGE_SIZE, "%u\n",
51749 - atomic_read(&dev->bytes_identical));
51750 + atomic_read_unchecked(&dev->bytes_identical));
51751 }
51752
51753 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51754 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51755 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51756 struct dlfb_data *dev = fb_info->par;
51757 return snprintf(buf, PAGE_SIZE, "%u\n",
51758 - atomic_read(&dev->bytes_sent));
51759 + atomic_read_unchecked(&dev->bytes_sent));
51760 }
51761
51762 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51763 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51764 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51765 struct dlfb_data *dev = fb_info->par;
51766 return snprintf(buf, PAGE_SIZE, "%u\n",
51767 - atomic_read(&dev->cpu_kcycles_used));
51768 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51769 }
51770
51771 static ssize_t edid_show(
51772 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51773 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51774 struct dlfb_data *dev = fb_info->par;
51775
51776 - atomic_set(&dev->bytes_rendered, 0);
51777 - atomic_set(&dev->bytes_identical, 0);
51778 - atomic_set(&dev->bytes_sent, 0);
51779 - atomic_set(&dev->cpu_kcycles_used, 0);
51780 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51781 + atomic_set_unchecked(&dev->bytes_identical, 0);
51782 + atomic_set_unchecked(&dev->bytes_sent, 0);
51783 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51784
51785 return count;
51786 }
51787 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51788 index 7aec6f3..e3b2d55 100644
51789 --- a/drivers/video/uvesafb.c
51790 +++ b/drivers/video/uvesafb.c
51791 @@ -19,6 +19,7 @@
51792 #include <linux/io.h>
51793 #include <linux/mutex.h>
51794 #include <linux/slab.h>
51795 +#include <linux/moduleloader.h>
51796 #include <video/edid.h>
51797 #include <video/uvesafb.h>
51798 #ifdef CONFIG_X86
51799 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51800 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51801 par->pmi_setpal = par->ypan = 0;
51802 } else {
51803 +
51804 +#ifdef CONFIG_PAX_KERNEXEC
51805 +#ifdef CONFIG_MODULES
51806 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51807 +#endif
51808 + if (!par->pmi_code) {
51809 + par->pmi_setpal = par->ypan = 0;
51810 + return 0;
51811 + }
51812 +#endif
51813 +
51814 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51815 + task->t.regs.edi);
51816 +
51817 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51818 + pax_open_kernel();
51819 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51820 + pax_close_kernel();
51821 +
51822 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51823 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51824 +#else
51825 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51826 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51827 +#endif
51828 +
51829 printk(KERN_INFO "uvesafb: protected mode interface info at "
51830 "%04x:%04x\n",
51831 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51832 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51833 par->ypan = ypan;
51834
51835 if (par->pmi_setpal || par->ypan) {
51836 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51837 if (__supported_pte_mask & _PAGE_NX) {
51838 par->pmi_setpal = par->ypan = 0;
51839 printk(KERN_WARNING "uvesafb: NX protection is active, "
51840 "better not use the PMI.\n");
51841 - } else {
51842 + } else
51843 +#endif
51844 uvesafb_vbe_getpmi(task, par);
51845 - }
51846 }
51847 #else
51848 /* The protected mode interface is not available on non-x86. */
51849 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51850 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51851
51852 /* Disable blanking if the user requested so. */
51853 - if (!blank)
51854 - info->fbops->fb_blank = NULL;
51855 + if (!blank) {
51856 + pax_open_kernel();
51857 + *(void **)&info->fbops->fb_blank = NULL;
51858 + pax_close_kernel();
51859 + }
51860
51861 /*
51862 * Find out how much IO memory is required for the mode with
51863 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51864 info->flags = FBINFO_FLAG_DEFAULT |
51865 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51866
51867 - if (!par->ypan)
51868 - info->fbops->fb_pan_display = NULL;
51869 + if (!par->ypan) {
51870 + pax_open_kernel();
51871 + *(void **)&info->fbops->fb_pan_display = NULL;
51872 + pax_close_kernel();
51873 + }
51874 }
51875
51876 static void uvesafb_init_mtrr(struct fb_info *info)
51877 @@ -1796,6 +1826,11 @@ out:
51878 if (par->vbe_modes)
51879 kfree(par->vbe_modes);
51880
51881 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51882 + if (par->pmi_code)
51883 + module_free_exec(NULL, par->pmi_code);
51884 +#endif
51885 +
51886 framebuffer_release(info);
51887 return err;
51888 }
51889 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51890 kfree(par->vbe_state_orig);
51891 if (par->vbe_state_saved)
51892 kfree(par->vbe_state_saved);
51893 +
51894 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51895 + if (par->pmi_code)
51896 + module_free_exec(NULL, par->pmi_code);
51897 +#endif
51898 +
51899 }
51900
51901 framebuffer_release(info);
51902 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51903 index 501b340..d80aa17 100644
51904 --- a/drivers/video/vesafb.c
51905 +++ b/drivers/video/vesafb.c
51906 @@ -9,6 +9,7 @@
51907 */
51908
51909 #include <linux/module.h>
51910 +#include <linux/moduleloader.h>
51911 #include <linux/kernel.h>
51912 #include <linux/errno.h>
51913 #include <linux/string.h>
51914 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51915 static int vram_total __initdata; /* Set total amount of memory */
51916 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51917 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51918 -static void (*pmi_start)(void) __read_mostly;
51919 -static void (*pmi_pal) (void) __read_mostly;
51920 +static void (*pmi_start)(void) __read_only;
51921 +static void (*pmi_pal) (void) __read_only;
51922 static int depth __read_mostly;
51923 static int vga_compat __read_mostly;
51924 /* --------------------------------------------------------------------- */
51925 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
51926 unsigned int size_vmode;
51927 unsigned int size_remap;
51928 unsigned int size_total;
51929 + void *pmi_code = NULL;
51930
51931 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
51932 return -ENODEV;
51933 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
51934 size_remap = size_total;
51935 vesafb_fix.smem_len = size_remap;
51936
51937 -#ifndef __i386__
51938 - screen_info.vesapm_seg = 0;
51939 -#endif
51940 -
51941 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
51942 printk(KERN_WARNING
51943 "vesafb: cannot reserve video memory at 0x%lx\n",
51944 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
51945 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
51946 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
51947
51948 +#ifdef __i386__
51949 +
51950 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51951 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
51952 + if (!pmi_code)
51953 +#elif !defined(CONFIG_PAX_KERNEXEC)
51954 + if (0)
51955 +#endif
51956 +
51957 +#endif
51958 + screen_info.vesapm_seg = 0;
51959 +
51960 if (screen_info.vesapm_seg) {
51961 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
51962 - screen_info.vesapm_seg,screen_info.vesapm_off);
51963 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
51964 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
51965 }
51966
51967 if (screen_info.vesapm_seg < 0xc000)
51968 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
51969
51970 if (ypan || pmi_setpal) {
51971 unsigned short *pmi_base;
51972 +
51973 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
51974 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
51975 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
51976 +
51977 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51978 + pax_open_kernel();
51979 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
51980 +#else
51981 + pmi_code = pmi_base;
51982 +#endif
51983 +
51984 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
51985 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
51986 +
51987 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51988 + pmi_start = ktva_ktla(pmi_start);
51989 + pmi_pal = ktva_ktla(pmi_pal);
51990 + pax_close_kernel();
51991 +#endif
51992 +
51993 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
51994 if (pmi_base[3]) {
51995 printk(KERN_INFO "vesafb: pmi: ports = ");
51996 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51997 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
51998 (ypan ? FBINFO_HWACCEL_YPAN : 0);
51999
52000 - if (!ypan)
52001 - info->fbops->fb_pan_display = NULL;
52002 + if (!ypan) {
52003 + pax_open_kernel();
52004 + *(void **)&info->fbops->fb_pan_display = NULL;
52005 + pax_close_kernel();
52006 + }
52007
52008 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52009 err = -ENOMEM;
52010 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52011 info->node, info->fix.id);
52012 return 0;
52013 err:
52014 +
52015 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52016 + module_free_exec(NULL, pmi_code);
52017 +#endif
52018 +
52019 if (info->screen_base)
52020 iounmap(info->screen_base);
52021 framebuffer_release(info);
52022 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52023 index 88714ae..16c2e11 100644
52024 --- a/drivers/video/via/via_clock.h
52025 +++ b/drivers/video/via/via_clock.h
52026 @@ -56,7 +56,7 @@ struct via_clock {
52027
52028 void (*set_engine_pll_state)(u8 state);
52029 void (*set_engine_pll)(struct via_pll_config config);
52030 -};
52031 +} __no_const;
52032
52033
52034 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52035 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52036 index fef20db..d28b1ab 100644
52037 --- a/drivers/xen/xenfs/xenstored.c
52038 +++ b/drivers/xen/xenfs/xenstored.c
52039 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52040 static int xsd_kva_open(struct inode *inode, struct file *file)
52041 {
52042 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52043 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52044 + NULL);
52045 +#else
52046 xen_store_interface);
52047 +#endif
52048 +
52049 if (!file->private_data)
52050 return -ENOMEM;
52051 return 0;
52052 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52053 index 9ff073f..05cef23 100644
52054 --- a/fs/9p/vfs_addr.c
52055 +++ b/fs/9p/vfs_addr.c
52056 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52057
52058 retval = v9fs_file_write_internal(inode,
52059 v9inode->writeback_fid,
52060 - (__force const char __user *)buffer,
52061 + (const char __force_user *)buffer,
52062 len, &offset, 0);
52063 if (retval > 0)
52064 retval = 0;
52065 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52066 index 25b018e..b941525 100644
52067 --- a/fs/9p/vfs_inode.c
52068 +++ b/fs/9p/vfs_inode.c
52069 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52070 void
52071 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52072 {
52073 - char *s = nd_get_link(nd);
52074 + const char *s = nd_get_link(nd);
52075
52076 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52077 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52078 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52079 index 370b24c..ff0be7b 100644
52080 --- a/fs/Kconfig.binfmt
52081 +++ b/fs/Kconfig.binfmt
52082 @@ -103,7 +103,7 @@ config HAVE_AOUT
52083
52084 config BINFMT_AOUT
52085 tristate "Kernel support for a.out and ECOFF binaries"
52086 - depends on HAVE_AOUT
52087 + depends on HAVE_AOUT && BROKEN
52088 ---help---
52089 A.out (Assembler.OUTput) is a set of formats for libraries and
52090 executables used in the earliest versions of UNIX. Linux used
52091 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52092 index 789bc25..fafaeea 100644
52093 --- a/fs/afs/inode.c
52094 +++ b/fs/afs/inode.c
52095 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52096 struct afs_vnode *vnode;
52097 struct super_block *sb;
52098 struct inode *inode;
52099 - static atomic_t afs_autocell_ino;
52100 + static atomic_unchecked_t afs_autocell_ino;
52101
52102 _enter("{%x:%u},%*.*s,",
52103 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52104 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52105 data.fid.unique = 0;
52106 data.fid.vnode = 0;
52107
52108 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52109 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52110 afs_iget5_autocell_test, afs_iget5_set,
52111 &data);
52112 if (!inode) {
52113 diff --git a/fs/aio.c b/fs/aio.c
52114 index 9b5ca11..c530886 100644
52115 --- a/fs/aio.c
52116 +++ b/fs/aio.c
52117 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52118 size += sizeof(struct io_event) * nr_events;
52119 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52120
52121 - if (nr_pages < 0)
52122 + if (nr_pages <= 0)
52123 return -EINVAL;
52124
52125 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52126 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52127 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52128 {
52129 ssize_t ret;
52130 + struct iovec iovstack;
52131
52132 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52133
52134 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52135 if (compat)
52136 ret = compat_rw_copy_check_uvector(rw,
52137 (struct compat_iovec __user *)kiocb->ki_buf,
52138 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52139 + kiocb->ki_nr_segs, 1, &iovstack,
52140 &kiocb->ki_iovec);
52141 else
52142 #endif
52143 ret = rw_copy_check_uvector(rw,
52144 (struct iovec __user *)kiocb->ki_buf,
52145 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52146 + kiocb->ki_nr_segs, 1, &iovstack,
52147 &kiocb->ki_iovec);
52148 if (ret < 0)
52149 return ret;
52150
52151 + if (kiocb->ki_iovec == &iovstack) {
52152 + kiocb->ki_inline_vec = iovstack;
52153 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52154 + }
52155 +
52156 /* ki_nbytes now reflect bytes instead of segs */
52157 kiocb->ki_nbytes = ret;
52158 return 0;
52159 diff --git a/fs/attr.c b/fs/attr.c
52160 index 1449adb..a2038c2 100644
52161 --- a/fs/attr.c
52162 +++ b/fs/attr.c
52163 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52164 unsigned long limit;
52165
52166 limit = rlimit(RLIMIT_FSIZE);
52167 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52168 if (limit != RLIM_INFINITY && offset > limit)
52169 goto out_sig;
52170 if (offset > inode->i_sb->s_maxbytes)
52171 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52172 index 3db70da..7aeec5b 100644
52173 --- a/fs/autofs4/waitq.c
52174 +++ b/fs/autofs4/waitq.c
52175 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52176 {
52177 unsigned long sigpipe, flags;
52178 mm_segment_t fs;
52179 - const char *data = (const char *)addr;
52180 + const char __user *data = (const char __force_user *)addr;
52181 ssize_t wr = 0;
52182
52183 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52184 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52185 return 1;
52186 }
52187
52188 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52189 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52190 +#endif
52191 +
52192 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52193 enum autofs_notify notify)
52194 {
52195 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52196
52197 /* If this is a direct mount request create a dummy name */
52198 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52199 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52200 + /* this name does get written to userland via autofs4_write() */
52201 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52202 +#else
52203 qstr.len = sprintf(name, "%p", dentry);
52204 +#endif
52205 else {
52206 qstr.len = autofs4_getpath(sbi, dentry, &name);
52207 if (!qstr.len) {
52208 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52209 index 2722387..c8dd2a7 100644
52210 --- a/fs/befs/endian.h
52211 +++ b/fs/befs/endian.h
52212 @@ -11,7 +11,7 @@
52213
52214 #include <asm/byteorder.h>
52215
52216 -static inline u64
52217 +static inline u64 __intentional_overflow(-1)
52218 fs64_to_cpu(const struct super_block *sb, fs64 n)
52219 {
52220 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52221 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52222 return (__force fs64)cpu_to_be64(n);
52223 }
52224
52225 -static inline u32
52226 +static inline u32 __intentional_overflow(-1)
52227 fs32_to_cpu(const struct super_block *sb, fs32 n)
52228 {
52229 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52230 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52231 index e9c75e2..1baece1 100644
52232 --- a/fs/befs/linuxvfs.c
52233 +++ b/fs/befs/linuxvfs.c
52234 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52235 {
52236 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52237 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52238 - char *link = nd_get_link(nd);
52239 + const char *link = nd_get_link(nd);
52240 if (!IS_ERR(link))
52241 kfree(link);
52242 }
52243 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52244 index 89dec7f..361b0d75 100644
52245 --- a/fs/binfmt_aout.c
52246 +++ b/fs/binfmt_aout.c
52247 @@ -16,6 +16,7 @@
52248 #include <linux/string.h>
52249 #include <linux/fs.h>
52250 #include <linux/file.h>
52251 +#include <linux/security.h>
52252 #include <linux/stat.h>
52253 #include <linux/fcntl.h>
52254 #include <linux/ptrace.h>
52255 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52256 #endif
52257 # define START_STACK(u) ((void __user *)u.start_stack)
52258
52259 + memset(&dump, 0, sizeof(dump));
52260 +
52261 fs = get_fs();
52262 set_fs(KERNEL_DS);
52263 has_dumped = 1;
52264 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52265
52266 /* If the size of the dump file exceeds the rlimit, then see what would happen
52267 if we wrote the stack, but not the data area. */
52268 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52269 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52270 dump.u_dsize = 0;
52271
52272 /* Make sure we have enough room to write the stack and data areas. */
52273 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52274 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52275 dump.u_ssize = 0;
52276
52277 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52278 rlim = rlimit(RLIMIT_DATA);
52279 if (rlim >= RLIM_INFINITY)
52280 rlim = ~0;
52281 +
52282 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52283 if (ex.a_data + ex.a_bss > rlim)
52284 return -ENOMEM;
52285
52286 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52287
52288 install_exec_creds(bprm);
52289
52290 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52291 + current->mm->pax_flags = 0UL;
52292 +#endif
52293 +
52294 +#ifdef CONFIG_PAX_PAGEEXEC
52295 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52296 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52297 +
52298 +#ifdef CONFIG_PAX_EMUTRAMP
52299 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52300 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52301 +#endif
52302 +
52303 +#ifdef CONFIG_PAX_MPROTECT
52304 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52305 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52306 +#endif
52307 +
52308 + }
52309 +#endif
52310 +
52311 if (N_MAGIC(ex) == OMAGIC) {
52312 unsigned long text_addr, map_size;
52313 loff_t pos;
52314 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52315 }
52316
52317 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52318 - PROT_READ | PROT_WRITE | PROT_EXEC,
52319 + PROT_READ | PROT_WRITE,
52320 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52321 fd_offset + ex.a_text);
52322 if (error != N_DATADDR(ex)) {
52323 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52324 index 4c94a79..f428019 100644
52325 --- a/fs/binfmt_elf.c
52326 +++ b/fs/binfmt_elf.c
52327 @@ -34,6 +34,7 @@
52328 #include <linux/utsname.h>
52329 #include <linux/coredump.h>
52330 #include <linux/sched.h>
52331 +#include <linux/xattr.h>
52332 #include <asm/uaccess.h>
52333 #include <asm/param.h>
52334 #include <asm/page.h>
52335 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52336 #define elf_core_dump NULL
52337 #endif
52338
52339 +#ifdef CONFIG_PAX_MPROTECT
52340 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52341 +#endif
52342 +
52343 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52344 +static void elf_handle_mmap(struct file *file);
52345 +#endif
52346 +
52347 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52348 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52349 #else
52350 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52351 .load_binary = load_elf_binary,
52352 .load_shlib = load_elf_library,
52353 .core_dump = elf_core_dump,
52354 +
52355 +#ifdef CONFIG_PAX_MPROTECT
52356 + .handle_mprotect= elf_handle_mprotect,
52357 +#endif
52358 +
52359 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52360 + .handle_mmap = elf_handle_mmap,
52361 +#endif
52362 +
52363 .min_coredump = ELF_EXEC_PAGESIZE,
52364 };
52365
52366 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52367
52368 static int set_brk(unsigned long start, unsigned long end)
52369 {
52370 + unsigned long e = end;
52371 +
52372 start = ELF_PAGEALIGN(start);
52373 end = ELF_PAGEALIGN(end);
52374 if (end > start) {
52375 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52376 if (BAD_ADDR(addr))
52377 return addr;
52378 }
52379 - current->mm->start_brk = current->mm->brk = end;
52380 + current->mm->start_brk = current->mm->brk = e;
52381 return 0;
52382 }
52383
52384 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52385 elf_addr_t __user *u_rand_bytes;
52386 const char *k_platform = ELF_PLATFORM;
52387 const char *k_base_platform = ELF_BASE_PLATFORM;
52388 - unsigned char k_rand_bytes[16];
52389 + u32 k_rand_bytes[4];
52390 int items;
52391 elf_addr_t *elf_info;
52392 int ei_index = 0;
52393 const struct cred *cred = current_cred();
52394 struct vm_area_struct *vma;
52395 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52396
52397 /*
52398 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52399 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52400 * Generate 16 random bytes for userspace PRNG seeding.
52401 */
52402 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52403 - u_rand_bytes = (elf_addr_t __user *)
52404 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52405 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52406 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52407 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52408 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52409 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52410 + u_rand_bytes = (elf_addr_t __user *) p;
52411 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52412 return -EFAULT;
52413
52414 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52415 return -EFAULT;
52416 current->mm->env_end = p;
52417
52418 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52419 +
52420 /* Put the elf_info on the stack in the right place. */
52421 sp = (elf_addr_t __user *)envp + 1;
52422 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52423 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52424 return -EFAULT;
52425 return 0;
52426 }
52427 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52428 an ELF header */
52429
52430 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52431 - struct file *interpreter, unsigned long *interp_map_addr,
52432 - unsigned long no_base)
52433 + struct file *interpreter, unsigned long no_base)
52434 {
52435 struct elf_phdr *elf_phdata;
52436 struct elf_phdr *eppnt;
52437 - unsigned long load_addr = 0;
52438 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52439 int load_addr_set = 0;
52440 unsigned long last_bss = 0, elf_bss = 0;
52441 - unsigned long error = ~0UL;
52442 + unsigned long error = -EINVAL;
52443 unsigned long total_size;
52444 int retval, i, size;
52445
52446 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52447 goto out_close;
52448 }
52449
52450 +#ifdef CONFIG_PAX_SEGMEXEC
52451 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52452 + pax_task_size = SEGMEXEC_TASK_SIZE;
52453 +#endif
52454 +
52455 eppnt = elf_phdata;
52456 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52457 if (eppnt->p_type == PT_LOAD) {
52458 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52459 map_addr = elf_map(interpreter, load_addr + vaddr,
52460 eppnt, elf_prot, elf_type, total_size);
52461 total_size = 0;
52462 - if (!*interp_map_addr)
52463 - *interp_map_addr = map_addr;
52464 error = map_addr;
52465 if (BAD_ADDR(map_addr))
52466 goto out_close;
52467 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52468 k = load_addr + eppnt->p_vaddr;
52469 if (BAD_ADDR(k) ||
52470 eppnt->p_filesz > eppnt->p_memsz ||
52471 - eppnt->p_memsz > TASK_SIZE ||
52472 - TASK_SIZE - eppnt->p_memsz < k) {
52473 + eppnt->p_memsz > pax_task_size ||
52474 + pax_task_size - eppnt->p_memsz < k) {
52475 error = -ENOMEM;
52476 goto out_close;
52477 }
52478 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52479 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52480
52481 /* Map the last of the bss segment */
52482 - error = vm_brk(elf_bss, last_bss - elf_bss);
52483 - if (BAD_ADDR(error))
52484 - goto out_close;
52485 + if (last_bss > elf_bss) {
52486 + error = vm_brk(elf_bss, last_bss - elf_bss);
52487 + if (BAD_ADDR(error))
52488 + goto out_close;
52489 + }
52490 }
52491
52492 error = load_addr;
52493 @@ -538,6 +569,315 @@ out:
52494 return error;
52495 }
52496
52497 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52498 +#ifdef CONFIG_PAX_SOFTMODE
52499 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52500 +{
52501 + unsigned long pax_flags = 0UL;
52502 +
52503 +#ifdef CONFIG_PAX_PAGEEXEC
52504 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52505 + pax_flags |= MF_PAX_PAGEEXEC;
52506 +#endif
52507 +
52508 +#ifdef CONFIG_PAX_SEGMEXEC
52509 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52510 + pax_flags |= MF_PAX_SEGMEXEC;
52511 +#endif
52512 +
52513 +#ifdef CONFIG_PAX_EMUTRAMP
52514 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52515 + pax_flags |= MF_PAX_EMUTRAMP;
52516 +#endif
52517 +
52518 +#ifdef CONFIG_PAX_MPROTECT
52519 + if (elf_phdata->p_flags & PF_MPROTECT)
52520 + pax_flags |= MF_PAX_MPROTECT;
52521 +#endif
52522 +
52523 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52524 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52525 + pax_flags |= MF_PAX_RANDMMAP;
52526 +#endif
52527 +
52528 + return pax_flags;
52529 +}
52530 +#endif
52531 +
52532 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52533 +{
52534 + unsigned long pax_flags = 0UL;
52535 +
52536 +#ifdef CONFIG_PAX_PAGEEXEC
52537 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52538 + pax_flags |= MF_PAX_PAGEEXEC;
52539 +#endif
52540 +
52541 +#ifdef CONFIG_PAX_SEGMEXEC
52542 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52543 + pax_flags |= MF_PAX_SEGMEXEC;
52544 +#endif
52545 +
52546 +#ifdef CONFIG_PAX_EMUTRAMP
52547 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52548 + pax_flags |= MF_PAX_EMUTRAMP;
52549 +#endif
52550 +
52551 +#ifdef CONFIG_PAX_MPROTECT
52552 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52553 + pax_flags |= MF_PAX_MPROTECT;
52554 +#endif
52555 +
52556 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52557 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52558 + pax_flags |= MF_PAX_RANDMMAP;
52559 +#endif
52560 +
52561 + return pax_flags;
52562 +}
52563 +#endif
52564 +
52565 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52566 +#ifdef CONFIG_PAX_SOFTMODE
52567 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52568 +{
52569 + unsigned long pax_flags = 0UL;
52570 +
52571 +#ifdef CONFIG_PAX_PAGEEXEC
52572 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52573 + pax_flags |= MF_PAX_PAGEEXEC;
52574 +#endif
52575 +
52576 +#ifdef CONFIG_PAX_SEGMEXEC
52577 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52578 + pax_flags |= MF_PAX_SEGMEXEC;
52579 +#endif
52580 +
52581 +#ifdef CONFIG_PAX_EMUTRAMP
52582 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52583 + pax_flags |= MF_PAX_EMUTRAMP;
52584 +#endif
52585 +
52586 +#ifdef CONFIG_PAX_MPROTECT
52587 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52588 + pax_flags |= MF_PAX_MPROTECT;
52589 +#endif
52590 +
52591 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52592 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52593 + pax_flags |= MF_PAX_RANDMMAP;
52594 +#endif
52595 +
52596 + return pax_flags;
52597 +}
52598 +#endif
52599 +
52600 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52601 +{
52602 + unsigned long pax_flags = 0UL;
52603 +
52604 +#ifdef CONFIG_PAX_PAGEEXEC
52605 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52606 + pax_flags |= MF_PAX_PAGEEXEC;
52607 +#endif
52608 +
52609 +#ifdef CONFIG_PAX_SEGMEXEC
52610 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52611 + pax_flags |= MF_PAX_SEGMEXEC;
52612 +#endif
52613 +
52614 +#ifdef CONFIG_PAX_EMUTRAMP
52615 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52616 + pax_flags |= MF_PAX_EMUTRAMP;
52617 +#endif
52618 +
52619 +#ifdef CONFIG_PAX_MPROTECT
52620 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52621 + pax_flags |= MF_PAX_MPROTECT;
52622 +#endif
52623 +
52624 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52625 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52626 + pax_flags |= MF_PAX_RANDMMAP;
52627 +#endif
52628 +
52629 + return pax_flags;
52630 +}
52631 +#endif
52632 +
52633 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52634 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52635 +{
52636 + unsigned long pax_flags = 0UL;
52637 +
52638 +#ifdef CONFIG_PAX_EI_PAX
52639 +
52640 +#ifdef CONFIG_PAX_PAGEEXEC
52641 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52642 + pax_flags |= MF_PAX_PAGEEXEC;
52643 +#endif
52644 +
52645 +#ifdef CONFIG_PAX_SEGMEXEC
52646 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52647 + pax_flags |= MF_PAX_SEGMEXEC;
52648 +#endif
52649 +
52650 +#ifdef CONFIG_PAX_EMUTRAMP
52651 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52652 + pax_flags |= MF_PAX_EMUTRAMP;
52653 +#endif
52654 +
52655 +#ifdef CONFIG_PAX_MPROTECT
52656 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52657 + pax_flags |= MF_PAX_MPROTECT;
52658 +#endif
52659 +
52660 +#ifdef CONFIG_PAX_ASLR
52661 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52662 + pax_flags |= MF_PAX_RANDMMAP;
52663 +#endif
52664 +
52665 +#else
52666 +
52667 +#ifdef CONFIG_PAX_PAGEEXEC
52668 + pax_flags |= MF_PAX_PAGEEXEC;
52669 +#endif
52670 +
52671 +#ifdef CONFIG_PAX_SEGMEXEC
52672 + pax_flags |= MF_PAX_SEGMEXEC;
52673 +#endif
52674 +
52675 +#ifdef CONFIG_PAX_MPROTECT
52676 + pax_flags |= MF_PAX_MPROTECT;
52677 +#endif
52678 +
52679 +#ifdef CONFIG_PAX_RANDMMAP
52680 + if (randomize_va_space)
52681 + pax_flags |= MF_PAX_RANDMMAP;
52682 +#endif
52683 +
52684 +#endif
52685 +
52686 + return pax_flags;
52687 +}
52688 +
52689 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52690 +{
52691 +
52692 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52693 + unsigned long i;
52694 +
52695 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52696 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52697 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52698 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52699 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52700 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52701 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52702 + return ~0UL;
52703 +
52704 +#ifdef CONFIG_PAX_SOFTMODE
52705 + if (pax_softmode)
52706 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52707 + else
52708 +#endif
52709 +
52710 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52711 + break;
52712 + }
52713 +#endif
52714 +
52715 + return ~0UL;
52716 +}
52717 +
52718 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52719 +{
52720 +
52721 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52722 + ssize_t xattr_size, i;
52723 + unsigned char xattr_value[sizeof("pemrs") - 1];
52724 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52725 +
52726 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52727 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52728 + return ~0UL;
52729 +
52730 + for (i = 0; i < xattr_size; i++)
52731 + switch (xattr_value[i]) {
52732 + default:
52733 + return ~0UL;
52734 +
52735 +#define parse_flag(option1, option2, flag) \
52736 + case option1: \
52737 + if (pax_flags_hardmode & MF_PAX_##flag) \
52738 + return ~0UL; \
52739 + pax_flags_hardmode |= MF_PAX_##flag; \
52740 + break; \
52741 + case option2: \
52742 + if (pax_flags_softmode & MF_PAX_##flag) \
52743 + return ~0UL; \
52744 + pax_flags_softmode |= MF_PAX_##flag; \
52745 + break;
52746 +
52747 + parse_flag('p', 'P', PAGEEXEC);
52748 + parse_flag('e', 'E', EMUTRAMP);
52749 + parse_flag('m', 'M', MPROTECT);
52750 + parse_flag('r', 'R', RANDMMAP);
52751 + parse_flag('s', 'S', SEGMEXEC);
52752 +
52753 +#undef parse_flag
52754 + }
52755 +
52756 + if (pax_flags_hardmode & pax_flags_softmode)
52757 + return ~0UL;
52758 +
52759 +#ifdef CONFIG_PAX_SOFTMODE
52760 + if (pax_softmode)
52761 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52762 + else
52763 +#endif
52764 +
52765 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52766 +#else
52767 + return ~0UL;
52768 +#endif
52769 +
52770 +}
52771 +
52772 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52773 +{
52774 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52775 +
52776 + pax_flags = pax_parse_ei_pax(elf_ex);
52777 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52778 + xattr_pax_flags = pax_parse_xattr_pax(file);
52779 +
52780 + if (pt_pax_flags == ~0UL)
52781 + pt_pax_flags = xattr_pax_flags;
52782 + else if (xattr_pax_flags == ~0UL)
52783 + xattr_pax_flags = pt_pax_flags;
52784 + if (pt_pax_flags != xattr_pax_flags)
52785 + return -EINVAL;
52786 + if (pt_pax_flags != ~0UL)
52787 + pax_flags = pt_pax_flags;
52788 +
52789 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52790 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52791 + if ((__supported_pte_mask & _PAGE_NX))
52792 + pax_flags &= ~MF_PAX_SEGMEXEC;
52793 + else
52794 + pax_flags &= ~MF_PAX_PAGEEXEC;
52795 + }
52796 +#endif
52797 +
52798 + if (0 > pax_check_flags(&pax_flags))
52799 + return -EINVAL;
52800 +
52801 + current->mm->pax_flags = pax_flags;
52802 + return 0;
52803 +}
52804 +#endif
52805 +
52806 /*
52807 * These are the functions used to load ELF style executables and shared
52808 * libraries. There is no binary dependent code anywhere else.
52809 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52810 {
52811 unsigned int random_variable = 0;
52812
52813 +#ifdef CONFIG_PAX_RANDUSTACK
52814 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52815 + return stack_top - current->mm->delta_stack;
52816 +#endif
52817 +
52818 if ((current->flags & PF_RANDOMIZE) &&
52819 !(current->personality & ADDR_NO_RANDOMIZE)) {
52820 random_variable = get_random_int() & STACK_RND_MASK;
52821 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52822 unsigned long load_addr = 0, load_bias = 0;
52823 int load_addr_set = 0;
52824 char * elf_interpreter = NULL;
52825 - unsigned long error;
52826 + unsigned long error = 0;
52827 struct elf_phdr *elf_ppnt, *elf_phdata;
52828 unsigned long elf_bss, elf_brk;
52829 int retval, i;
52830 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52831 unsigned long start_code, end_code, start_data, end_data;
52832 unsigned long reloc_func_desc __maybe_unused = 0;
52833 int executable_stack = EXSTACK_DEFAULT;
52834 - unsigned long def_flags = 0;
52835 struct pt_regs *regs = current_pt_regs();
52836 struct {
52837 struct elfhdr elf_ex;
52838 struct elfhdr interp_elf_ex;
52839 } *loc;
52840 + unsigned long pax_task_size = TASK_SIZE;
52841
52842 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52843 if (!loc) {
52844 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52845 goto out_free_dentry;
52846
52847 /* OK, This is the point of no return */
52848 - current->mm->def_flags = def_flags;
52849 +
52850 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52851 + current->mm->pax_flags = 0UL;
52852 +#endif
52853 +
52854 +#ifdef CONFIG_PAX_DLRESOLVE
52855 + current->mm->call_dl_resolve = 0UL;
52856 +#endif
52857 +
52858 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52859 + current->mm->call_syscall = 0UL;
52860 +#endif
52861 +
52862 +#ifdef CONFIG_PAX_ASLR
52863 + current->mm->delta_mmap = 0UL;
52864 + current->mm->delta_stack = 0UL;
52865 +#endif
52866 +
52867 + current->mm->def_flags = 0;
52868 +
52869 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52870 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52871 + send_sig(SIGKILL, current, 0);
52872 + goto out_free_dentry;
52873 + }
52874 +#endif
52875 +
52876 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52877 + pax_set_initial_flags(bprm);
52878 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52879 + if (pax_set_initial_flags_func)
52880 + (pax_set_initial_flags_func)(bprm);
52881 +#endif
52882 +
52883 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52884 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52885 + current->mm->context.user_cs_limit = PAGE_SIZE;
52886 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52887 + }
52888 +#endif
52889 +
52890 +#ifdef CONFIG_PAX_SEGMEXEC
52891 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52892 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52893 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52894 + pax_task_size = SEGMEXEC_TASK_SIZE;
52895 + current->mm->def_flags |= VM_NOHUGEPAGE;
52896 + }
52897 +#endif
52898 +
52899 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52900 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52901 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52902 + put_cpu();
52903 + }
52904 +#endif
52905
52906 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52907 may depend on the personality. */
52908 SET_PERSONALITY(loc->elf_ex);
52909 +
52910 +#ifdef CONFIG_PAX_ASLR
52911 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52912 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52913 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52914 + }
52915 +#endif
52916 +
52917 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52918 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52919 + executable_stack = EXSTACK_DISABLE_X;
52920 + current->personality &= ~READ_IMPLIES_EXEC;
52921 + } else
52922 +#endif
52923 +
52924 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
52925 current->personality |= READ_IMPLIES_EXEC;
52926
52927 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
52928 #else
52929 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
52930 #endif
52931 +
52932 +#ifdef CONFIG_PAX_RANDMMAP
52933 + /* PaX: randomize base address at the default exe base if requested */
52934 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
52935 +#ifdef CONFIG_SPARC64
52936 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
52937 +#else
52938 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
52939 +#endif
52940 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
52941 + elf_flags |= MAP_FIXED;
52942 + }
52943 +#endif
52944 +
52945 }
52946
52947 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
52948 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
52949 * allowed task size. Note that p_filesz must always be
52950 * <= p_memsz so it is only necessary to check p_memsz.
52951 */
52952 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52953 - elf_ppnt->p_memsz > TASK_SIZE ||
52954 - TASK_SIZE - elf_ppnt->p_memsz < k) {
52955 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52956 + elf_ppnt->p_memsz > pax_task_size ||
52957 + pax_task_size - elf_ppnt->p_memsz < k) {
52958 /* set_brk can never work. Avoid overflows. */
52959 send_sig(SIGKILL, current, 0);
52960 retval = -EINVAL;
52961 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
52962 goto out_free_dentry;
52963 }
52964 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
52965 - send_sig(SIGSEGV, current, 0);
52966 - retval = -EFAULT; /* Nobody gets to see this, but.. */
52967 - goto out_free_dentry;
52968 + /*
52969 + * This bss-zeroing can fail if the ELF
52970 + * file specifies odd protections. So
52971 + * we don't check the return value
52972 + */
52973 }
52974
52975 +#ifdef CONFIG_PAX_RANDMMAP
52976 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52977 + unsigned long start, size, flags;
52978 + vm_flags_t vm_flags;
52979 +
52980 + start = ELF_PAGEALIGN(elf_brk);
52981 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
52982 + flags = MAP_FIXED | MAP_PRIVATE;
52983 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
52984 +
52985 + down_write(&current->mm->mmap_sem);
52986 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
52987 + retval = -ENOMEM;
52988 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
52989 +// if (current->personality & ADDR_NO_RANDOMIZE)
52990 +// vm_flags |= VM_READ | VM_MAYREAD;
52991 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
52992 + retval = IS_ERR_VALUE(start) ? start : 0;
52993 + }
52994 + up_write(&current->mm->mmap_sem);
52995 + if (retval == 0)
52996 + retval = set_brk(start + size, start + size + PAGE_SIZE);
52997 + if (retval < 0) {
52998 + send_sig(SIGKILL, current, 0);
52999 + goto out_free_dentry;
53000 + }
53001 + }
53002 +#endif
53003 +
53004 if (elf_interpreter) {
53005 - unsigned long interp_map_addr = 0;
53006 -
53007 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53008 interpreter,
53009 - &interp_map_addr,
53010 load_bias);
53011 if (!IS_ERR((void *)elf_entry)) {
53012 /*
53013 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53014 * Decide what to dump of a segment, part, all or none.
53015 */
53016 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53017 - unsigned long mm_flags)
53018 + unsigned long mm_flags, long signr)
53019 {
53020 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53021
53022 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53023 if (vma->vm_file == NULL)
53024 return 0;
53025
53026 - if (FILTER(MAPPED_PRIVATE))
53027 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53028 goto whole;
53029
53030 /*
53031 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53032 {
53033 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53034 int i = 0;
53035 - do
53036 + do {
53037 i += 2;
53038 - while (auxv[i - 2] != AT_NULL);
53039 + } while (auxv[i - 2] != AT_NULL);
53040 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53041 }
53042
53043 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53044 {
53045 mm_segment_t old_fs = get_fs();
53046 set_fs(KERNEL_DS);
53047 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53048 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53049 set_fs(old_fs);
53050 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53051 }
53052 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53053 }
53054
53055 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53056 - unsigned long mm_flags)
53057 + struct coredump_params *cprm)
53058 {
53059 struct vm_area_struct *vma;
53060 size_t size = 0;
53061
53062 for (vma = first_vma(current, gate_vma); vma != NULL;
53063 vma = next_vma(vma, gate_vma))
53064 - size += vma_dump_size(vma, mm_flags);
53065 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53066 return size;
53067 }
53068
53069 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53070
53071 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53072
53073 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53074 + offset += elf_core_vma_data_size(gate_vma, cprm);
53075 offset += elf_core_extra_data_size();
53076 e_shoff = offset;
53077
53078 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53079 offset = dataoff;
53080
53081 size += sizeof(*elf);
53082 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53083 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53084 goto end_coredump;
53085
53086 size += sizeof(*phdr4note);
53087 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53088 if (size > cprm->limit
53089 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53090 goto end_coredump;
53091 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53092 phdr.p_offset = offset;
53093 phdr.p_vaddr = vma->vm_start;
53094 phdr.p_paddr = 0;
53095 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53096 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53097 phdr.p_memsz = vma->vm_end - vma->vm_start;
53098 offset += phdr.p_filesz;
53099 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53100 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53101 phdr.p_align = ELF_EXEC_PAGESIZE;
53102
53103 size += sizeof(phdr);
53104 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53105 if (size > cprm->limit
53106 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53107 goto end_coredump;
53108 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53109 unsigned long addr;
53110 unsigned long end;
53111
53112 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53113 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53114
53115 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53116 struct page *page;
53117 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53118 page = get_dump_page(addr);
53119 if (page) {
53120 void *kaddr = kmap(page);
53121 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53122 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53123 !dump_write(cprm->file, kaddr,
53124 PAGE_SIZE);
53125 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53126
53127 if (e_phnum == PN_XNUM) {
53128 size += sizeof(*shdr4extnum);
53129 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53130 if (size > cprm->limit
53131 || !dump_write(cprm->file, shdr4extnum,
53132 sizeof(*shdr4extnum)))
53133 @@ -2235,6 +2697,167 @@ out:
53134
53135 #endif /* CONFIG_ELF_CORE */
53136
53137 +#ifdef CONFIG_PAX_MPROTECT
53138 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53139 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53140 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53141 + *
53142 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53143 + * basis because we want to allow the common case and not the special ones.
53144 + */
53145 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53146 +{
53147 + struct elfhdr elf_h;
53148 + struct elf_phdr elf_p;
53149 + unsigned long i;
53150 + unsigned long oldflags;
53151 + bool is_textrel_rw, is_textrel_rx, is_relro;
53152 +
53153 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53154 + return;
53155 +
53156 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53157 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53158 +
53159 +#ifdef CONFIG_PAX_ELFRELOCS
53160 + /* possible TEXTREL */
53161 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53162 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53163 +#else
53164 + is_textrel_rw = false;
53165 + is_textrel_rx = false;
53166 +#endif
53167 +
53168 + /* possible RELRO */
53169 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53170 +
53171 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53172 + return;
53173 +
53174 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53175 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53176 +
53177 +#ifdef CONFIG_PAX_ETEXECRELOCS
53178 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53179 +#else
53180 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53181 +#endif
53182 +
53183 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53184 + !elf_check_arch(&elf_h) ||
53185 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53186 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53187 + return;
53188 +
53189 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53190 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53191 + return;
53192 + switch (elf_p.p_type) {
53193 + case PT_DYNAMIC:
53194 + if (!is_textrel_rw && !is_textrel_rx)
53195 + continue;
53196 + i = 0UL;
53197 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53198 + elf_dyn dyn;
53199 +
53200 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53201 + break;
53202 + if (dyn.d_tag == DT_NULL)
53203 + break;
53204 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53205 + gr_log_textrel(vma);
53206 + if (is_textrel_rw)
53207 + vma->vm_flags |= VM_MAYWRITE;
53208 + else
53209 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53210 + vma->vm_flags &= ~VM_MAYWRITE;
53211 + break;
53212 + }
53213 + i++;
53214 + }
53215 + is_textrel_rw = false;
53216 + is_textrel_rx = false;
53217 + continue;
53218 +
53219 + case PT_GNU_RELRO:
53220 + if (!is_relro)
53221 + continue;
53222 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53223 + vma->vm_flags &= ~VM_MAYWRITE;
53224 + is_relro = false;
53225 + continue;
53226 +
53227 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53228 + case PT_PAX_FLAGS: {
53229 + const char *msg_mprotect = "", *msg_emutramp = "";
53230 + char *buffer_lib, *buffer_exe;
53231 +
53232 + if (elf_p.p_flags & PF_NOMPROTECT)
53233 + msg_mprotect = "MPROTECT disabled";
53234 +
53235 +#ifdef CONFIG_PAX_EMUTRAMP
53236 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53237 + msg_emutramp = "EMUTRAMP enabled";
53238 +#endif
53239 +
53240 + if (!msg_mprotect[0] && !msg_emutramp[0])
53241 + continue;
53242 +
53243 + if (!printk_ratelimit())
53244 + continue;
53245 +
53246 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53247 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53248 + if (buffer_lib && buffer_exe) {
53249 + char *path_lib, *path_exe;
53250 +
53251 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53252 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53253 +
53254 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53255 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53256 +
53257 + }
53258 + free_page((unsigned long)buffer_exe);
53259 + free_page((unsigned long)buffer_lib);
53260 + continue;
53261 + }
53262 +#endif
53263 +
53264 + }
53265 + }
53266 +}
53267 +#endif
53268 +
53269 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53270 +
53271 +extern int grsec_enable_log_rwxmaps;
53272 +
53273 +static void elf_handle_mmap(struct file *file)
53274 +{
53275 + struct elfhdr elf_h;
53276 + struct elf_phdr elf_p;
53277 + unsigned long i;
53278 +
53279 + if (!grsec_enable_log_rwxmaps)
53280 + return;
53281 +
53282 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53283 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53284 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53285 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53286 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53287 + return;
53288 +
53289 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53290 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53291 + return;
53292 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53293 + gr_log_ptgnustack(file);
53294 + }
53295 +}
53296 +#endif
53297 +
53298 static int __init init_elf_binfmt(void)
53299 {
53300 register_binfmt(&elf_format);
53301 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53302 index d50bbe5..af3b649 100644
53303 --- a/fs/binfmt_flat.c
53304 +++ b/fs/binfmt_flat.c
53305 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53306 realdatastart = (unsigned long) -ENOMEM;
53307 printk("Unable to allocate RAM for process data, errno %d\n",
53308 (int)-realdatastart);
53309 + down_write(&current->mm->mmap_sem);
53310 vm_munmap(textpos, text_len);
53311 + up_write(&current->mm->mmap_sem);
53312 ret = realdatastart;
53313 goto err;
53314 }
53315 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53316 }
53317 if (IS_ERR_VALUE(result)) {
53318 printk("Unable to read data+bss, errno %d\n", (int)-result);
53319 + down_write(&current->mm->mmap_sem);
53320 vm_munmap(textpos, text_len);
53321 vm_munmap(realdatastart, len);
53322 + up_write(&current->mm->mmap_sem);
53323 ret = result;
53324 goto err;
53325 }
53326 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53327 }
53328 if (IS_ERR_VALUE(result)) {
53329 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53330 + down_write(&current->mm->mmap_sem);
53331 vm_munmap(textpos, text_len + data_len + extra +
53332 MAX_SHARED_LIBS * sizeof(unsigned long));
53333 + up_write(&current->mm->mmap_sem);
53334 ret = result;
53335 goto err;
53336 }
53337 diff --git a/fs/bio.c b/fs/bio.c
53338 index 5e7507d..418c639 100644
53339 --- a/fs/bio.c
53340 +++ b/fs/bio.c
53341 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53342 /*
53343 * Overflow, abort
53344 */
53345 - if (end < start)
53346 + if (end < start || end - start > INT_MAX - nr_pages)
53347 return ERR_PTR(-EINVAL);
53348
53349 nr_pages += end - start;
53350 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53351 /*
53352 * Overflow, abort
53353 */
53354 - if (end < start)
53355 + if (end < start || end - start > INT_MAX - nr_pages)
53356 return ERR_PTR(-EINVAL);
53357
53358 nr_pages += end - start;
53359 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53360 const int read = bio_data_dir(bio) == READ;
53361 struct bio_map_data *bmd = bio->bi_private;
53362 int i;
53363 - char *p = bmd->sgvecs[0].iov_base;
53364 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53365
53366 bio_for_each_segment_all(bvec, bio, i) {
53367 char *addr = page_address(bvec->bv_page);
53368 diff --git a/fs/block_dev.c b/fs/block_dev.c
53369 index c7bda5c..2121e94 100644
53370 --- a/fs/block_dev.c
53371 +++ b/fs/block_dev.c
53372 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53373 else if (bdev->bd_contains == bdev)
53374 return true; /* is a whole device which isn't held */
53375
53376 - else if (whole->bd_holder == bd_may_claim)
53377 + else if (whole->bd_holder == (void *)bd_may_claim)
53378 return true; /* is a partition of a device that is being partitioned */
53379 else if (whole->bd_holder != NULL)
53380 return false; /* is a partition of a held device */
53381 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53382 index ed50460..fe84385 100644
53383 --- a/fs/btrfs/ctree.c
53384 +++ b/fs/btrfs/ctree.c
53385 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53386 free_extent_buffer(buf);
53387 add_root_to_dirty_list(root);
53388 } else {
53389 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53390 - parent_start = parent->start;
53391 - else
53392 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53393 + if (parent)
53394 + parent_start = parent->start;
53395 + else
53396 + parent_start = 0;
53397 + } else
53398 parent_start = 0;
53399
53400 WARN_ON(trans->transid != btrfs_header_generation(parent));
53401 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53402 index 3755109..e3d457f 100644
53403 --- a/fs/btrfs/delayed-inode.c
53404 +++ b/fs/btrfs/delayed-inode.c
53405 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53406
53407 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53408 {
53409 - int seq = atomic_inc_return(&delayed_root->items_seq);
53410 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53411 if ((atomic_dec_return(&delayed_root->items) <
53412 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53413 waitqueue_active(&delayed_root->wait))
53414 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53415 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53416 int seq, int count)
53417 {
53418 - int val = atomic_read(&delayed_root->items_seq);
53419 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53420
53421 if (val < seq || val >= seq + count)
53422 return 1;
53423 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53424 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53425 return;
53426
53427 - seq = atomic_read(&delayed_root->items_seq);
53428 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53429
53430 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53431 int ret;
53432 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53433 index a4b38f9..f86a509 100644
53434 --- a/fs/btrfs/delayed-inode.h
53435 +++ b/fs/btrfs/delayed-inode.h
53436 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53437 */
53438 struct list_head prepare_list;
53439 atomic_t items; /* for delayed items */
53440 - atomic_t items_seq; /* for delayed items */
53441 + atomic_unchecked_t items_seq; /* for delayed items */
53442 int nodes; /* for delayed nodes */
53443 wait_queue_head_t wait;
53444 };
53445 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53446 struct btrfs_delayed_root *delayed_root)
53447 {
53448 atomic_set(&delayed_root->items, 0);
53449 - atomic_set(&delayed_root->items_seq, 0);
53450 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53451 delayed_root->nodes = 0;
53452 spin_lock_init(&delayed_root->lock);
53453 init_waitqueue_head(&delayed_root->wait);
53454 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53455 index 9877a2a..7ebf9ab 100644
53456 --- a/fs/btrfs/ioctl.c
53457 +++ b/fs/btrfs/ioctl.c
53458 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53459 for (i = 0; i < num_types; i++) {
53460 struct btrfs_space_info *tmp;
53461
53462 + /* Don't copy in more than we allocated */
53463 if (!slot_count)
53464 break;
53465
53466 + slot_count--;
53467 +
53468 info = NULL;
53469 rcu_read_lock();
53470 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53471 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53472 memcpy(dest, &space, sizeof(space));
53473 dest++;
53474 space_args.total_spaces++;
53475 - slot_count--;
53476 }
53477 - if (!slot_count)
53478 - break;
53479 }
53480 up_read(&info->groups_sem);
53481 }
53482 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53483 index 8eb6191..eda91e2 100644
53484 --- a/fs/btrfs/super.c
53485 +++ b/fs/btrfs/super.c
53486 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53487 function, line, errstr);
53488 return;
53489 }
53490 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53491 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53492 /* Wake up anybody who may be waiting on this transaction */
53493 wake_up(&root->fs_info->transaction_wait);
53494 wake_up(&root->fs_info->transaction_blocked_wait);
53495 diff --git a/fs/buffer.c b/fs/buffer.c
53496 index 4d74335..7bd000a 100644
53497 --- a/fs/buffer.c
53498 +++ b/fs/buffer.c
53499 @@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block,
53500 struct buffer_head *bh;
53501 sector_t end_block;
53502 int ret = 0; /* Will call free_more_memory() */
53503 + gfp_t gfp_mask;
53504
53505 - page = find_or_create_page(inode->i_mapping, index,
53506 - (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
53507 + gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS;
53508 + gfp_mask |= __GFP_MOVABLE;
53509 + /*
53510 + * XXX: __getblk_slow() can not really deal with failure and
53511 + * will endlessly loop on improvised global reclaim. Prefer
53512 + * looping in the allocator rather than here, at least that
53513 + * code knows what it's doing.
53514 + */
53515 + gfp_mask |= __GFP_NOFAIL;
53516 +
53517 + page = find_or_create_page(inode->i_mapping, index, gfp_mask);
53518 if (!page)
53519 return ret;
53520
53521 @@ -3416,7 +3426,7 @@ void __init buffer_init(void)
53522 bh_cachep = kmem_cache_create("buffer_head",
53523 sizeof(struct buffer_head), 0,
53524 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53525 - SLAB_MEM_SPREAD),
53526 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53527 NULL);
53528
53529 /*
53530 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53531 index 622f469..e8d2d55 100644
53532 --- a/fs/cachefiles/bind.c
53533 +++ b/fs/cachefiles/bind.c
53534 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53535 args);
53536
53537 /* start by checking things over */
53538 - ASSERT(cache->fstop_percent >= 0 &&
53539 - cache->fstop_percent < cache->fcull_percent &&
53540 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53541 cache->fcull_percent < cache->frun_percent &&
53542 cache->frun_percent < 100);
53543
53544 - ASSERT(cache->bstop_percent >= 0 &&
53545 - cache->bstop_percent < cache->bcull_percent &&
53546 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53547 cache->bcull_percent < cache->brun_percent &&
53548 cache->brun_percent < 100);
53549
53550 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53551 index 0a1467b..6a53245 100644
53552 --- a/fs/cachefiles/daemon.c
53553 +++ b/fs/cachefiles/daemon.c
53554 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53555 if (n > buflen)
53556 return -EMSGSIZE;
53557
53558 - if (copy_to_user(_buffer, buffer, n) != 0)
53559 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53560 return -EFAULT;
53561
53562 return n;
53563 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53564 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53565 return -EIO;
53566
53567 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53568 + if (datalen > PAGE_SIZE - 1)
53569 return -EOPNOTSUPP;
53570
53571 /* drag the command string into the kernel so we can parse it */
53572 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53573 if (args[0] != '%' || args[1] != '\0')
53574 return -EINVAL;
53575
53576 - if (fstop < 0 || fstop >= cache->fcull_percent)
53577 + if (fstop >= cache->fcull_percent)
53578 return cachefiles_daemon_range_error(cache, args);
53579
53580 cache->fstop_percent = fstop;
53581 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53582 if (args[0] != '%' || args[1] != '\0')
53583 return -EINVAL;
53584
53585 - if (bstop < 0 || bstop >= cache->bcull_percent)
53586 + if (bstop >= cache->bcull_percent)
53587 return cachefiles_daemon_range_error(cache, args);
53588
53589 cache->bstop_percent = bstop;
53590 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53591 index 4938251..7e01445 100644
53592 --- a/fs/cachefiles/internal.h
53593 +++ b/fs/cachefiles/internal.h
53594 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53595 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53596 struct rb_root active_nodes; /* active nodes (can't be culled) */
53597 rwlock_t active_lock; /* lock for active_nodes */
53598 - atomic_t gravecounter; /* graveyard uniquifier */
53599 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53600 unsigned frun_percent; /* when to stop culling (% files) */
53601 unsigned fcull_percent; /* when to start culling (% files) */
53602 unsigned fstop_percent; /* when to stop allocating (% files) */
53603 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53604 * proc.c
53605 */
53606 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53607 -extern atomic_t cachefiles_lookup_histogram[HZ];
53608 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53609 -extern atomic_t cachefiles_create_histogram[HZ];
53610 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53611 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53612 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53613
53614 extern int __init cachefiles_proc_init(void);
53615 extern void cachefiles_proc_cleanup(void);
53616 static inline
53617 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53618 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53619 {
53620 unsigned long jif = jiffies - start_jif;
53621 if (jif >= HZ)
53622 jif = HZ - 1;
53623 - atomic_inc(&histogram[jif]);
53624 + atomic_inc_unchecked(&histogram[jif]);
53625 }
53626
53627 #else
53628 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53629 index 25badd1..d70d918 100644
53630 --- a/fs/cachefiles/namei.c
53631 +++ b/fs/cachefiles/namei.c
53632 @@ -317,7 +317,7 @@ try_again:
53633 /* first step is to make up a grave dentry in the graveyard */
53634 sprintf(nbuffer, "%08x%08x",
53635 (uint32_t) get_seconds(),
53636 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53637 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53638
53639 /* do the multiway lock magic */
53640 trap = lock_rename(cache->graveyard, dir);
53641 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53642 index eccd339..4c1d995 100644
53643 --- a/fs/cachefiles/proc.c
53644 +++ b/fs/cachefiles/proc.c
53645 @@ -14,9 +14,9 @@
53646 #include <linux/seq_file.h>
53647 #include "internal.h"
53648
53649 -atomic_t cachefiles_lookup_histogram[HZ];
53650 -atomic_t cachefiles_mkdir_histogram[HZ];
53651 -atomic_t cachefiles_create_histogram[HZ];
53652 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53653 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53654 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53655
53656 /*
53657 * display the latency histogram
53658 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53659 return 0;
53660 default:
53661 index = (unsigned long) v - 3;
53662 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53663 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53664 - z = atomic_read(&cachefiles_create_histogram[index]);
53665 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53666 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53667 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53668 if (x == 0 && y == 0 && z == 0)
53669 return 0;
53670
53671 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53672 index ebaff36..7e3ea26 100644
53673 --- a/fs/cachefiles/rdwr.c
53674 +++ b/fs/cachefiles/rdwr.c
53675 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53676 old_fs = get_fs();
53677 set_fs(KERNEL_DS);
53678 ret = file->f_op->write(
53679 - file, (const void __user *) data, len, &pos);
53680 + file, (const void __force_user *) data, len, &pos);
53681 set_fs(old_fs);
53682 kunmap(page);
53683 file_end_write(file);
53684 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53685 index a40ceda..f43d17c 100644
53686 --- a/fs/ceph/dir.c
53687 +++ b/fs/ceph/dir.c
53688 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53689 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53690 struct ceph_mds_client *mdsc = fsc->mdsc;
53691 unsigned frag = fpos_frag(ctx->pos);
53692 - int off = fpos_off(ctx->pos);
53693 + unsigned int off = fpos_off(ctx->pos);
53694 int err;
53695 u32 ftype;
53696 struct ceph_mds_reply_info_parsed *rinfo;
53697 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53698 index 6627b26..634ec4b 100644
53699 --- a/fs/ceph/super.c
53700 +++ b/fs/ceph/super.c
53701 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53702 /*
53703 * construct our own bdi so we can control readahead, etc.
53704 */
53705 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53706 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53707
53708 static int ceph_register_bdi(struct super_block *sb,
53709 struct ceph_fs_client *fsc)
53710 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53711 default_backing_dev_info.ra_pages;
53712
53713 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53714 - atomic_long_inc_return(&bdi_seq));
53715 + atomic_long_inc_return_unchecked(&bdi_seq));
53716 if (!err)
53717 sb->s_bdi = &fsc->backing_dev_info;
53718 return err;
53719 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53720 index f3ac415..3d2420c 100644
53721 --- a/fs/cifs/cifs_debug.c
53722 +++ b/fs/cifs/cifs_debug.c
53723 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53724
53725 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53726 #ifdef CONFIG_CIFS_STATS2
53727 - atomic_set(&totBufAllocCount, 0);
53728 - atomic_set(&totSmBufAllocCount, 0);
53729 + atomic_set_unchecked(&totBufAllocCount, 0);
53730 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53731 #endif /* CONFIG_CIFS_STATS2 */
53732 spin_lock(&cifs_tcp_ses_lock);
53733 list_for_each(tmp1, &cifs_tcp_ses_list) {
53734 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53735 tcon = list_entry(tmp3,
53736 struct cifs_tcon,
53737 tcon_list);
53738 - atomic_set(&tcon->num_smbs_sent, 0);
53739 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53740 if (server->ops->clear_stats)
53741 server->ops->clear_stats(tcon);
53742 }
53743 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53744 smBufAllocCount.counter, cifs_min_small);
53745 #ifdef CONFIG_CIFS_STATS2
53746 seq_printf(m, "Total Large %d Small %d Allocations\n",
53747 - atomic_read(&totBufAllocCount),
53748 - atomic_read(&totSmBufAllocCount));
53749 + atomic_read_unchecked(&totBufAllocCount),
53750 + atomic_read_unchecked(&totSmBufAllocCount));
53751 #endif /* CONFIG_CIFS_STATS2 */
53752
53753 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53754 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53755 if (tcon->need_reconnect)
53756 seq_puts(m, "\tDISCONNECTED ");
53757 seq_printf(m, "\nSMBs: %d",
53758 - atomic_read(&tcon->num_smbs_sent));
53759 + atomic_read_unchecked(&tcon->num_smbs_sent));
53760 if (server->ops->print_stats)
53761 server->ops->print_stats(m, tcon);
53762 }
53763 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53764 index 40cfef5..1eee040 100644
53765 --- a/fs/cifs/cifsfs.c
53766 +++ b/fs/cifs/cifsfs.c
53767 @@ -1039,7 +1039,7 @@ cifs_init_request_bufs(void)
53768 */
53769 cifs_req_cachep = kmem_cache_create("cifs_request",
53770 CIFSMaxBufSize + max_hdr_size, 0,
53771 - SLAB_HWCACHE_ALIGN, NULL);
53772 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53773 if (cifs_req_cachep == NULL)
53774 return -ENOMEM;
53775
53776 @@ -1066,7 +1066,7 @@ cifs_init_request_bufs(void)
53777 efficient to alloc 1 per page off the slab compared to 17K (5page)
53778 alloc of large cifs buffers even when page debugging is on */
53779 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53780 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53781 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53782 NULL);
53783 if (cifs_sm_req_cachep == NULL) {
53784 mempool_destroy(cifs_req_poolp);
53785 @@ -1151,8 +1151,8 @@ init_cifs(void)
53786 atomic_set(&bufAllocCount, 0);
53787 atomic_set(&smBufAllocCount, 0);
53788 #ifdef CONFIG_CIFS_STATS2
53789 - atomic_set(&totBufAllocCount, 0);
53790 - atomic_set(&totSmBufAllocCount, 0);
53791 + atomic_set_unchecked(&totBufAllocCount, 0);
53792 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53793 #endif /* CONFIG_CIFS_STATS2 */
53794
53795 atomic_set(&midCount, 0);
53796 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53797 index 52ca861..47f309c 100644
53798 --- a/fs/cifs/cifsglob.h
53799 +++ b/fs/cifs/cifsglob.h
53800 @@ -756,35 +756,35 @@ struct cifs_tcon {
53801 __u16 Flags; /* optional support bits */
53802 enum statusEnum tidStatus;
53803 #ifdef CONFIG_CIFS_STATS
53804 - atomic_t num_smbs_sent;
53805 + atomic_unchecked_t num_smbs_sent;
53806 union {
53807 struct {
53808 - atomic_t num_writes;
53809 - atomic_t num_reads;
53810 - atomic_t num_flushes;
53811 - atomic_t num_oplock_brks;
53812 - atomic_t num_opens;
53813 - atomic_t num_closes;
53814 - atomic_t num_deletes;
53815 - atomic_t num_mkdirs;
53816 - atomic_t num_posixopens;
53817 - atomic_t num_posixmkdirs;
53818 - atomic_t num_rmdirs;
53819 - atomic_t num_renames;
53820 - atomic_t num_t2renames;
53821 - atomic_t num_ffirst;
53822 - atomic_t num_fnext;
53823 - atomic_t num_fclose;
53824 - atomic_t num_hardlinks;
53825 - atomic_t num_symlinks;
53826 - atomic_t num_locks;
53827 - atomic_t num_acl_get;
53828 - atomic_t num_acl_set;
53829 + atomic_unchecked_t num_writes;
53830 + atomic_unchecked_t num_reads;
53831 + atomic_unchecked_t num_flushes;
53832 + atomic_unchecked_t num_oplock_brks;
53833 + atomic_unchecked_t num_opens;
53834 + atomic_unchecked_t num_closes;
53835 + atomic_unchecked_t num_deletes;
53836 + atomic_unchecked_t num_mkdirs;
53837 + atomic_unchecked_t num_posixopens;
53838 + atomic_unchecked_t num_posixmkdirs;
53839 + atomic_unchecked_t num_rmdirs;
53840 + atomic_unchecked_t num_renames;
53841 + atomic_unchecked_t num_t2renames;
53842 + atomic_unchecked_t num_ffirst;
53843 + atomic_unchecked_t num_fnext;
53844 + atomic_unchecked_t num_fclose;
53845 + atomic_unchecked_t num_hardlinks;
53846 + atomic_unchecked_t num_symlinks;
53847 + atomic_unchecked_t num_locks;
53848 + atomic_unchecked_t num_acl_get;
53849 + atomic_unchecked_t num_acl_set;
53850 } cifs_stats;
53851 #ifdef CONFIG_CIFS_SMB2
53852 struct {
53853 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53854 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53855 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53856 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53857 } smb2_stats;
53858 #endif /* CONFIG_CIFS_SMB2 */
53859 } stats;
53860 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53861 }
53862
53863 #ifdef CONFIG_CIFS_STATS
53864 -#define cifs_stats_inc atomic_inc
53865 +#define cifs_stats_inc atomic_inc_unchecked
53866
53867 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53868 unsigned int bytes)
53869 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53870 /* Various Debug counters */
53871 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53872 #ifdef CONFIG_CIFS_STATS2
53873 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53874 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53875 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53876 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53877 #endif
53878 GLOBAL_EXTERN atomic_t smBufAllocCount;
53879 GLOBAL_EXTERN atomic_t midCount;
53880 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53881 index 562044f..4af6a17 100644
53882 --- a/fs/cifs/link.c
53883 +++ b/fs/cifs/link.c
53884 @@ -638,7 +638,7 @@ symlink_exit:
53885
53886 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53887 {
53888 - char *p = nd_get_link(nd);
53889 + const char *p = nd_get_link(nd);
53890 if (!IS_ERR(p))
53891 kfree(p);
53892 }
53893 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53894 index f7d4b22..1254377 100644
53895 --- a/fs/cifs/misc.c
53896 +++ b/fs/cifs/misc.c
53897 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53898 memset(ret_buf, 0, buf_size + 3);
53899 atomic_inc(&bufAllocCount);
53900 #ifdef CONFIG_CIFS_STATS2
53901 - atomic_inc(&totBufAllocCount);
53902 + atomic_inc_unchecked(&totBufAllocCount);
53903 #endif /* CONFIG_CIFS_STATS2 */
53904 }
53905
53906 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53907 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53908 atomic_inc(&smBufAllocCount);
53909 #ifdef CONFIG_CIFS_STATS2
53910 - atomic_inc(&totSmBufAllocCount);
53911 + atomic_inc_unchecked(&totSmBufAllocCount);
53912 #endif /* CONFIG_CIFS_STATS2 */
53913
53914 }
53915 diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
53916 index af847e1..651a527 100644
53917 --- a/fs/cifs/netmisc.c
53918 +++ b/fs/cifs/netmisc.c
53919 @@ -780,7 +780,9 @@ static const struct {
53920 ERRDOS, ERRnoaccess, 0xc0000290}, {
53921 ERRDOS, ERRbadfunc, 0xc000029c}, {
53922 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
53923 - ERRDOS, ERRinvlevel, 0x007c0001}, };
53924 + ERRDOS, ERRinvlevel, 0x007c0001}, {
53925 + 0, 0, 0 }
53926 +};
53927
53928 /*****************************************************************************
53929 Print an error message from the status code
53930 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53931 index 6094397..51e576f 100644
53932 --- a/fs/cifs/smb1ops.c
53933 +++ b/fs/cifs/smb1ops.c
53934 @@ -590,27 +590,27 @@ static void
53935 cifs_clear_stats(struct cifs_tcon *tcon)
53936 {
53937 #ifdef CONFIG_CIFS_STATS
53938 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53939 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53940 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53941 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53942 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53943 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53944 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53945 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53946 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53947 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53948 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
53949 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
53950 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
53951 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
53952 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
53953 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
53954 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
53955 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
53956 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
53957 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
53958 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
53959 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
53960 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
53961 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
53962 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53963 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
53964 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
53965 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53966 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
53967 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
53968 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
53969 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
53970 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
53971 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
53972 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
53973 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
53974 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
53975 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
53976 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
53977 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
53978 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
53979 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
53980 #endif
53981 }
53982
53983 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53984 {
53985 #ifdef CONFIG_CIFS_STATS
53986 seq_printf(m, " Oplocks breaks: %d",
53987 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
53988 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
53989 seq_printf(m, "\nReads: %d Bytes: %llu",
53990 - atomic_read(&tcon->stats.cifs_stats.num_reads),
53991 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
53992 (long long)(tcon->bytes_read));
53993 seq_printf(m, "\nWrites: %d Bytes: %llu",
53994 - atomic_read(&tcon->stats.cifs_stats.num_writes),
53995 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
53996 (long long)(tcon->bytes_written));
53997 seq_printf(m, "\nFlushes: %d",
53998 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
53999 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54000 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54001 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54002 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54003 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54004 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54005 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54006 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54007 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54008 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54009 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54010 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54011 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54012 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54013 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54014 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54015 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54016 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54017 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54018 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54019 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54020 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54021 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54022 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54023 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54024 seq_printf(m, "\nRenames: %d T2 Renames %d",
54025 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54026 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54027 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54028 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54029 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54030 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54031 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54032 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54033 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54034 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54035 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54036 #endif
54037 }
54038
54039 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54040 index f259e6c..ca948ff 100644
54041 --- a/fs/cifs/smb2ops.c
54042 +++ b/fs/cifs/smb2ops.c
54043 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54044 #ifdef CONFIG_CIFS_STATS
54045 int i;
54046 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54047 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54048 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54049 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54050 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54051 }
54052 #endif
54053 }
54054 @@ -310,65 +310,65 @@ static void
54055 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54056 {
54057 #ifdef CONFIG_CIFS_STATS
54058 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54059 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54060 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54061 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54062 seq_printf(m, "\nNegotiates: %d sent %d failed",
54063 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54064 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54065 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54066 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54067 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54068 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54069 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54070 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54071 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54072 seq_printf(m, "\nLogoffs: %d sent %d failed",
54073 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54074 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54075 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54076 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54077 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54078 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54079 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54080 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54081 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54082 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54083 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54084 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54085 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54086 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54087 seq_printf(m, "\nCreates: %d sent %d failed",
54088 - atomic_read(&sent[SMB2_CREATE_HE]),
54089 - atomic_read(&failed[SMB2_CREATE_HE]));
54090 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54091 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54092 seq_printf(m, "\nCloses: %d sent %d failed",
54093 - atomic_read(&sent[SMB2_CLOSE_HE]),
54094 - atomic_read(&failed[SMB2_CLOSE_HE]));
54095 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54096 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54097 seq_printf(m, "\nFlushes: %d sent %d failed",
54098 - atomic_read(&sent[SMB2_FLUSH_HE]),
54099 - atomic_read(&failed[SMB2_FLUSH_HE]));
54100 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54101 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54102 seq_printf(m, "\nReads: %d sent %d failed",
54103 - atomic_read(&sent[SMB2_READ_HE]),
54104 - atomic_read(&failed[SMB2_READ_HE]));
54105 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54106 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54107 seq_printf(m, "\nWrites: %d sent %d failed",
54108 - atomic_read(&sent[SMB2_WRITE_HE]),
54109 - atomic_read(&failed[SMB2_WRITE_HE]));
54110 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54111 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54112 seq_printf(m, "\nLocks: %d sent %d failed",
54113 - atomic_read(&sent[SMB2_LOCK_HE]),
54114 - atomic_read(&failed[SMB2_LOCK_HE]));
54115 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54116 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54117 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54118 - atomic_read(&sent[SMB2_IOCTL_HE]),
54119 - atomic_read(&failed[SMB2_IOCTL_HE]));
54120 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54121 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54122 seq_printf(m, "\nCancels: %d sent %d failed",
54123 - atomic_read(&sent[SMB2_CANCEL_HE]),
54124 - atomic_read(&failed[SMB2_CANCEL_HE]));
54125 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54126 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54127 seq_printf(m, "\nEchos: %d sent %d failed",
54128 - atomic_read(&sent[SMB2_ECHO_HE]),
54129 - atomic_read(&failed[SMB2_ECHO_HE]));
54130 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54131 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54132 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54133 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54134 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54135 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54136 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54137 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54138 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54139 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54140 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54141 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54142 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54143 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54144 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54145 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54146 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54147 seq_printf(m, "\nSetInfos: %d sent %d failed",
54148 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54149 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54150 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54151 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54152 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54153 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54154 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54155 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54156 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54157 #endif
54158 }
54159
54160 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54161 index abc9c28..3fdae28 100644
54162 --- a/fs/cifs/smb2pdu.c
54163 +++ b/fs/cifs/smb2pdu.c
54164 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54165 default:
54166 cifs_dbg(VFS, "info level %u isn't supported\n",
54167 srch_inf->info_level);
54168 - rc = -EINVAL;
54169 - goto qdir_exit;
54170 + return -EINVAL;
54171 }
54172
54173 req->FileIndex = cpu_to_le32(index);
54174 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54175 index 1da168c..8bc7ff6 100644
54176 --- a/fs/coda/cache.c
54177 +++ b/fs/coda/cache.c
54178 @@ -24,7 +24,7 @@
54179 #include "coda_linux.h"
54180 #include "coda_cache.h"
54181
54182 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54183 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54184
54185 /* replace or extend an acl cache hit */
54186 void coda_cache_enter(struct inode *inode, int mask)
54187 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54188 struct coda_inode_info *cii = ITOC(inode);
54189
54190 spin_lock(&cii->c_lock);
54191 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54192 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54193 if (!uid_eq(cii->c_uid, current_fsuid())) {
54194 cii->c_uid = current_fsuid();
54195 cii->c_cached_perm = mask;
54196 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54197 {
54198 struct coda_inode_info *cii = ITOC(inode);
54199 spin_lock(&cii->c_lock);
54200 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54201 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54202 spin_unlock(&cii->c_lock);
54203 }
54204
54205 /* remove all acl caches */
54206 void coda_cache_clear_all(struct super_block *sb)
54207 {
54208 - atomic_inc(&permission_epoch);
54209 + atomic_inc_unchecked(&permission_epoch);
54210 }
54211
54212
54213 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54214 spin_lock(&cii->c_lock);
54215 hit = (mask & cii->c_cached_perm) == mask &&
54216 uid_eq(cii->c_uid, current_fsuid()) &&
54217 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54218 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54219 spin_unlock(&cii->c_lock);
54220
54221 return hit;
54222 diff --git a/fs/compat.c b/fs/compat.c
54223 index 6af20de..fec3fbb 100644
54224 --- a/fs/compat.c
54225 +++ b/fs/compat.c
54226 @@ -54,7 +54,7 @@
54227 #include <asm/ioctls.h>
54228 #include "internal.h"
54229
54230 -int compat_log = 1;
54231 +int compat_log = 0;
54232
54233 int compat_printk(const char *fmt, ...)
54234 {
54235 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54236
54237 set_fs(KERNEL_DS);
54238 /* The __user pointer cast is valid because of the set_fs() */
54239 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54240 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54241 set_fs(oldfs);
54242 /* truncating is ok because it's a user address */
54243 if (!ret)
54244 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54245 goto out;
54246
54247 ret = -EINVAL;
54248 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54249 + if (nr_segs > UIO_MAXIOV)
54250 goto out;
54251 if (nr_segs > fast_segs) {
54252 ret = -ENOMEM;
54253 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54254 struct compat_readdir_callback {
54255 struct dir_context ctx;
54256 struct compat_old_linux_dirent __user *dirent;
54257 + struct file * file;
54258 int result;
54259 };
54260
54261 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54262 buf->result = -EOVERFLOW;
54263 return -EOVERFLOW;
54264 }
54265 +
54266 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54267 + return 0;
54268 +
54269 buf->result++;
54270 dirent = buf->dirent;
54271 if (!access_ok(VERIFY_WRITE, dirent,
54272 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54273 if (!f.file)
54274 return -EBADF;
54275
54276 + buf.file = f.file;
54277 error = iterate_dir(f.file, &buf.ctx);
54278 if (buf.result)
54279 error = buf.result;
54280 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54281 struct dir_context ctx;
54282 struct compat_linux_dirent __user *current_dir;
54283 struct compat_linux_dirent __user *previous;
54284 + struct file * file;
54285 int count;
54286 int error;
54287 };
54288 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54289 buf->error = -EOVERFLOW;
54290 return -EOVERFLOW;
54291 }
54292 +
54293 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54294 + return 0;
54295 +
54296 dirent = buf->previous;
54297 if (dirent) {
54298 if (__put_user(offset, &dirent->d_off))
54299 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54300 if (!f.file)
54301 return -EBADF;
54302
54303 + buf.file = f.file;
54304 error = iterate_dir(f.file, &buf.ctx);
54305 if (error >= 0)
54306 error = buf.error;
54307 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54308 struct dir_context ctx;
54309 struct linux_dirent64 __user *current_dir;
54310 struct linux_dirent64 __user *previous;
54311 + struct file * file;
54312 int count;
54313 int error;
54314 };
54315 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54316 buf->error = -EINVAL; /* only used if we fail.. */
54317 if (reclen > buf->count)
54318 return -EINVAL;
54319 +
54320 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54321 + return 0;
54322 +
54323 dirent = buf->previous;
54324
54325 if (dirent) {
54326 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54327 if (!f.file)
54328 return -EBADF;
54329
54330 + buf.file = f.file;
54331 error = iterate_dir(f.file, &buf.ctx);
54332 if (error >= 0)
54333 error = buf.error;
54334 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54335 index a81147e..20bf2b5 100644
54336 --- a/fs/compat_binfmt_elf.c
54337 +++ b/fs/compat_binfmt_elf.c
54338 @@ -30,11 +30,13 @@
54339 #undef elf_phdr
54340 #undef elf_shdr
54341 #undef elf_note
54342 +#undef elf_dyn
54343 #undef elf_addr_t
54344 #define elfhdr elf32_hdr
54345 #define elf_phdr elf32_phdr
54346 #define elf_shdr elf32_shdr
54347 #define elf_note elf32_note
54348 +#define elf_dyn Elf32_Dyn
54349 #define elf_addr_t Elf32_Addr
54350
54351 /*
54352 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54353 index 5d19acf..9ab093b 100644
54354 --- a/fs/compat_ioctl.c
54355 +++ b/fs/compat_ioctl.c
54356 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54357 return -EFAULT;
54358 if (__get_user(udata, &ss32->iomem_base))
54359 return -EFAULT;
54360 - ss.iomem_base = compat_ptr(udata);
54361 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54362 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54363 __get_user(ss.port_high, &ss32->port_high))
54364 return -EFAULT;
54365 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54366 for (i = 0; i < nmsgs; i++) {
54367 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54368 return -EFAULT;
54369 - if (get_user(datap, &umsgs[i].buf) ||
54370 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54371 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54372 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54373 return -EFAULT;
54374 }
54375 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54376 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54377 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54378 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54379 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54380 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54381 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54382 return -EFAULT;
54383
54384 return ioctl_preallocate(file, p);
54385 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54386 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54387 {
54388 unsigned int a, b;
54389 - a = *(unsigned int *)p;
54390 - b = *(unsigned int *)q;
54391 + a = *(const unsigned int *)p;
54392 + b = *(const unsigned int *)q;
54393 if (a > b)
54394 return 1;
54395 if (a < b)
54396 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54397 index 277bd1b..f312c9e 100644
54398 --- a/fs/configfs/dir.c
54399 +++ b/fs/configfs/dir.c
54400 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54401 }
54402 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54403 struct configfs_dirent *next;
54404 - const char *name;
54405 + const unsigned char * name;
54406 + char d_name[sizeof(next->s_dentry->d_iname)];
54407 int len;
54408 struct inode *inode = NULL;
54409
54410 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54411 continue;
54412
54413 name = configfs_get_name(next);
54414 - len = strlen(name);
54415 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54416 + len = next->s_dentry->d_name.len;
54417 + memcpy(d_name, name, len);
54418 + name = d_name;
54419 + } else
54420 + len = strlen(name);
54421
54422 /*
54423 * We'll have a dentry and an inode for
54424 diff --git a/fs/coredump.c b/fs/coredump.c
54425 index 72f816d..1ba8eff 100644
54426 --- a/fs/coredump.c
54427 +++ b/fs/coredump.c
54428 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54429 struct pipe_inode_info *pipe = file->private_data;
54430
54431 pipe_lock(pipe);
54432 - pipe->readers++;
54433 - pipe->writers--;
54434 + atomic_inc(&pipe->readers);
54435 + atomic_dec(&pipe->writers);
54436 wake_up_interruptible_sync(&pipe->wait);
54437 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54438 pipe_unlock(pipe);
54439 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54440 * We actually want wait_event_freezable() but then we need
54441 * to clear TIF_SIGPENDING and improve dump_interrupted().
54442 */
54443 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54444 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54445
54446 pipe_lock(pipe);
54447 - pipe->readers--;
54448 - pipe->writers++;
54449 + atomic_dec(&pipe->readers);
54450 + atomic_inc(&pipe->writers);
54451 pipe_unlock(pipe);
54452 }
54453
54454 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54455 struct files_struct *displaced;
54456 bool need_nonrelative = false;
54457 bool core_dumped = false;
54458 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54459 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54460 + long signr = siginfo->si_signo;
54461 struct coredump_params cprm = {
54462 .siginfo = siginfo,
54463 .regs = signal_pt_regs(),
54464 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54465 .mm_flags = mm->flags,
54466 };
54467
54468 - audit_core_dumps(siginfo->si_signo);
54469 + audit_core_dumps(signr);
54470 +
54471 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54472 + gr_handle_brute_attach(cprm.mm_flags);
54473
54474 binfmt = mm->binfmt;
54475 if (!binfmt || !binfmt->core_dump)
54476 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54477 need_nonrelative = true;
54478 }
54479
54480 - retval = coredump_wait(siginfo->si_signo, &core_state);
54481 + retval = coredump_wait(signr, &core_state);
54482 if (retval < 0)
54483 goto fail_creds;
54484
54485 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54486 }
54487 cprm.limit = RLIM_INFINITY;
54488
54489 - dump_count = atomic_inc_return(&core_dump_count);
54490 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54491 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54492 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54493 task_tgid_vnr(current), current->comm);
54494 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54495 } else {
54496 struct inode *inode;
54497
54498 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54499 +
54500 if (cprm.limit < binfmt->min_coredump)
54501 goto fail_unlock;
54502
54503 @@ -664,7 +670,7 @@ close_fail:
54504 filp_close(cprm.file, NULL);
54505 fail_dropcount:
54506 if (ispipe)
54507 - atomic_dec(&core_dump_count);
54508 + atomic_dec_unchecked(&core_dump_count);
54509 fail_unlock:
54510 kfree(cn.corename);
54511 coredump_finish(mm, core_dumped);
54512 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54513 {
54514 return !dump_interrupted() &&
54515 access_ok(VERIFY_READ, addr, nr) &&
54516 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54517 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54518 }
54519 EXPORT_SYMBOL(dump_write);
54520
54521 diff --git a/fs/dcache.c b/fs/dcache.c
54522 index b949af8..5978926 100644
54523 --- a/fs/dcache.c
54524 +++ b/fs/dcache.c
54525 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54526 mempages -= reserve;
54527
54528 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54529 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54530 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54531 + SLAB_NO_SANITIZE, NULL);
54532
54533 dcache_init();
54534 inode_init();
54535 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54536 index c7c83ff..bda9461 100644
54537 --- a/fs/debugfs/inode.c
54538 +++ b/fs/debugfs/inode.c
54539 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54540 */
54541 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54542 {
54543 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54544 + return __create_file(name, S_IFDIR | S_IRWXU,
54545 +#else
54546 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54547 +#endif
54548 parent, NULL, NULL);
54549 }
54550 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54551 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54552 index 67e9b63..a9adb68 100644
54553 --- a/fs/ecryptfs/inode.c
54554 +++ b/fs/ecryptfs/inode.c
54555 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54556 old_fs = get_fs();
54557 set_fs(get_ds());
54558 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54559 - (char __user *)lower_buf,
54560 + (char __force_user *)lower_buf,
54561 PATH_MAX);
54562 set_fs(old_fs);
54563 if (rc < 0)
54564 @@ -706,7 +706,7 @@ out:
54565 static void
54566 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54567 {
54568 - char *buf = nd_get_link(nd);
54569 + const char *buf = nd_get_link(nd);
54570 if (!IS_ERR(buf)) {
54571 /* Free the char* */
54572 kfree(buf);
54573 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54574 index e4141f2..d8263e8 100644
54575 --- a/fs/ecryptfs/miscdev.c
54576 +++ b/fs/ecryptfs/miscdev.c
54577 @@ -304,7 +304,7 @@ check_list:
54578 goto out_unlock_msg_ctx;
54579 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54580 if (msg_ctx->msg) {
54581 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54582 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54583 goto out_unlock_msg_ctx;
54584 i += packet_length_size;
54585 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54586 diff --git a/fs/exec.c b/fs/exec.c
54587 index fd774c7..d08c9ec 100644
54588 --- a/fs/exec.c
54589 +++ b/fs/exec.c
54590 @@ -55,8 +55,20 @@
54591 #include <linux/pipe_fs_i.h>
54592 #include <linux/oom.h>
54593 #include <linux/compat.h>
54594 +#include <linux/random.h>
54595 +#include <linux/seq_file.h>
54596 +#include <linux/coredump.h>
54597 +#include <linux/mman.h>
54598 +
54599 +#ifdef CONFIG_PAX_REFCOUNT
54600 +#include <linux/kallsyms.h>
54601 +#include <linux/kdebug.h>
54602 +#endif
54603 +
54604 +#include <trace/events/fs.h>
54605
54606 #include <asm/uaccess.h>
54607 +#include <asm/sections.h>
54608 #include <asm/mmu_context.h>
54609 #include <asm/tlb.h>
54610
54611 @@ -66,17 +78,32 @@
54612
54613 #include <trace/events/sched.h>
54614
54615 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54616 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54617 +{
54618 + 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");
54619 +}
54620 +#endif
54621 +
54622 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54623 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54624 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54625 +#endif
54626 +
54627 int suid_dumpable = 0;
54628
54629 static LIST_HEAD(formats);
54630 static DEFINE_RWLOCK(binfmt_lock);
54631
54632 +extern int gr_process_kernel_exec_ban(void);
54633 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54634 +
54635 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54636 {
54637 BUG_ON(!fmt);
54638 write_lock(&binfmt_lock);
54639 - insert ? list_add(&fmt->lh, &formats) :
54640 - list_add_tail(&fmt->lh, &formats);
54641 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54642 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54643 write_unlock(&binfmt_lock);
54644 }
54645
54646 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54647 void unregister_binfmt(struct linux_binfmt * fmt)
54648 {
54649 write_lock(&binfmt_lock);
54650 - list_del(&fmt->lh);
54651 + pax_list_del((struct list_head *)&fmt->lh);
54652 write_unlock(&binfmt_lock);
54653 }
54654
54655 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54656 int write)
54657 {
54658 struct page *page;
54659 - int ret;
54660
54661 -#ifdef CONFIG_STACK_GROWSUP
54662 - if (write) {
54663 - ret = expand_downwards(bprm->vma, pos);
54664 - if (ret < 0)
54665 - return NULL;
54666 - }
54667 -#endif
54668 - ret = get_user_pages(current, bprm->mm, pos,
54669 - 1, write, 1, &page, NULL);
54670 - if (ret <= 0)
54671 + if (0 > expand_downwards(bprm->vma, pos))
54672 + return NULL;
54673 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54674 return NULL;
54675
54676 if (write) {
54677 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54678 if (size <= ARG_MAX)
54679 return page;
54680
54681 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54682 + // only allow 512KB for argv+env on suid/sgid binaries
54683 + // to prevent easy ASLR exhaustion
54684 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54685 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54686 + (size > (512 * 1024))) {
54687 + put_page(page);
54688 + return NULL;
54689 + }
54690 +#endif
54691 +
54692 /*
54693 * Limit to 1/4-th the stack size for the argv+env strings.
54694 * This ensures that:
54695 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54696 vma->vm_end = STACK_TOP_MAX;
54697 vma->vm_start = vma->vm_end - PAGE_SIZE;
54698 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54699 +
54700 +#ifdef CONFIG_PAX_SEGMEXEC
54701 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54702 +#endif
54703 +
54704 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54705 INIT_LIST_HEAD(&vma->anon_vma_chain);
54706
54707 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54708 mm->stack_vm = mm->total_vm = 1;
54709 up_write(&mm->mmap_sem);
54710 bprm->p = vma->vm_end - sizeof(void *);
54711 +
54712 +#ifdef CONFIG_PAX_RANDUSTACK
54713 + if (randomize_va_space)
54714 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54715 +#endif
54716 +
54717 return 0;
54718 err:
54719 up_write(&mm->mmap_sem);
54720 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54721 } ptr;
54722 };
54723
54724 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54725 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54726 {
54727 const char __user *native;
54728
54729 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54730 compat_uptr_t compat;
54731
54732 if (get_user(compat, argv.ptr.compat + nr))
54733 - return ERR_PTR(-EFAULT);
54734 + return (const char __force_user *)ERR_PTR(-EFAULT);
54735
54736 return compat_ptr(compat);
54737 }
54738 #endif
54739
54740 if (get_user(native, argv.ptr.native + nr))
54741 - return ERR_PTR(-EFAULT);
54742 + return (const char __force_user *)ERR_PTR(-EFAULT);
54743
54744 return native;
54745 }
54746 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54747 if (!p)
54748 break;
54749
54750 - if (IS_ERR(p))
54751 + if (IS_ERR((const char __force_kernel *)p))
54752 return -EFAULT;
54753
54754 if (i >= max)
54755 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54756
54757 ret = -EFAULT;
54758 str = get_user_arg_ptr(argv, argc);
54759 - if (IS_ERR(str))
54760 + if (IS_ERR((const char __force_kernel *)str))
54761 goto out;
54762
54763 len = strnlen_user(str, MAX_ARG_STRLEN);
54764 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54765 int r;
54766 mm_segment_t oldfs = get_fs();
54767 struct user_arg_ptr argv = {
54768 - .ptr.native = (const char __user *const __user *)__argv,
54769 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54770 };
54771
54772 set_fs(KERNEL_DS);
54773 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54774 unsigned long new_end = old_end - shift;
54775 struct mmu_gather tlb;
54776
54777 - BUG_ON(new_start > new_end);
54778 + if (new_start >= new_end || new_start < mmap_min_addr)
54779 + return -ENOMEM;
54780
54781 /*
54782 * ensure there are no vmas between where we want to go
54783 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54784 if (vma != find_vma(mm, new_start))
54785 return -EFAULT;
54786
54787 +#ifdef CONFIG_PAX_SEGMEXEC
54788 + BUG_ON(pax_find_mirror_vma(vma));
54789 +#endif
54790 +
54791 /*
54792 * cover the whole range: [new_start, old_end)
54793 */
54794 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54795 stack_top = arch_align_stack(stack_top);
54796 stack_top = PAGE_ALIGN(stack_top);
54797
54798 - if (unlikely(stack_top < mmap_min_addr) ||
54799 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54800 - return -ENOMEM;
54801 -
54802 stack_shift = vma->vm_end - stack_top;
54803
54804 bprm->p -= stack_shift;
54805 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54806 bprm->exec -= stack_shift;
54807
54808 down_write(&mm->mmap_sem);
54809 +
54810 + /* Move stack pages down in memory. */
54811 + if (stack_shift) {
54812 + ret = shift_arg_pages(vma, stack_shift);
54813 + if (ret)
54814 + goto out_unlock;
54815 + }
54816 +
54817 vm_flags = VM_STACK_FLAGS;
54818
54819 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54820 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54821 + vm_flags &= ~VM_EXEC;
54822 +
54823 +#ifdef CONFIG_PAX_MPROTECT
54824 + if (mm->pax_flags & MF_PAX_MPROTECT)
54825 + vm_flags &= ~VM_MAYEXEC;
54826 +#endif
54827 +
54828 + }
54829 +#endif
54830 +
54831 /*
54832 * Adjust stack execute permissions; explicitly enable for
54833 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54834 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54835 goto out_unlock;
54836 BUG_ON(prev != vma);
54837
54838 - /* Move stack pages down in memory. */
54839 - if (stack_shift) {
54840 - ret = shift_arg_pages(vma, stack_shift);
54841 - if (ret)
54842 - goto out_unlock;
54843 - }
54844 -
54845 /* mprotect_fixup is overkill to remove the temporary stack flags */
54846 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54847
54848 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54849 #endif
54850 current->mm->start_stack = bprm->p;
54851 ret = expand_stack(vma, stack_base);
54852 +
54853 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54854 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54855 + unsigned long size;
54856 + vm_flags_t vm_flags;
54857 +
54858 + size = STACK_TOP - vma->vm_end;
54859 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54860 +
54861 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54862 +
54863 +#ifdef CONFIG_X86
54864 + if (!ret) {
54865 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54866 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54867 + }
54868 +#endif
54869 +
54870 + }
54871 +#endif
54872 +
54873 if (ret)
54874 ret = -EFAULT;
54875
54876 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54877
54878 fsnotify_open(file);
54879
54880 + trace_open_exec(name);
54881 +
54882 err = deny_write_access(file);
54883 if (err)
54884 goto exit;
54885 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54886 old_fs = get_fs();
54887 set_fs(get_ds());
54888 /* The cast to a user pointer is valid due to the set_fs() */
54889 - result = vfs_read(file, (void __user *)addr, count, &pos);
54890 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54891 set_fs(old_fs);
54892 return result;
54893 }
54894 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54895 }
54896 rcu_read_unlock();
54897
54898 - if (p->fs->users > n_fs) {
54899 + if (atomic_read(&p->fs->users) > n_fs) {
54900 bprm->unsafe |= LSM_UNSAFE_SHARE;
54901 } else {
54902 res = -EAGAIN;
54903 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54904
54905 EXPORT_SYMBOL(search_binary_handler);
54906
54907 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54908 +static DEFINE_PER_CPU(u64, exec_counter);
54909 +static int __init init_exec_counters(void)
54910 +{
54911 + unsigned int cpu;
54912 +
54913 + for_each_possible_cpu(cpu) {
54914 + per_cpu(exec_counter, cpu) = (u64)cpu;
54915 + }
54916 +
54917 + return 0;
54918 +}
54919 +early_initcall(init_exec_counters);
54920 +static inline void increment_exec_counter(void)
54921 +{
54922 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54923 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
54924 +}
54925 +#else
54926 +static inline void increment_exec_counter(void) {}
54927 +#endif
54928 +
54929 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
54930 + struct user_arg_ptr argv);
54931 +
54932 /*
54933 * sys_execve() executes a new program.
54934 */
54935 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
54936 struct user_arg_ptr argv,
54937 struct user_arg_ptr envp)
54938 {
54939 +#ifdef CONFIG_GRKERNSEC
54940 + struct file *old_exec_file;
54941 + struct acl_subject_label *old_acl;
54942 + struct rlimit old_rlim[RLIM_NLIMITS];
54943 +#endif
54944 struct linux_binprm *bprm;
54945 struct file *file;
54946 struct files_struct *displaced;
54947 bool clear_in_exec;
54948 int retval;
54949
54950 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
54951 +
54952 /*
54953 * We move the actual failure in case of RLIMIT_NPROC excess from
54954 * set*uid() to execve() because too many poorly written programs
54955 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
54956 if (IS_ERR(file))
54957 goto out_unmark;
54958
54959 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
54960 + retval = -EPERM;
54961 + goto out_file;
54962 + }
54963 +
54964 sched_exec();
54965
54966 bprm->file = file;
54967 bprm->filename = filename;
54968 bprm->interp = filename;
54969
54970 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
54971 + retval = -EACCES;
54972 + goto out_file;
54973 + }
54974 +
54975 retval = bprm_mm_init(bprm);
54976 if (retval)
54977 goto out_file;
54978 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
54979 if (retval < 0)
54980 goto out;
54981
54982 +#ifdef CONFIG_GRKERNSEC
54983 + old_acl = current->acl;
54984 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
54985 + old_exec_file = current->exec_file;
54986 + get_file(file);
54987 + current->exec_file = file;
54988 +#endif
54989 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54990 + /* limit suid stack to 8MB
54991 + * we saved the old limits above and will restore them if this exec fails
54992 + */
54993 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
54994 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
54995 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
54996 +#endif
54997 +
54998 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
54999 + retval = -EPERM;
55000 + goto out_fail;
55001 + }
55002 +
55003 + if (!gr_tpe_allow(file)) {
55004 + retval = -EACCES;
55005 + goto out_fail;
55006 + }
55007 +
55008 + if (gr_check_crash_exec(file)) {
55009 + retval = -EACCES;
55010 + goto out_fail;
55011 + }
55012 +
55013 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55014 + bprm->unsafe);
55015 + if (retval < 0)
55016 + goto out_fail;
55017 +
55018 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55019 if (retval < 0)
55020 - goto out;
55021 + goto out_fail;
55022
55023 bprm->exec = bprm->p;
55024 retval = copy_strings(bprm->envc, envp, bprm);
55025 if (retval < 0)
55026 - goto out;
55027 + goto out_fail;
55028
55029 retval = copy_strings(bprm->argc, argv, bprm);
55030 if (retval < 0)
55031 - goto out;
55032 + goto out_fail;
55033 +
55034 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55035 +
55036 + gr_handle_exec_args(bprm, argv);
55037
55038 retval = search_binary_handler(bprm);
55039 if (retval < 0)
55040 - goto out;
55041 + goto out_fail;
55042 +#ifdef CONFIG_GRKERNSEC
55043 + if (old_exec_file)
55044 + fput(old_exec_file);
55045 +#endif
55046
55047 /* execve succeeded */
55048 +
55049 + increment_exec_counter();
55050 current->fs->in_exec = 0;
55051 current->in_execve = 0;
55052 acct_update_integrals(current);
55053 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55054 put_files_struct(displaced);
55055 return retval;
55056
55057 +out_fail:
55058 +#ifdef CONFIG_GRKERNSEC
55059 + current->acl = old_acl;
55060 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55061 + fput(current->exec_file);
55062 + current->exec_file = old_exec_file;
55063 +#endif
55064 +
55065 out:
55066 if (bprm->mm) {
55067 acct_arg_size(bprm, 0);
55068 @@ -1702,3 +1876,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55069 return error;
55070 }
55071 #endif
55072 +
55073 +int pax_check_flags(unsigned long *flags)
55074 +{
55075 + int retval = 0;
55076 +
55077 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55078 + if (*flags & MF_PAX_SEGMEXEC)
55079 + {
55080 + *flags &= ~MF_PAX_SEGMEXEC;
55081 + retval = -EINVAL;
55082 + }
55083 +#endif
55084 +
55085 + if ((*flags & MF_PAX_PAGEEXEC)
55086 +
55087 +#ifdef CONFIG_PAX_PAGEEXEC
55088 + && (*flags & MF_PAX_SEGMEXEC)
55089 +#endif
55090 +
55091 + )
55092 + {
55093 + *flags &= ~MF_PAX_PAGEEXEC;
55094 + retval = -EINVAL;
55095 + }
55096 +
55097 + if ((*flags & MF_PAX_MPROTECT)
55098 +
55099 +#ifdef CONFIG_PAX_MPROTECT
55100 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55101 +#endif
55102 +
55103 + )
55104 + {
55105 + *flags &= ~MF_PAX_MPROTECT;
55106 + retval = -EINVAL;
55107 + }
55108 +
55109 + if ((*flags & MF_PAX_EMUTRAMP)
55110 +
55111 +#ifdef CONFIG_PAX_EMUTRAMP
55112 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55113 +#endif
55114 +
55115 + )
55116 + {
55117 + *flags &= ~MF_PAX_EMUTRAMP;
55118 + retval = -EINVAL;
55119 + }
55120 +
55121 + return retval;
55122 +}
55123 +
55124 +EXPORT_SYMBOL(pax_check_flags);
55125 +
55126 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55127 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55128 +{
55129 + char *pathname = d_path(path, buf, buflen);
55130 +
55131 + if (IS_ERR(pathname))
55132 + goto toolong;
55133 +
55134 + pathname = mangle_path(buf, pathname, "\t\n\\");
55135 + if (!pathname)
55136 + goto toolong;
55137 +
55138 + *pathname = 0;
55139 + return buf;
55140 +
55141 +toolong:
55142 + return "<path too long>";
55143 +}
55144 +EXPORT_SYMBOL(pax_get_path);
55145 +
55146 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55147 +{
55148 + struct task_struct *tsk = current;
55149 + struct mm_struct *mm = current->mm;
55150 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55151 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55152 + char *path_exec = NULL;
55153 + char *path_fault = NULL;
55154 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55155 + siginfo_t info = { };
55156 +
55157 + if (buffer_exec && buffer_fault) {
55158 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55159 +
55160 + down_read(&mm->mmap_sem);
55161 + vma = mm->mmap;
55162 + while (vma && (!vma_exec || !vma_fault)) {
55163 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55164 + vma_exec = vma;
55165 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55166 + vma_fault = vma;
55167 + vma = vma->vm_next;
55168 + }
55169 + if (vma_exec)
55170 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55171 + if (vma_fault) {
55172 + start = vma_fault->vm_start;
55173 + end = vma_fault->vm_end;
55174 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55175 + if (vma_fault->vm_file)
55176 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55177 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55178 + path_fault = "<heap>";
55179 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55180 + path_fault = "<stack>";
55181 + else
55182 + path_fault = "<anonymous mapping>";
55183 + }
55184 + up_read(&mm->mmap_sem);
55185 + }
55186 + if (tsk->signal->curr_ip)
55187 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55188 + else
55189 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55190 + 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),
55191 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55192 + free_page((unsigned long)buffer_exec);
55193 + free_page((unsigned long)buffer_fault);
55194 + pax_report_insns(regs, pc, sp);
55195 + info.si_signo = SIGKILL;
55196 + info.si_errno = 0;
55197 + info.si_code = SI_KERNEL;
55198 + info.si_pid = 0;
55199 + info.si_uid = 0;
55200 + do_coredump(&info);
55201 +}
55202 +#endif
55203 +
55204 +#ifdef CONFIG_PAX_REFCOUNT
55205 +void pax_report_refcount_overflow(struct pt_regs *regs)
55206 +{
55207 + if (current->signal->curr_ip)
55208 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55209 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55210 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55211 + else
55212 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55213 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55214 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55215 + preempt_disable();
55216 + show_regs(regs);
55217 + preempt_enable();
55218 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55219 +}
55220 +#endif
55221 +
55222 +#ifdef CONFIG_PAX_USERCOPY
55223 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55224 +static noinline int check_stack_object(const void *obj, unsigned long len)
55225 +{
55226 + const void * const stack = task_stack_page(current);
55227 + const void * const stackend = stack + THREAD_SIZE;
55228 +
55229 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55230 + const void *frame = NULL;
55231 + const void *oldframe;
55232 +#endif
55233 +
55234 + if (obj + len < obj)
55235 + return -1;
55236 +
55237 + if (obj + len <= stack || stackend <= obj)
55238 + return 0;
55239 +
55240 + if (obj < stack || stackend < obj + len)
55241 + return -1;
55242 +
55243 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55244 + oldframe = __builtin_frame_address(1);
55245 + if (oldframe)
55246 + frame = __builtin_frame_address(2);
55247 + /*
55248 + low ----------------------------------------------> high
55249 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55250 + ^----------------^
55251 + allow copies only within here
55252 + */
55253 + while (stack <= frame && frame < stackend) {
55254 + /* if obj + len extends past the last frame, this
55255 + check won't pass and the next frame will be 0,
55256 + causing us to bail out and correctly report
55257 + the copy as invalid
55258 + */
55259 + if (obj + len <= frame)
55260 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55261 + oldframe = frame;
55262 + frame = *(const void * const *)frame;
55263 + }
55264 + return -1;
55265 +#else
55266 + return 1;
55267 +#endif
55268 +}
55269 +
55270 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55271 +{
55272 + if (current->signal->curr_ip)
55273 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55274 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55275 + else
55276 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55277 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55278 + dump_stack();
55279 + gr_handle_kernel_exploit();
55280 + do_group_exit(SIGKILL);
55281 +}
55282 +#endif
55283 +
55284 +#ifdef CONFIG_PAX_USERCOPY
55285 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55286 +{
55287 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55288 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55289 +#ifdef CONFIG_MODULES
55290 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55291 +#else
55292 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55293 +#endif
55294 +
55295 +#else
55296 + unsigned long textlow = (unsigned long)_stext;
55297 + unsigned long texthigh = (unsigned long)_etext;
55298 +
55299 +#ifdef CONFIG_X86_64
55300 + /* check against linear mapping as well */
55301 + if (high > (unsigned long)__va(__pa(textlow)) &&
55302 + low <= (unsigned long)__va(__pa(texthigh)))
55303 + return true;
55304 +#endif
55305 +
55306 +#endif
55307 +
55308 + if (high <= textlow || low > texthigh)
55309 + return false;
55310 + else
55311 + return true;
55312 +}
55313 +#endif
55314 +
55315 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55316 +{
55317 +
55318 +#ifdef CONFIG_PAX_USERCOPY
55319 + const char *type;
55320 +
55321 + if (!n)
55322 + return;
55323 +
55324 + type = check_heap_object(ptr, n);
55325 + if (!type) {
55326 + int ret = check_stack_object(ptr, n);
55327 + if (ret == 1 || ret == 2)
55328 + return;
55329 + if (ret == 0) {
55330 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55331 + type = "<kernel text>";
55332 + else
55333 + return;
55334 + } else
55335 + type = "<process stack>";
55336 + }
55337 +
55338 + pax_report_usercopy(ptr, n, to_user, type);
55339 +#endif
55340 +
55341 +}
55342 +EXPORT_SYMBOL(__check_object_size);
55343 +
55344 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55345 +void pax_track_stack(void)
55346 +{
55347 + unsigned long sp = (unsigned long)&sp;
55348 + if (sp < current_thread_info()->lowest_stack &&
55349 + sp > (unsigned long)task_stack_page(current))
55350 + current_thread_info()->lowest_stack = sp;
55351 +}
55352 +EXPORT_SYMBOL(pax_track_stack);
55353 +#endif
55354 +
55355 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55356 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55357 +{
55358 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55359 + dump_stack();
55360 + do_group_exit(SIGKILL);
55361 +}
55362 +EXPORT_SYMBOL(report_size_overflow);
55363 +#endif
55364 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55365 index 9f9992b..8b59411 100644
55366 --- a/fs/ext2/balloc.c
55367 +++ b/fs/ext2/balloc.c
55368 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55369
55370 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55371 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55372 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55373 + if (free_blocks < root_blocks + 1 &&
55374 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55375 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55376 - !in_group_p (sbi->s_resgid))) {
55377 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55378 return 0;
55379 }
55380 return 1;
55381 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55382 index 22548f5..41521d8 100644
55383 --- a/fs/ext3/balloc.c
55384 +++ b/fs/ext3/balloc.c
55385 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55386
55387 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55388 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55389 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55390 + if (free_blocks < root_blocks + 1 &&
55391 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55392 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55393 - !in_group_p (sbi->s_resgid))) {
55394 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55395 return 0;
55396 }
55397 return 1;
55398 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55399 index ddd715e..c772f88 100644
55400 --- a/fs/ext4/balloc.c
55401 +++ b/fs/ext4/balloc.c
55402 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55403 /* Hm, nope. Are (enough) root reserved clusters available? */
55404 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55405 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55406 - capable(CAP_SYS_RESOURCE) ||
55407 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55408 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55409 + capable_nolog(CAP_SYS_RESOURCE)) {
55410
55411 if (free_clusters >= (nclusters + dirty_clusters +
55412 resv_clusters))
55413 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55414 index 0ab26fb..b6ecb39 100644
55415 --- a/fs/ext4/ext4.h
55416 +++ b/fs/ext4/ext4.h
55417 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55418 unsigned long s_mb_last_start;
55419
55420 /* stats for buddy allocator */
55421 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55422 - atomic_t s_bal_success; /* we found long enough chunks */
55423 - atomic_t s_bal_allocated; /* in blocks */
55424 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55425 - atomic_t s_bal_goals; /* goal hits */
55426 - atomic_t s_bal_breaks; /* too long searches */
55427 - atomic_t s_bal_2orders; /* 2^order hits */
55428 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55429 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55430 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55431 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55432 + atomic_unchecked_t s_bal_goals; /* goal hits */
55433 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55434 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55435 spinlock_t s_bal_lock;
55436 unsigned long s_mb_buddies_generated;
55437 unsigned long long s_mb_generation_time;
55438 - atomic_t s_mb_lost_chunks;
55439 - atomic_t s_mb_preallocated;
55440 - atomic_t s_mb_discarded;
55441 + atomic_unchecked_t s_mb_lost_chunks;
55442 + atomic_unchecked_t s_mb_preallocated;
55443 + atomic_unchecked_t s_mb_discarded;
55444 atomic_t s_lock_busy;
55445
55446 /* locality groups */
55447 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55448 index 4bbbf13b..dcceaeb 100644
55449 --- a/fs/ext4/mballoc.c
55450 +++ b/fs/ext4/mballoc.c
55451 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55452 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55453
55454 if (EXT4_SB(sb)->s_mb_stats)
55455 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55456 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55457
55458 break;
55459 }
55460 @@ -2171,7 +2171,7 @@ repeat:
55461 ac->ac_status = AC_STATUS_CONTINUE;
55462 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55463 cr = 3;
55464 - atomic_inc(&sbi->s_mb_lost_chunks);
55465 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55466 goto repeat;
55467 }
55468 }
55469 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55470 if (sbi->s_mb_stats) {
55471 ext4_msg(sb, KERN_INFO,
55472 "mballoc: %u blocks %u reqs (%u success)",
55473 - atomic_read(&sbi->s_bal_allocated),
55474 - atomic_read(&sbi->s_bal_reqs),
55475 - atomic_read(&sbi->s_bal_success));
55476 + atomic_read_unchecked(&sbi->s_bal_allocated),
55477 + atomic_read_unchecked(&sbi->s_bal_reqs),
55478 + atomic_read_unchecked(&sbi->s_bal_success));
55479 ext4_msg(sb, KERN_INFO,
55480 "mballoc: %u extents scanned, %u goal hits, "
55481 "%u 2^N hits, %u breaks, %u lost",
55482 - atomic_read(&sbi->s_bal_ex_scanned),
55483 - atomic_read(&sbi->s_bal_goals),
55484 - atomic_read(&sbi->s_bal_2orders),
55485 - atomic_read(&sbi->s_bal_breaks),
55486 - atomic_read(&sbi->s_mb_lost_chunks));
55487 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55488 + atomic_read_unchecked(&sbi->s_bal_goals),
55489 + atomic_read_unchecked(&sbi->s_bal_2orders),
55490 + atomic_read_unchecked(&sbi->s_bal_breaks),
55491 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55492 ext4_msg(sb, KERN_INFO,
55493 "mballoc: %lu generated and it took %Lu",
55494 sbi->s_mb_buddies_generated,
55495 sbi->s_mb_generation_time);
55496 ext4_msg(sb, KERN_INFO,
55497 "mballoc: %u preallocated, %u discarded",
55498 - atomic_read(&sbi->s_mb_preallocated),
55499 - atomic_read(&sbi->s_mb_discarded));
55500 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55501 + atomic_read_unchecked(&sbi->s_mb_discarded));
55502 }
55503
55504 free_percpu(sbi->s_locality_groups);
55505 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55506 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55507
55508 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55509 - atomic_inc(&sbi->s_bal_reqs);
55510 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55511 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55512 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55513 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55514 - atomic_inc(&sbi->s_bal_success);
55515 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55516 + atomic_inc_unchecked(&sbi->s_bal_success);
55517 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55518 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55519 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55520 - atomic_inc(&sbi->s_bal_goals);
55521 + atomic_inc_unchecked(&sbi->s_bal_goals);
55522 if (ac->ac_found > sbi->s_mb_max_to_scan)
55523 - atomic_inc(&sbi->s_bal_breaks);
55524 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55525 }
55526
55527 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55528 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55529 trace_ext4_mb_new_inode_pa(ac, pa);
55530
55531 ext4_mb_use_inode_pa(ac, pa);
55532 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55533 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55534
55535 ei = EXT4_I(ac->ac_inode);
55536 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55537 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55538 trace_ext4_mb_new_group_pa(ac, pa);
55539
55540 ext4_mb_use_group_pa(ac, pa);
55541 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55542 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55543
55544 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55545 lg = ac->ac_lg;
55546 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55547 * from the bitmap and continue.
55548 */
55549 }
55550 - atomic_add(free, &sbi->s_mb_discarded);
55551 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55552
55553 return err;
55554 }
55555 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55556 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55557 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55558 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55559 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55560 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55561 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55562
55563 return 0;
55564 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55565 index 214461e..3614c89 100644
55566 --- a/fs/ext4/mmp.c
55567 +++ b/fs/ext4/mmp.c
55568 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55569 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55570 const char *function, unsigned int line, const char *msg)
55571 {
55572 - __ext4_warning(sb, function, line, msg);
55573 + __ext4_warning(sb, function, line, "%s", msg);
55574 __ext4_warning(sb, function, line,
55575 "MMP failure info: last update time: %llu, last update "
55576 "node: %s, last update device: %s\n",
55577 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55578 index b59373b..f41c2b5 100644
55579 --- a/fs/ext4/super.c
55580 +++ b/fs/ext4/super.c
55581 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55582 }
55583
55584 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55585 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55586 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55587 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55588
55589 #ifdef CONFIG_QUOTA
55590 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55591 int offset;
55592 int deprecated_val;
55593 } u;
55594 -};
55595 +} __do_const;
55596
55597 static int parse_strtoull(const char *buf,
55598 unsigned long long max, unsigned long long *value)
55599 diff --git a/fs/fcntl.c b/fs/fcntl.c
55600 index 65343c3..9969dcf 100644
55601 --- a/fs/fcntl.c
55602 +++ b/fs/fcntl.c
55603 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55604 if (err)
55605 return err;
55606
55607 + if (gr_handle_chroot_fowner(pid, type))
55608 + return -ENOENT;
55609 + if (gr_check_protected_task_fowner(pid, type))
55610 + return -EACCES;
55611 +
55612 f_modown(filp, pid, type, force);
55613 return 0;
55614 }
55615 diff --git a/fs/fhandle.c b/fs/fhandle.c
55616 index 999ff5c..41f4109 100644
55617 --- a/fs/fhandle.c
55618 +++ b/fs/fhandle.c
55619 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55620 } else
55621 retval = 0;
55622 /* copy the mount id */
55623 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55624 - sizeof(*mnt_id)) ||
55625 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55626 copy_to_user(ufh, handle,
55627 sizeof(struct file_handle) + handle_bytes))
55628 retval = -EFAULT;
55629 diff --git a/fs/file.c b/fs/file.c
55630 index 4a78f98..9447397 100644
55631 --- a/fs/file.c
55632 +++ b/fs/file.c
55633 @@ -16,6 +16,7 @@
55634 #include <linux/slab.h>
55635 #include <linux/vmalloc.h>
55636 #include <linux/file.h>
55637 +#include <linux/security.h>
55638 #include <linux/fdtable.h>
55639 #include <linux/bitops.h>
55640 #include <linux/interrupt.h>
55641 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55642 if (!file)
55643 return __close_fd(files, fd);
55644
55645 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55646 if (fd >= rlimit(RLIMIT_NOFILE))
55647 return -EBADF;
55648
55649 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55650 if (unlikely(oldfd == newfd))
55651 return -EINVAL;
55652
55653 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55654 if (newfd >= rlimit(RLIMIT_NOFILE))
55655 return -EBADF;
55656
55657 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55658 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55659 {
55660 int err;
55661 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55662 if (from >= rlimit(RLIMIT_NOFILE))
55663 return -EINVAL;
55664 err = alloc_fd(from, flags);
55665 diff --git a/fs/filesystems.c b/fs/filesystems.c
55666 index 92567d9..fcd8cbf 100644
55667 --- a/fs/filesystems.c
55668 +++ b/fs/filesystems.c
55669 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55670 int len = dot ? dot - name : strlen(name);
55671
55672 fs = __get_fs_type(name, len);
55673 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55674 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55675 +#else
55676 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55677 +#endif
55678 fs = __get_fs_type(name, len);
55679
55680 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55681 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55682 index d8ac61d..79a36f0 100644
55683 --- a/fs/fs_struct.c
55684 +++ b/fs/fs_struct.c
55685 @@ -4,6 +4,7 @@
55686 #include <linux/path.h>
55687 #include <linux/slab.h>
55688 #include <linux/fs_struct.h>
55689 +#include <linux/grsecurity.h>
55690 #include "internal.h"
55691
55692 /*
55693 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55694 write_seqcount_begin(&fs->seq);
55695 old_root = fs->root;
55696 fs->root = *path;
55697 + gr_set_chroot_entries(current, path);
55698 write_seqcount_end(&fs->seq);
55699 spin_unlock(&fs->lock);
55700 if (old_root.dentry)
55701 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55702 int hits = 0;
55703 spin_lock(&fs->lock);
55704 write_seqcount_begin(&fs->seq);
55705 + /* this root replacement is only done by pivot_root,
55706 + leave grsec's chroot tagging alone for this task
55707 + so that a pivoted root isn't treated as a chroot
55708 + */
55709 hits += replace_path(&fs->root, old_root, new_root);
55710 hits += replace_path(&fs->pwd, old_root, new_root);
55711 write_seqcount_end(&fs->seq);
55712 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55713 task_lock(tsk);
55714 spin_lock(&fs->lock);
55715 tsk->fs = NULL;
55716 - kill = !--fs->users;
55717 + gr_clear_chroot_entries(tsk);
55718 + kill = !atomic_dec_return(&fs->users);
55719 spin_unlock(&fs->lock);
55720 task_unlock(tsk);
55721 if (kill)
55722 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55723 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55724 /* We don't need to lock fs - think why ;-) */
55725 if (fs) {
55726 - fs->users = 1;
55727 + atomic_set(&fs->users, 1);
55728 fs->in_exec = 0;
55729 spin_lock_init(&fs->lock);
55730 seqcount_init(&fs->seq);
55731 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55732 spin_lock(&old->lock);
55733 fs->root = old->root;
55734 path_get(&fs->root);
55735 + /* instead of calling gr_set_chroot_entries here,
55736 + we call it from every caller of this function
55737 + */
55738 fs->pwd = old->pwd;
55739 path_get(&fs->pwd);
55740 spin_unlock(&old->lock);
55741 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55742
55743 task_lock(current);
55744 spin_lock(&fs->lock);
55745 - kill = !--fs->users;
55746 + kill = !atomic_dec_return(&fs->users);
55747 current->fs = new_fs;
55748 + gr_set_chroot_entries(current, &new_fs->root);
55749 spin_unlock(&fs->lock);
55750 task_unlock(current);
55751
55752 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55753
55754 int current_umask(void)
55755 {
55756 - return current->fs->umask;
55757 + return current->fs->umask | gr_acl_umask();
55758 }
55759 EXPORT_SYMBOL(current_umask);
55760
55761 /* to be mentioned only in INIT_TASK */
55762 struct fs_struct init_fs = {
55763 - .users = 1,
55764 + .users = ATOMIC_INIT(1),
55765 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55766 .seq = SEQCNT_ZERO,
55767 .umask = 0022,
55768 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55769 index 0e91a3c..6c6d2e0 100644
55770 --- a/fs/fscache/cookie.c
55771 +++ b/fs/fscache/cookie.c
55772 @@ -19,7 +19,7 @@
55773
55774 struct kmem_cache *fscache_cookie_jar;
55775
55776 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55777 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55778
55779 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55780 static int fscache_alloc_object(struct fscache_cache *cache,
55781 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55782 parent ? (char *) parent->def->name : "<no-parent>",
55783 def->name, netfs_data);
55784
55785 - fscache_stat(&fscache_n_acquires);
55786 + fscache_stat_unchecked(&fscache_n_acquires);
55787
55788 /* if there's no parent cookie, then we don't create one here either */
55789 if (!parent) {
55790 - fscache_stat(&fscache_n_acquires_null);
55791 + fscache_stat_unchecked(&fscache_n_acquires_null);
55792 _leave(" [no parent]");
55793 return NULL;
55794 }
55795 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55796 /* allocate and initialise a cookie */
55797 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55798 if (!cookie) {
55799 - fscache_stat(&fscache_n_acquires_oom);
55800 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55801 _leave(" [ENOMEM]");
55802 return NULL;
55803 }
55804 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55805
55806 switch (cookie->def->type) {
55807 case FSCACHE_COOKIE_TYPE_INDEX:
55808 - fscache_stat(&fscache_n_cookie_index);
55809 + fscache_stat_unchecked(&fscache_n_cookie_index);
55810 break;
55811 case FSCACHE_COOKIE_TYPE_DATAFILE:
55812 - fscache_stat(&fscache_n_cookie_data);
55813 + fscache_stat_unchecked(&fscache_n_cookie_data);
55814 break;
55815 default:
55816 - fscache_stat(&fscache_n_cookie_special);
55817 + fscache_stat_unchecked(&fscache_n_cookie_special);
55818 break;
55819 }
55820
55821 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55822 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55823 atomic_dec(&parent->n_children);
55824 __fscache_cookie_put(cookie);
55825 - fscache_stat(&fscache_n_acquires_nobufs);
55826 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55827 _leave(" = NULL");
55828 return NULL;
55829 }
55830 }
55831
55832 - fscache_stat(&fscache_n_acquires_ok);
55833 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55834 _leave(" = %p", cookie);
55835 return cookie;
55836 }
55837 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55838 cache = fscache_select_cache_for_object(cookie->parent);
55839 if (!cache) {
55840 up_read(&fscache_addremove_sem);
55841 - fscache_stat(&fscache_n_acquires_no_cache);
55842 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55843 _leave(" = -ENOMEDIUM [no cache]");
55844 return -ENOMEDIUM;
55845 }
55846 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55847 object = cache->ops->alloc_object(cache, cookie);
55848 fscache_stat_d(&fscache_n_cop_alloc_object);
55849 if (IS_ERR(object)) {
55850 - fscache_stat(&fscache_n_object_no_alloc);
55851 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55852 ret = PTR_ERR(object);
55853 goto error;
55854 }
55855
55856 - fscache_stat(&fscache_n_object_alloc);
55857 + fscache_stat_unchecked(&fscache_n_object_alloc);
55858
55859 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55860 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55861
55862 _debug("ALLOC OBJ%x: %s {%lx}",
55863 object->debug_id, cookie->def->name, object->events);
55864 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55865
55866 _enter("{%s}", cookie->def->name);
55867
55868 - fscache_stat(&fscache_n_invalidates);
55869 + fscache_stat_unchecked(&fscache_n_invalidates);
55870
55871 /* Only permit invalidation of data files. Invalidating an index will
55872 * require the caller to release all its attachments to the tree rooted
55873 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55874 {
55875 struct fscache_object *object;
55876
55877 - fscache_stat(&fscache_n_updates);
55878 + fscache_stat_unchecked(&fscache_n_updates);
55879
55880 if (!cookie) {
55881 - fscache_stat(&fscache_n_updates_null);
55882 + fscache_stat_unchecked(&fscache_n_updates_null);
55883 _leave(" [no cookie]");
55884 return;
55885 }
55886 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55887 {
55888 struct fscache_object *object;
55889
55890 - fscache_stat(&fscache_n_relinquishes);
55891 + fscache_stat_unchecked(&fscache_n_relinquishes);
55892 if (retire)
55893 - fscache_stat(&fscache_n_relinquishes_retire);
55894 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55895
55896 if (!cookie) {
55897 - fscache_stat(&fscache_n_relinquishes_null);
55898 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55899 _leave(" [no cookie]");
55900 return;
55901 }
55902 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55903 index 12d505b..86473a3 100644
55904 --- a/fs/fscache/internal.h
55905 +++ b/fs/fscache/internal.h
55906 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55907 * stats.c
55908 */
55909 #ifdef CONFIG_FSCACHE_STATS
55910 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55911 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55912 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55913 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55914
55915 -extern atomic_t fscache_n_op_pend;
55916 -extern atomic_t fscache_n_op_run;
55917 -extern atomic_t fscache_n_op_enqueue;
55918 -extern atomic_t fscache_n_op_deferred_release;
55919 -extern atomic_t fscache_n_op_release;
55920 -extern atomic_t fscache_n_op_gc;
55921 -extern atomic_t fscache_n_op_cancelled;
55922 -extern atomic_t fscache_n_op_rejected;
55923 +extern atomic_unchecked_t fscache_n_op_pend;
55924 +extern atomic_unchecked_t fscache_n_op_run;
55925 +extern atomic_unchecked_t fscache_n_op_enqueue;
55926 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55927 +extern atomic_unchecked_t fscache_n_op_release;
55928 +extern atomic_unchecked_t fscache_n_op_gc;
55929 +extern atomic_unchecked_t fscache_n_op_cancelled;
55930 +extern atomic_unchecked_t fscache_n_op_rejected;
55931
55932 -extern atomic_t fscache_n_attr_changed;
55933 -extern atomic_t fscache_n_attr_changed_ok;
55934 -extern atomic_t fscache_n_attr_changed_nobufs;
55935 -extern atomic_t fscache_n_attr_changed_nomem;
55936 -extern atomic_t fscache_n_attr_changed_calls;
55937 +extern atomic_unchecked_t fscache_n_attr_changed;
55938 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
55939 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
55940 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
55941 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
55942
55943 -extern atomic_t fscache_n_allocs;
55944 -extern atomic_t fscache_n_allocs_ok;
55945 -extern atomic_t fscache_n_allocs_wait;
55946 -extern atomic_t fscache_n_allocs_nobufs;
55947 -extern atomic_t fscache_n_allocs_intr;
55948 -extern atomic_t fscache_n_allocs_object_dead;
55949 -extern atomic_t fscache_n_alloc_ops;
55950 -extern atomic_t fscache_n_alloc_op_waits;
55951 +extern atomic_unchecked_t fscache_n_allocs;
55952 +extern atomic_unchecked_t fscache_n_allocs_ok;
55953 +extern atomic_unchecked_t fscache_n_allocs_wait;
55954 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
55955 +extern atomic_unchecked_t fscache_n_allocs_intr;
55956 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
55957 +extern atomic_unchecked_t fscache_n_alloc_ops;
55958 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
55959
55960 -extern atomic_t fscache_n_retrievals;
55961 -extern atomic_t fscache_n_retrievals_ok;
55962 -extern atomic_t fscache_n_retrievals_wait;
55963 -extern atomic_t fscache_n_retrievals_nodata;
55964 -extern atomic_t fscache_n_retrievals_nobufs;
55965 -extern atomic_t fscache_n_retrievals_intr;
55966 -extern atomic_t fscache_n_retrievals_nomem;
55967 -extern atomic_t fscache_n_retrievals_object_dead;
55968 -extern atomic_t fscache_n_retrieval_ops;
55969 -extern atomic_t fscache_n_retrieval_op_waits;
55970 +extern atomic_unchecked_t fscache_n_retrievals;
55971 +extern atomic_unchecked_t fscache_n_retrievals_ok;
55972 +extern atomic_unchecked_t fscache_n_retrievals_wait;
55973 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
55974 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
55975 +extern atomic_unchecked_t fscache_n_retrievals_intr;
55976 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
55977 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
55978 +extern atomic_unchecked_t fscache_n_retrieval_ops;
55979 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
55980
55981 -extern atomic_t fscache_n_stores;
55982 -extern atomic_t fscache_n_stores_ok;
55983 -extern atomic_t fscache_n_stores_again;
55984 -extern atomic_t fscache_n_stores_nobufs;
55985 -extern atomic_t fscache_n_stores_oom;
55986 -extern atomic_t fscache_n_store_ops;
55987 -extern atomic_t fscache_n_store_calls;
55988 -extern atomic_t fscache_n_store_pages;
55989 -extern atomic_t fscache_n_store_radix_deletes;
55990 -extern atomic_t fscache_n_store_pages_over_limit;
55991 +extern atomic_unchecked_t fscache_n_stores;
55992 +extern atomic_unchecked_t fscache_n_stores_ok;
55993 +extern atomic_unchecked_t fscache_n_stores_again;
55994 +extern atomic_unchecked_t fscache_n_stores_nobufs;
55995 +extern atomic_unchecked_t fscache_n_stores_oom;
55996 +extern atomic_unchecked_t fscache_n_store_ops;
55997 +extern atomic_unchecked_t fscache_n_store_calls;
55998 +extern atomic_unchecked_t fscache_n_store_pages;
55999 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56000 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56001
56002 -extern atomic_t fscache_n_store_vmscan_not_storing;
56003 -extern atomic_t fscache_n_store_vmscan_gone;
56004 -extern atomic_t fscache_n_store_vmscan_busy;
56005 -extern atomic_t fscache_n_store_vmscan_cancelled;
56006 -extern atomic_t fscache_n_store_vmscan_wait;
56007 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56008 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56009 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56010 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56011 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56012
56013 -extern atomic_t fscache_n_marks;
56014 -extern atomic_t fscache_n_uncaches;
56015 +extern atomic_unchecked_t fscache_n_marks;
56016 +extern atomic_unchecked_t fscache_n_uncaches;
56017
56018 -extern atomic_t fscache_n_acquires;
56019 -extern atomic_t fscache_n_acquires_null;
56020 -extern atomic_t fscache_n_acquires_no_cache;
56021 -extern atomic_t fscache_n_acquires_ok;
56022 -extern atomic_t fscache_n_acquires_nobufs;
56023 -extern atomic_t fscache_n_acquires_oom;
56024 +extern atomic_unchecked_t fscache_n_acquires;
56025 +extern atomic_unchecked_t fscache_n_acquires_null;
56026 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56027 +extern atomic_unchecked_t fscache_n_acquires_ok;
56028 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56029 +extern atomic_unchecked_t fscache_n_acquires_oom;
56030
56031 -extern atomic_t fscache_n_invalidates;
56032 -extern atomic_t fscache_n_invalidates_run;
56033 +extern atomic_unchecked_t fscache_n_invalidates;
56034 +extern atomic_unchecked_t fscache_n_invalidates_run;
56035
56036 -extern atomic_t fscache_n_updates;
56037 -extern atomic_t fscache_n_updates_null;
56038 -extern atomic_t fscache_n_updates_run;
56039 +extern atomic_unchecked_t fscache_n_updates;
56040 +extern atomic_unchecked_t fscache_n_updates_null;
56041 +extern atomic_unchecked_t fscache_n_updates_run;
56042
56043 -extern atomic_t fscache_n_relinquishes;
56044 -extern atomic_t fscache_n_relinquishes_null;
56045 -extern atomic_t fscache_n_relinquishes_waitcrt;
56046 -extern atomic_t fscache_n_relinquishes_retire;
56047 +extern atomic_unchecked_t fscache_n_relinquishes;
56048 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56049 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56050 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56051
56052 -extern atomic_t fscache_n_cookie_index;
56053 -extern atomic_t fscache_n_cookie_data;
56054 -extern atomic_t fscache_n_cookie_special;
56055 +extern atomic_unchecked_t fscache_n_cookie_index;
56056 +extern atomic_unchecked_t fscache_n_cookie_data;
56057 +extern atomic_unchecked_t fscache_n_cookie_special;
56058
56059 -extern atomic_t fscache_n_object_alloc;
56060 -extern atomic_t fscache_n_object_no_alloc;
56061 -extern atomic_t fscache_n_object_lookups;
56062 -extern atomic_t fscache_n_object_lookups_negative;
56063 -extern atomic_t fscache_n_object_lookups_positive;
56064 -extern atomic_t fscache_n_object_lookups_timed_out;
56065 -extern atomic_t fscache_n_object_created;
56066 -extern atomic_t fscache_n_object_avail;
56067 -extern atomic_t fscache_n_object_dead;
56068 +extern atomic_unchecked_t fscache_n_object_alloc;
56069 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56070 +extern atomic_unchecked_t fscache_n_object_lookups;
56071 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56072 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56073 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56074 +extern atomic_unchecked_t fscache_n_object_created;
56075 +extern atomic_unchecked_t fscache_n_object_avail;
56076 +extern atomic_unchecked_t fscache_n_object_dead;
56077
56078 -extern atomic_t fscache_n_checkaux_none;
56079 -extern atomic_t fscache_n_checkaux_okay;
56080 -extern atomic_t fscache_n_checkaux_update;
56081 -extern atomic_t fscache_n_checkaux_obsolete;
56082 +extern atomic_unchecked_t fscache_n_checkaux_none;
56083 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56084 +extern atomic_unchecked_t fscache_n_checkaux_update;
56085 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56086
56087 extern atomic_t fscache_n_cop_alloc_object;
56088 extern atomic_t fscache_n_cop_lookup_object;
56089 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56090 atomic_inc(stat);
56091 }
56092
56093 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56094 +{
56095 + atomic_inc_unchecked(stat);
56096 +}
56097 +
56098 static inline void fscache_stat_d(atomic_t *stat)
56099 {
56100 atomic_dec(stat);
56101 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56102
56103 #define __fscache_stat(stat) (NULL)
56104 #define fscache_stat(stat) do {} while (0)
56105 +#define fscache_stat_unchecked(stat) do {} while (0)
56106 #define fscache_stat_d(stat) do {} while (0)
56107 #endif
56108
56109 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56110 index 86d75a6..5f3d7a0 100644
56111 --- a/fs/fscache/object.c
56112 +++ b/fs/fscache/object.c
56113 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56114 _debug("LOOKUP \"%s\" in \"%s\"",
56115 cookie->def->name, object->cache->tag->name);
56116
56117 - fscache_stat(&fscache_n_object_lookups);
56118 + fscache_stat_unchecked(&fscache_n_object_lookups);
56119 fscache_stat(&fscache_n_cop_lookup_object);
56120 ret = object->cache->ops->lookup_object(object);
56121 fscache_stat_d(&fscache_n_cop_lookup_object);
56122 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56123 if (ret == -ETIMEDOUT) {
56124 /* probably stuck behind another object, so move this one to
56125 * the back of the queue */
56126 - fscache_stat(&fscache_n_object_lookups_timed_out);
56127 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56128 _leave(" [timeout]");
56129 return NO_TRANSIT;
56130 }
56131 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56132 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56133
56134 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56135 - fscache_stat(&fscache_n_object_lookups_negative);
56136 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56137
56138 /* Allow write requests to begin stacking up and read requests to begin
56139 * returning ENODATA.
56140 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56141 /* if we were still looking up, then we must have a positive lookup
56142 * result, in which case there may be data available */
56143 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56144 - fscache_stat(&fscache_n_object_lookups_positive);
56145 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56146
56147 /* We do (presumably) have data */
56148 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56149 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56150 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56151 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56152 } else {
56153 - fscache_stat(&fscache_n_object_created);
56154 + fscache_stat_unchecked(&fscache_n_object_created);
56155 }
56156
56157 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56158 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56159 fscache_stat_d(&fscache_n_cop_lookup_complete);
56160
56161 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56162 - fscache_stat(&fscache_n_object_avail);
56163 + fscache_stat_unchecked(&fscache_n_object_avail);
56164
56165 _leave("");
56166 return transit_to(JUMPSTART_DEPS);
56167 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56168
56169 /* this just shifts the object release to the work processor */
56170 fscache_put_object(object);
56171 - fscache_stat(&fscache_n_object_dead);
56172 + fscache_stat_unchecked(&fscache_n_object_dead);
56173
56174 _leave("");
56175 return transit_to(OBJECT_DEAD);
56176 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56177 enum fscache_checkaux result;
56178
56179 if (!object->cookie->def->check_aux) {
56180 - fscache_stat(&fscache_n_checkaux_none);
56181 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56182 return FSCACHE_CHECKAUX_OKAY;
56183 }
56184
56185 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56186 switch (result) {
56187 /* entry okay as is */
56188 case FSCACHE_CHECKAUX_OKAY:
56189 - fscache_stat(&fscache_n_checkaux_okay);
56190 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56191 break;
56192
56193 /* entry requires update */
56194 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56195 - fscache_stat(&fscache_n_checkaux_update);
56196 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56197 break;
56198
56199 /* entry requires deletion */
56200 case FSCACHE_CHECKAUX_OBSOLETE:
56201 - fscache_stat(&fscache_n_checkaux_obsolete);
56202 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56203 break;
56204
56205 default:
56206 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56207 {
56208 const struct fscache_state *s;
56209
56210 - fscache_stat(&fscache_n_invalidates_run);
56211 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56212 fscache_stat(&fscache_n_cop_invalidate_object);
56213 s = _fscache_invalidate_object(object, event);
56214 fscache_stat_d(&fscache_n_cop_invalidate_object);
56215 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56216 {
56217 _enter("{OBJ%x},%d", object->debug_id, event);
56218
56219 - fscache_stat(&fscache_n_updates_run);
56220 + fscache_stat_unchecked(&fscache_n_updates_run);
56221 fscache_stat(&fscache_n_cop_update_object);
56222 object->cache->ops->update_object(object);
56223 fscache_stat_d(&fscache_n_cop_update_object);
56224 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56225 index 318071a..379938b 100644
56226 --- a/fs/fscache/operation.c
56227 +++ b/fs/fscache/operation.c
56228 @@ -17,7 +17,7 @@
56229 #include <linux/slab.h>
56230 #include "internal.h"
56231
56232 -atomic_t fscache_op_debug_id;
56233 +atomic_unchecked_t fscache_op_debug_id;
56234 EXPORT_SYMBOL(fscache_op_debug_id);
56235
56236 /**
56237 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56238 ASSERTCMP(atomic_read(&op->usage), >, 0);
56239 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56240
56241 - fscache_stat(&fscache_n_op_enqueue);
56242 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56243 switch (op->flags & FSCACHE_OP_TYPE) {
56244 case FSCACHE_OP_ASYNC:
56245 _debug("queue async");
56246 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56247 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56248 if (op->processor)
56249 fscache_enqueue_operation(op);
56250 - fscache_stat(&fscache_n_op_run);
56251 + fscache_stat_unchecked(&fscache_n_op_run);
56252 }
56253
56254 /*
56255 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56256 if (object->n_in_progress > 0) {
56257 atomic_inc(&op->usage);
56258 list_add_tail(&op->pend_link, &object->pending_ops);
56259 - fscache_stat(&fscache_n_op_pend);
56260 + fscache_stat_unchecked(&fscache_n_op_pend);
56261 } else if (!list_empty(&object->pending_ops)) {
56262 atomic_inc(&op->usage);
56263 list_add_tail(&op->pend_link, &object->pending_ops);
56264 - fscache_stat(&fscache_n_op_pend);
56265 + fscache_stat_unchecked(&fscache_n_op_pend);
56266 fscache_start_operations(object);
56267 } else {
56268 ASSERTCMP(object->n_in_progress, ==, 0);
56269 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56270 object->n_exclusive++; /* reads and writes must wait */
56271 atomic_inc(&op->usage);
56272 list_add_tail(&op->pend_link, &object->pending_ops);
56273 - fscache_stat(&fscache_n_op_pend);
56274 + fscache_stat_unchecked(&fscache_n_op_pend);
56275 ret = 0;
56276 } else {
56277 /* If we're in any other state, there must have been an I/O
56278 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56279 if (object->n_exclusive > 0) {
56280 atomic_inc(&op->usage);
56281 list_add_tail(&op->pend_link, &object->pending_ops);
56282 - fscache_stat(&fscache_n_op_pend);
56283 + fscache_stat_unchecked(&fscache_n_op_pend);
56284 } else if (!list_empty(&object->pending_ops)) {
56285 atomic_inc(&op->usage);
56286 list_add_tail(&op->pend_link, &object->pending_ops);
56287 - fscache_stat(&fscache_n_op_pend);
56288 + fscache_stat_unchecked(&fscache_n_op_pend);
56289 fscache_start_operations(object);
56290 } else {
56291 ASSERTCMP(object->n_exclusive, ==, 0);
56292 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56293 object->n_ops++;
56294 atomic_inc(&op->usage);
56295 list_add_tail(&op->pend_link, &object->pending_ops);
56296 - fscache_stat(&fscache_n_op_pend);
56297 + fscache_stat_unchecked(&fscache_n_op_pend);
56298 ret = 0;
56299 } else if (fscache_object_is_dying(object)) {
56300 - fscache_stat(&fscache_n_op_rejected);
56301 + fscache_stat_unchecked(&fscache_n_op_rejected);
56302 op->state = FSCACHE_OP_ST_CANCELLED;
56303 ret = -ENOBUFS;
56304 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56305 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56306 ret = -EBUSY;
56307 if (op->state == FSCACHE_OP_ST_PENDING) {
56308 ASSERT(!list_empty(&op->pend_link));
56309 - fscache_stat(&fscache_n_op_cancelled);
56310 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56311 list_del_init(&op->pend_link);
56312 if (do_cancel)
56313 do_cancel(op);
56314 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56315 while (!list_empty(&object->pending_ops)) {
56316 op = list_entry(object->pending_ops.next,
56317 struct fscache_operation, pend_link);
56318 - fscache_stat(&fscache_n_op_cancelled);
56319 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56320 list_del_init(&op->pend_link);
56321
56322 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56323 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56324 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56325 op->state = FSCACHE_OP_ST_DEAD;
56326
56327 - fscache_stat(&fscache_n_op_release);
56328 + fscache_stat_unchecked(&fscache_n_op_release);
56329
56330 if (op->release) {
56331 op->release(op);
56332 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56333 * lock, and defer it otherwise */
56334 if (!spin_trylock(&object->lock)) {
56335 _debug("defer put");
56336 - fscache_stat(&fscache_n_op_deferred_release);
56337 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56338
56339 cache = object->cache;
56340 spin_lock(&cache->op_gc_list_lock);
56341 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56342
56343 _debug("GC DEFERRED REL OBJ%x OP%x",
56344 object->debug_id, op->debug_id);
56345 - fscache_stat(&fscache_n_op_gc);
56346 + fscache_stat_unchecked(&fscache_n_op_gc);
56347
56348 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56349 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56350 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56351 index d479ab3..727a7f2 100644
56352 --- a/fs/fscache/page.c
56353 +++ b/fs/fscache/page.c
56354 @@ -61,7 +61,7 @@ try_again:
56355 val = radix_tree_lookup(&cookie->stores, page->index);
56356 if (!val) {
56357 rcu_read_unlock();
56358 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56359 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56360 __fscache_uncache_page(cookie, page);
56361 return true;
56362 }
56363 @@ -91,11 +91,11 @@ try_again:
56364 spin_unlock(&cookie->stores_lock);
56365
56366 if (xpage) {
56367 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56368 - fscache_stat(&fscache_n_store_radix_deletes);
56369 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56370 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56371 ASSERTCMP(xpage, ==, page);
56372 } else {
56373 - fscache_stat(&fscache_n_store_vmscan_gone);
56374 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56375 }
56376
56377 wake_up_bit(&cookie->flags, 0);
56378 @@ -110,11 +110,11 @@ page_busy:
56379 * sleeping on memory allocation, so we may need to impose a timeout
56380 * too. */
56381 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56382 - fscache_stat(&fscache_n_store_vmscan_busy);
56383 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56384 return false;
56385 }
56386
56387 - fscache_stat(&fscache_n_store_vmscan_wait);
56388 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56389 __fscache_wait_on_page_write(cookie, page);
56390 gfp &= ~__GFP_WAIT;
56391 goto try_again;
56392 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56393 FSCACHE_COOKIE_STORING_TAG);
56394 if (!radix_tree_tag_get(&cookie->stores, page->index,
56395 FSCACHE_COOKIE_PENDING_TAG)) {
56396 - fscache_stat(&fscache_n_store_radix_deletes);
56397 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56398 xpage = radix_tree_delete(&cookie->stores, page->index);
56399 }
56400 spin_unlock(&cookie->stores_lock);
56401 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56402
56403 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56404
56405 - fscache_stat(&fscache_n_attr_changed_calls);
56406 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56407
56408 if (fscache_object_is_active(object) &&
56409 fscache_use_cookie(object)) {
56410 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56411
56412 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56413
56414 - fscache_stat(&fscache_n_attr_changed);
56415 + fscache_stat_unchecked(&fscache_n_attr_changed);
56416
56417 op = kzalloc(sizeof(*op), GFP_KERNEL);
56418 if (!op) {
56419 - fscache_stat(&fscache_n_attr_changed_nomem);
56420 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56421 _leave(" = -ENOMEM");
56422 return -ENOMEM;
56423 }
56424 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56425 if (fscache_submit_exclusive_op(object, op) < 0)
56426 goto nobufs;
56427 spin_unlock(&cookie->lock);
56428 - fscache_stat(&fscache_n_attr_changed_ok);
56429 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56430 fscache_put_operation(op);
56431 _leave(" = 0");
56432 return 0;
56433 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56434 nobufs:
56435 spin_unlock(&cookie->lock);
56436 kfree(op);
56437 - fscache_stat(&fscache_n_attr_changed_nobufs);
56438 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56439 _leave(" = %d", -ENOBUFS);
56440 return -ENOBUFS;
56441 }
56442 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56443 /* allocate a retrieval operation and attempt to submit it */
56444 op = kzalloc(sizeof(*op), GFP_NOIO);
56445 if (!op) {
56446 - fscache_stat(&fscache_n_retrievals_nomem);
56447 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56448 return NULL;
56449 }
56450
56451 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56452 return 0;
56453 }
56454
56455 - fscache_stat(&fscache_n_retrievals_wait);
56456 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56457
56458 jif = jiffies;
56459 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56460 fscache_wait_bit_interruptible,
56461 TASK_INTERRUPTIBLE) != 0) {
56462 - fscache_stat(&fscache_n_retrievals_intr);
56463 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56464 _leave(" = -ERESTARTSYS");
56465 return -ERESTARTSYS;
56466 }
56467 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56468 */
56469 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56470 struct fscache_retrieval *op,
56471 - atomic_t *stat_op_waits,
56472 - atomic_t *stat_object_dead)
56473 + atomic_unchecked_t *stat_op_waits,
56474 + atomic_unchecked_t *stat_object_dead)
56475 {
56476 int ret;
56477
56478 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56479 goto check_if_dead;
56480
56481 _debug(">>> WT");
56482 - fscache_stat(stat_op_waits);
56483 + fscache_stat_unchecked(stat_op_waits);
56484 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56485 fscache_wait_bit_interruptible,
56486 TASK_INTERRUPTIBLE) != 0) {
56487 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56488
56489 check_if_dead:
56490 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56491 - fscache_stat(stat_object_dead);
56492 + fscache_stat_unchecked(stat_object_dead);
56493 _leave(" = -ENOBUFS [cancelled]");
56494 return -ENOBUFS;
56495 }
56496 if (unlikely(fscache_object_is_dead(object))) {
56497 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56498 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56499 - fscache_stat(stat_object_dead);
56500 + fscache_stat_unchecked(stat_object_dead);
56501 return -ENOBUFS;
56502 }
56503 return 0;
56504 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56505
56506 _enter("%p,%p,,,", cookie, page);
56507
56508 - fscache_stat(&fscache_n_retrievals);
56509 + fscache_stat_unchecked(&fscache_n_retrievals);
56510
56511 if (hlist_empty(&cookie->backing_objects))
56512 goto nobufs;
56513 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56514 goto nobufs_unlock_dec;
56515 spin_unlock(&cookie->lock);
56516
56517 - fscache_stat(&fscache_n_retrieval_ops);
56518 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56519
56520 /* pin the netfs read context in case we need to do the actual netfs
56521 * read because we've encountered a cache read failure */
56522 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56523
56524 error:
56525 if (ret == -ENOMEM)
56526 - fscache_stat(&fscache_n_retrievals_nomem);
56527 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56528 else if (ret == -ERESTARTSYS)
56529 - fscache_stat(&fscache_n_retrievals_intr);
56530 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56531 else if (ret == -ENODATA)
56532 - fscache_stat(&fscache_n_retrievals_nodata);
56533 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56534 else if (ret < 0)
56535 - fscache_stat(&fscache_n_retrievals_nobufs);
56536 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56537 else
56538 - fscache_stat(&fscache_n_retrievals_ok);
56539 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56540
56541 fscache_put_retrieval(op);
56542 _leave(" = %d", ret);
56543 @@ -475,7 +475,7 @@ nobufs_unlock:
56544 atomic_dec(&cookie->n_active);
56545 kfree(op);
56546 nobufs:
56547 - fscache_stat(&fscache_n_retrievals_nobufs);
56548 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56549 _leave(" = -ENOBUFS");
56550 return -ENOBUFS;
56551 }
56552 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56553
56554 _enter("%p,,%d,,,", cookie, *nr_pages);
56555
56556 - fscache_stat(&fscache_n_retrievals);
56557 + fscache_stat_unchecked(&fscache_n_retrievals);
56558
56559 if (hlist_empty(&cookie->backing_objects))
56560 goto nobufs;
56561 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56562 goto nobufs_unlock_dec;
56563 spin_unlock(&cookie->lock);
56564
56565 - fscache_stat(&fscache_n_retrieval_ops);
56566 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56567
56568 /* pin the netfs read context in case we need to do the actual netfs
56569 * read because we've encountered a cache read failure */
56570 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56571
56572 error:
56573 if (ret == -ENOMEM)
56574 - fscache_stat(&fscache_n_retrievals_nomem);
56575 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56576 else if (ret == -ERESTARTSYS)
56577 - fscache_stat(&fscache_n_retrievals_intr);
56578 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56579 else if (ret == -ENODATA)
56580 - fscache_stat(&fscache_n_retrievals_nodata);
56581 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56582 else if (ret < 0)
56583 - fscache_stat(&fscache_n_retrievals_nobufs);
56584 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56585 else
56586 - fscache_stat(&fscache_n_retrievals_ok);
56587 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56588
56589 fscache_put_retrieval(op);
56590 _leave(" = %d", ret);
56591 @@ -600,7 +600,7 @@ nobufs_unlock:
56592 atomic_dec(&cookie->n_active);
56593 kfree(op);
56594 nobufs:
56595 - fscache_stat(&fscache_n_retrievals_nobufs);
56596 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56597 _leave(" = -ENOBUFS");
56598 return -ENOBUFS;
56599 }
56600 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56601
56602 _enter("%p,%p,,,", cookie, page);
56603
56604 - fscache_stat(&fscache_n_allocs);
56605 + fscache_stat_unchecked(&fscache_n_allocs);
56606
56607 if (hlist_empty(&cookie->backing_objects))
56608 goto nobufs;
56609 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56610 goto nobufs_unlock;
56611 spin_unlock(&cookie->lock);
56612
56613 - fscache_stat(&fscache_n_alloc_ops);
56614 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56615
56616 ret = fscache_wait_for_retrieval_activation(
56617 object, op,
56618 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56619
56620 error:
56621 if (ret == -ERESTARTSYS)
56622 - fscache_stat(&fscache_n_allocs_intr);
56623 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56624 else if (ret < 0)
56625 - fscache_stat(&fscache_n_allocs_nobufs);
56626 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56627 else
56628 - fscache_stat(&fscache_n_allocs_ok);
56629 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56630
56631 fscache_put_retrieval(op);
56632 _leave(" = %d", ret);
56633 @@ -687,7 +687,7 @@ nobufs_unlock:
56634 atomic_dec(&cookie->n_active);
56635 kfree(op);
56636 nobufs:
56637 - fscache_stat(&fscache_n_allocs_nobufs);
56638 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56639 _leave(" = -ENOBUFS");
56640 return -ENOBUFS;
56641 }
56642 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56643
56644 spin_lock(&cookie->stores_lock);
56645
56646 - fscache_stat(&fscache_n_store_calls);
56647 + fscache_stat_unchecked(&fscache_n_store_calls);
56648
56649 /* find a page to store */
56650 page = NULL;
56651 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56652 page = results[0];
56653 _debug("gang %d [%lx]", n, page->index);
56654 if (page->index > op->store_limit) {
56655 - fscache_stat(&fscache_n_store_pages_over_limit);
56656 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56657 goto superseded;
56658 }
56659
56660 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56661 spin_unlock(&cookie->stores_lock);
56662 spin_unlock(&object->lock);
56663
56664 - fscache_stat(&fscache_n_store_pages);
56665 + fscache_stat_unchecked(&fscache_n_store_pages);
56666 fscache_stat(&fscache_n_cop_write_page);
56667 ret = object->cache->ops->write_page(op, page);
56668 fscache_stat_d(&fscache_n_cop_write_page);
56669 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56670 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56671 ASSERT(PageFsCache(page));
56672
56673 - fscache_stat(&fscache_n_stores);
56674 + fscache_stat_unchecked(&fscache_n_stores);
56675
56676 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56677 _leave(" = -ENOBUFS [invalidating]");
56678 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56679 spin_unlock(&cookie->stores_lock);
56680 spin_unlock(&object->lock);
56681
56682 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56683 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56684 op->store_limit = object->store_limit;
56685
56686 atomic_inc(&cookie->n_active);
56687 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56688
56689 spin_unlock(&cookie->lock);
56690 radix_tree_preload_end();
56691 - fscache_stat(&fscache_n_store_ops);
56692 - fscache_stat(&fscache_n_stores_ok);
56693 + fscache_stat_unchecked(&fscache_n_store_ops);
56694 + fscache_stat_unchecked(&fscache_n_stores_ok);
56695
56696 /* the work queue now carries its own ref on the object */
56697 fscache_put_operation(&op->op);
56698 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56699 return 0;
56700
56701 already_queued:
56702 - fscache_stat(&fscache_n_stores_again);
56703 + fscache_stat_unchecked(&fscache_n_stores_again);
56704 already_pending:
56705 spin_unlock(&cookie->stores_lock);
56706 spin_unlock(&object->lock);
56707 spin_unlock(&cookie->lock);
56708 radix_tree_preload_end();
56709 kfree(op);
56710 - fscache_stat(&fscache_n_stores_ok);
56711 + fscache_stat_unchecked(&fscache_n_stores_ok);
56712 _leave(" = 0");
56713 return 0;
56714
56715 @@ -976,14 +976,14 @@ nobufs:
56716 spin_unlock(&cookie->lock);
56717 radix_tree_preload_end();
56718 kfree(op);
56719 - fscache_stat(&fscache_n_stores_nobufs);
56720 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56721 _leave(" = -ENOBUFS");
56722 return -ENOBUFS;
56723
56724 nomem_free:
56725 kfree(op);
56726 nomem:
56727 - fscache_stat(&fscache_n_stores_oom);
56728 + fscache_stat_unchecked(&fscache_n_stores_oom);
56729 _leave(" = -ENOMEM");
56730 return -ENOMEM;
56731 }
56732 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56733 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56734 ASSERTCMP(page, !=, NULL);
56735
56736 - fscache_stat(&fscache_n_uncaches);
56737 + fscache_stat_unchecked(&fscache_n_uncaches);
56738
56739 /* cache withdrawal may beat us to it */
56740 if (!PageFsCache(page))
56741 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56742 struct fscache_cookie *cookie = op->op.object->cookie;
56743
56744 #ifdef CONFIG_FSCACHE_STATS
56745 - atomic_inc(&fscache_n_marks);
56746 + atomic_inc_unchecked(&fscache_n_marks);
56747 #endif
56748
56749 _debug("- mark %p{%lx}", page, page->index);
56750 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56751 index 40d13c7..ddf52b9 100644
56752 --- a/fs/fscache/stats.c
56753 +++ b/fs/fscache/stats.c
56754 @@ -18,99 +18,99 @@
56755 /*
56756 * operation counters
56757 */
56758 -atomic_t fscache_n_op_pend;
56759 -atomic_t fscache_n_op_run;
56760 -atomic_t fscache_n_op_enqueue;
56761 -atomic_t fscache_n_op_requeue;
56762 -atomic_t fscache_n_op_deferred_release;
56763 -atomic_t fscache_n_op_release;
56764 -atomic_t fscache_n_op_gc;
56765 -atomic_t fscache_n_op_cancelled;
56766 -atomic_t fscache_n_op_rejected;
56767 +atomic_unchecked_t fscache_n_op_pend;
56768 +atomic_unchecked_t fscache_n_op_run;
56769 +atomic_unchecked_t fscache_n_op_enqueue;
56770 +atomic_unchecked_t fscache_n_op_requeue;
56771 +atomic_unchecked_t fscache_n_op_deferred_release;
56772 +atomic_unchecked_t fscache_n_op_release;
56773 +atomic_unchecked_t fscache_n_op_gc;
56774 +atomic_unchecked_t fscache_n_op_cancelled;
56775 +atomic_unchecked_t fscache_n_op_rejected;
56776
56777 -atomic_t fscache_n_attr_changed;
56778 -atomic_t fscache_n_attr_changed_ok;
56779 -atomic_t fscache_n_attr_changed_nobufs;
56780 -atomic_t fscache_n_attr_changed_nomem;
56781 -atomic_t fscache_n_attr_changed_calls;
56782 +atomic_unchecked_t fscache_n_attr_changed;
56783 +atomic_unchecked_t fscache_n_attr_changed_ok;
56784 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56785 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56786 +atomic_unchecked_t fscache_n_attr_changed_calls;
56787
56788 -atomic_t fscache_n_allocs;
56789 -atomic_t fscache_n_allocs_ok;
56790 -atomic_t fscache_n_allocs_wait;
56791 -atomic_t fscache_n_allocs_nobufs;
56792 -atomic_t fscache_n_allocs_intr;
56793 -atomic_t fscache_n_allocs_object_dead;
56794 -atomic_t fscache_n_alloc_ops;
56795 -atomic_t fscache_n_alloc_op_waits;
56796 +atomic_unchecked_t fscache_n_allocs;
56797 +atomic_unchecked_t fscache_n_allocs_ok;
56798 +atomic_unchecked_t fscache_n_allocs_wait;
56799 +atomic_unchecked_t fscache_n_allocs_nobufs;
56800 +atomic_unchecked_t fscache_n_allocs_intr;
56801 +atomic_unchecked_t fscache_n_allocs_object_dead;
56802 +atomic_unchecked_t fscache_n_alloc_ops;
56803 +atomic_unchecked_t fscache_n_alloc_op_waits;
56804
56805 -atomic_t fscache_n_retrievals;
56806 -atomic_t fscache_n_retrievals_ok;
56807 -atomic_t fscache_n_retrievals_wait;
56808 -atomic_t fscache_n_retrievals_nodata;
56809 -atomic_t fscache_n_retrievals_nobufs;
56810 -atomic_t fscache_n_retrievals_intr;
56811 -atomic_t fscache_n_retrievals_nomem;
56812 -atomic_t fscache_n_retrievals_object_dead;
56813 -atomic_t fscache_n_retrieval_ops;
56814 -atomic_t fscache_n_retrieval_op_waits;
56815 +atomic_unchecked_t fscache_n_retrievals;
56816 +atomic_unchecked_t fscache_n_retrievals_ok;
56817 +atomic_unchecked_t fscache_n_retrievals_wait;
56818 +atomic_unchecked_t fscache_n_retrievals_nodata;
56819 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56820 +atomic_unchecked_t fscache_n_retrievals_intr;
56821 +atomic_unchecked_t fscache_n_retrievals_nomem;
56822 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56823 +atomic_unchecked_t fscache_n_retrieval_ops;
56824 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56825
56826 -atomic_t fscache_n_stores;
56827 -atomic_t fscache_n_stores_ok;
56828 -atomic_t fscache_n_stores_again;
56829 -atomic_t fscache_n_stores_nobufs;
56830 -atomic_t fscache_n_stores_oom;
56831 -atomic_t fscache_n_store_ops;
56832 -atomic_t fscache_n_store_calls;
56833 -atomic_t fscache_n_store_pages;
56834 -atomic_t fscache_n_store_radix_deletes;
56835 -atomic_t fscache_n_store_pages_over_limit;
56836 +atomic_unchecked_t fscache_n_stores;
56837 +atomic_unchecked_t fscache_n_stores_ok;
56838 +atomic_unchecked_t fscache_n_stores_again;
56839 +atomic_unchecked_t fscache_n_stores_nobufs;
56840 +atomic_unchecked_t fscache_n_stores_oom;
56841 +atomic_unchecked_t fscache_n_store_ops;
56842 +atomic_unchecked_t fscache_n_store_calls;
56843 +atomic_unchecked_t fscache_n_store_pages;
56844 +atomic_unchecked_t fscache_n_store_radix_deletes;
56845 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56846
56847 -atomic_t fscache_n_store_vmscan_not_storing;
56848 -atomic_t fscache_n_store_vmscan_gone;
56849 -atomic_t fscache_n_store_vmscan_busy;
56850 -atomic_t fscache_n_store_vmscan_cancelled;
56851 -atomic_t fscache_n_store_vmscan_wait;
56852 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56853 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56854 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56855 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56856 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56857
56858 -atomic_t fscache_n_marks;
56859 -atomic_t fscache_n_uncaches;
56860 +atomic_unchecked_t fscache_n_marks;
56861 +atomic_unchecked_t fscache_n_uncaches;
56862
56863 -atomic_t fscache_n_acquires;
56864 -atomic_t fscache_n_acquires_null;
56865 -atomic_t fscache_n_acquires_no_cache;
56866 -atomic_t fscache_n_acquires_ok;
56867 -atomic_t fscache_n_acquires_nobufs;
56868 -atomic_t fscache_n_acquires_oom;
56869 +atomic_unchecked_t fscache_n_acquires;
56870 +atomic_unchecked_t fscache_n_acquires_null;
56871 +atomic_unchecked_t fscache_n_acquires_no_cache;
56872 +atomic_unchecked_t fscache_n_acquires_ok;
56873 +atomic_unchecked_t fscache_n_acquires_nobufs;
56874 +atomic_unchecked_t fscache_n_acquires_oom;
56875
56876 -atomic_t fscache_n_invalidates;
56877 -atomic_t fscache_n_invalidates_run;
56878 +atomic_unchecked_t fscache_n_invalidates;
56879 +atomic_unchecked_t fscache_n_invalidates_run;
56880
56881 -atomic_t fscache_n_updates;
56882 -atomic_t fscache_n_updates_null;
56883 -atomic_t fscache_n_updates_run;
56884 +atomic_unchecked_t fscache_n_updates;
56885 +atomic_unchecked_t fscache_n_updates_null;
56886 +atomic_unchecked_t fscache_n_updates_run;
56887
56888 -atomic_t fscache_n_relinquishes;
56889 -atomic_t fscache_n_relinquishes_null;
56890 -atomic_t fscache_n_relinquishes_waitcrt;
56891 -atomic_t fscache_n_relinquishes_retire;
56892 +atomic_unchecked_t fscache_n_relinquishes;
56893 +atomic_unchecked_t fscache_n_relinquishes_null;
56894 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56895 +atomic_unchecked_t fscache_n_relinquishes_retire;
56896
56897 -atomic_t fscache_n_cookie_index;
56898 -atomic_t fscache_n_cookie_data;
56899 -atomic_t fscache_n_cookie_special;
56900 +atomic_unchecked_t fscache_n_cookie_index;
56901 +atomic_unchecked_t fscache_n_cookie_data;
56902 +atomic_unchecked_t fscache_n_cookie_special;
56903
56904 -atomic_t fscache_n_object_alloc;
56905 -atomic_t fscache_n_object_no_alloc;
56906 -atomic_t fscache_n_object_lookups;
56907 -atomic_t fscache_n_object_lookups_negative;
56908 -atomic_t fscache_n_object_lookups_positive;
56909 -atomic_t fscache_n_object_lookups_timed_out;
56910 -atomic_t fscache_n_object_created;
56911 -atomic_t fscache_n_object_avail;
56912 -atomic_t fscache_n_object_dead;
56913 +atomic_unchecked_t fscache_n_object_alloc;
56914 +atomic_unchecked_t fscache_n_object_no_alloc;
56915 +atomic_unchecked_t fscache_n_object_lookups;
56916 +atomic_unchecked_t fscache_n_object_lookups_negative;
56917 +atomic_unchecked_t fscache_n_object_lookups_positive;
56918 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56919 +atomic_unchecked_t fscache_n_object_created;
56920 +atomic_unchecked_t fscache_n_object_avail;
56921 +atomic_unchecked_t fscache_n_object_dead;
56922
56923 -atomic_t fscache_n_checkaux_none;
56924 -atomic_t fscache_n_checkaux_okay;
56925 -atomic_t fscache_n_checkaux_update;
56926 -atomic_t fscache_n_checkaux_obsolete;
56927 +atomic_unchecked_t fscache_n_checkaux_none;
56928 +atomic_unchecked_t fscache_n_checkaux_okay;
56929 +atomic_unchecked_t fscache_n_checkaux_update;
56930 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56931
56932 atomic_t fscache_n_cop_alloc_object;
56933 atomic_t fscache_n_cop_lookup_object;
56934 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
56935 seq_puts(m, "FS-Cache statistics\n");
56936
56937 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
56938 - atomic_read(&fscache_n_cookie_index),
56939 - atomic_read(&fscache_n_cookie_data),
56940 - atomic_read(&fscache_n_cookie_special));
56941 + atomic_read_unchecked(&fscache_n_cookie_index),
56942 + atomic_read_unchecked(&fscache_n_cookie_data),
56943 + atomic_read_unchecked(&fscache_n_cookie_special));
56944
56945 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
56946 - atomic_read(&fscache_n_object_alloc),
56947 - atomic_read(&fscache_n_object_no_alloc),
56948 - atomic_read(&fscache_n_object_avail),
56949 - atomic_read(&fscache_n_object_dead));
56950 + atomic_read_unchecked(&fscache_n_object_alloc),
56951 + atomic_read_unchecked(&fscache_n_object_no_alloc),
56952 + atomic_read_unchecked(&fscache_n_object_avail),
56953 + atomic_read_unchecked(&fscache_n_object_dead));
56954 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
56955 - atomic_read(&fscache_n_checkaux_none),
56956 - atomic_read(&fscache_n_checkaux_okay),
56957 - atomic_read(&fscache_n_checkaux_update),
56958 - atomic_read(&fscache_n_checkaux_obsolete));
56959 + atomic_read_unchecked(&fscache_n_checkaux_none),
56960 + atomic_read_unchecked(&fscache_n_checkaux_okay),
56961 + atomic_read_unchecked(&fscache_n_checkaux_update),
56962 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
56963
56964 seq_printf(m, "Pages : mrk=%u unc=%u\n",
56965 - atomic_read(&fscache_n_marks),
56966 - atomic_read(&fscache_n_uncaches));
56967 + atomic_read_unchecked(&fscache_n_marks),
56968 + atomic_read_unchecked(&fscache_n_uncaches));
56969
56970 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
56971 " oom=%u\n",
56972 - atomic_read(&fscache_n_acquires),
56973 - atomic_read(&fscache_n_acquires_null),
56974 - atomic_read(&fscache_n_acquires_no_cache),
56975 - atomic_read(&fscache_n_acquires_ok),
56976 - atomic_read(&fscache_n_acquires_nobufs),
56977 - atomic_read(&fscache_n_acquires_oom));
56978 + atomic_read_unchecked(&fscache_n_acquires),
56979 + atomic_read_unchecked(&fscache_n_acquires_null),
56980 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
56981 + atomic_read_unchecked(&fscache_n_acquires_ok),
56982 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
56983 + atomic_read_unchecked(&fscache_n_acquires_oom));
56984
56985 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
56986 - atomic_read(&fscache_n_object_lookups),
56987 - atomic_read(&fscache_n_object_lookups_negative),
56988 - atomic_read(&fscache_n_object_lookups_positive),
56989 - atomic_read(&fscache_n_object_created),
56990 - atomic_read(&fscache_n_object_lookups_timed_out));
56991 + atomic_read_unchecked(&fscache_n_object_lookups),
56992 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
56993 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
56994 + atomic_read_unchecked(&fscache_n_object_created),
56995 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
56996
56997 seq_printf(m, "Invals : n=%u run=%u\n",
56998 - atomic_read(&fscache_n_invalidates),
56999 - atomic_read(&fscache_n_invalidates_run));
57000 + atomic_read_unchecked(&fscache_n_invalidates),
57001 + atomic_read_unchecked(&fscache_n_invalidates_run));
57002
57003 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57004 - atomic_read(&fscache_n_updates),
57005 - atomic_read(&fscache_n_updates_null),
57006 - atomic_read(&fscache_n_updates_run));
57007 + atomic_read_unchecked(&fscache_n_updates),
57008 + atomic_read_unchecked(&fscache_n_updates_null),
57009 + atomic_read_unchecked(&fscache_n_updates_run));
57010
57011 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57012 - atomic_read(&fscache_n_relinquishes),
57013 - atomic_read(&fscache_n_relinquishes_null),
57014 - atomic_read(&fscache_n_relinquishes_waitcrt),
57015 - atomic_read(&fscache_n_relinquishes_retire));
57016 + atomic_read_unchecked(&fscache_n_relinquishes),
57017 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57018 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57019 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57020
57021 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57022 - atomic_read(&fscache_n_attr_changed),
57023 - atomic_read(&fscache_n_attr_changed_ok),
57024 - atomic_read(&fscache_n_attr_changed_nobufs),
57025 - atomic_read(&fscache_n_attr_changed_nomem),
57026 - atomic_read(&fscache_n_attr_changed_calls));
57027 + atomic_read_unchecked(&fscache_n_attr_changed),
57028 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57029 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57030 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57031 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57032
57033 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57034 - atomic_read(&fscache_n_allocs),
57035 - atomic_read(&fscache_n_allocs_ok),
57036 - atomic_read(&fscache_n_allocs_wait),
57037 - atomic_read(&fscache_n_allocs_nobufs),
57038 - atomic_read(&fscache_n_allocs_intr));
57039 + atomic_read_unchecked(&fscache_n_allocs),
57040 + atomic_read_unchecked(&fscache_n_allocs_ok),
57041 + atomic_read_unchecked(&fscache_n_allocs_wait),
57042 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57043 + atomic_read_unchecked(&fscache_n_allocs_intr));
57044 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57045 - atomic_read(&fscache_n_alloc_ops),
57046 - atomic_read(&fscache_n_alloc_op_waits),
57047 - atomic_read(&fscache_n_allocs_object_dead));
57048 + atomic_read_unchecked(&fscache_n_alloc_ops),
57049 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57050 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57051
57052 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57053 " int=%u oom=%u\n",
57054 - atomic_read(&fscache_n_retrievals),
57055 - atomic_read(&fscache_n_retrievals_ok),
57056 - atomic_read(&fscache_n_retrievals_wait),
57057 - atomic_read(&fscache_n_retrievals_nodata),
57058 - atomic_read(&fscache_n_retrievals_nobufs),
57059 - atomic_read(&fscache_n_retrievals_intr),
57060 - atomic_read(&fscache_n_retrievals_nomem));
57061 + atomic_read_unchecked(&fscache_n_retrievals),
57062 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57063 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57064 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57065 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57066 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57067 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57068 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57069 - atomic_read(&fscache_n_retrieval_ops),
57070 - atomic_read(&fscache_n_retrieval_op_waits),
57071 - atomic_read(&fscache_n_retrievals_object_dead));
57072 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57073 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57074 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57075
57076 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57077 - atomic_read(&fscache_n_stores),
57078 - atomic_read(&fscache_n_stores_ok),
57079 - atomic_read(&fscache_n_stores_again),
57080 - atomic_read(&fscache_n_stores_nobufs),
57081 - atomic_read(&fscache_n_stores_oom));
57082 + atomic_read_unchecked(&fscache_n_stores),
57083 + atomic_read_unchecked(&fscache_n_stores_ok),
57084 + atomic_read_unchecked(&fscache_n_stores_again),
57085 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57086 + atomic_read_unchecked(&fscache_n_stores_oom));
57087 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57088 - atomic_read(&fscache_n_store_ops),
57089 - atomic_read(&fscache_n_store_calls),
57090 - atomic_read(&fscache_n_store_pages),
57091 - atomic_read(&fscache_n_store_radix_deletes),
57092 - atomic_read(&fscache_n_store_pages_over_limit));
57093 + atomic_read_unchecked(&fscache_n_store_ops),
57094 + atomic_read_unchecked(&fscache_n_store_calls),
57095 + atomic_read_unchecked(&fscache_n_store_pages),
57096 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57097 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57098
57099 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57100 - atomic_read(&fscache_n_store_vmscan_not_storing),
57101 - atomic_read(&fscache_n_store_vmscan_gone),
57102 - atomic_read(&fscache_n_store_vmscan_busy),
57103 - atomic_read(&fscache_n_store_vmscan_cancelled),
57104 - atomic_read(&fscache_n_store_vmscan_wait));
57105 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57106 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57107 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57108 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57109 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57110
57111 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57112 - atomic_read(&fscache_n_op_pend),
57113 - atomic_read(&fscache_n_op_run),
57114 - atomic_read(&fscache_n_op_enqueue),
57115 - atomic_read(&fscache_n_op_cancelled),
57116 - atomic_read(&fscache_n_op_rejected));
57117 + atomic_read_unchecked(&fscache_n_op_pend),
57118 + atomic_read_unchecked(&fscache_n_op_run),
57119 + atomic_read_unchecked(&fscache_n_op_enqueue),
57120 + atomic_read_unchecked(&fscache_n_op_cancelled),
57121 + atomic_read_unchecked(&fscache_n_op_rejected));
57122 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57123 - atomic_read(&fscache_n_op_deferred_release),
57124 - atomic_read(&fscache_n_op_release),
57125 - atomic_read(&fscache_n_op_gc));
57126 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57127 + atomic_read_unchecked(&fscache_n_op_release),
57128 + atomic_read_unchecked(&fscache_n_op_gc));
57129
57130 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57131 atomic_read(&fscache_n_cop_alloc_object),
57132 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57133 index aef34b1..59bfd7b 100644
57134 --- a/fs/fuse/cuse.c
57135 +++ b/fs/fuse/cuse.c
57136 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57137 INIT_LIST_HEAD(&cuse_conntbl[i]);
57138
57139 /* inherit and extend fuse_dev_operations */
57140 - cuse_channel_fops = fuse_dev_operations;
57141 - cuse_channel_fops.owner = THIS_MODULE;
57142 - cuse_channel_fops.open = cuse_channel_open;
57143 - cuse_channel_fops.release = cuse_channel_release;
57144 + pax_open_kernel();
57145 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57146 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57147 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57148 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57149 + pax_close_kernel();
57150
57151 cuse_class = class_create(THIS_MODULE, "cuse");
57152 if (IS_ERR(cuse_class))
57153 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57154 index 1d55f94..088da65 100644
57155 --- a/fs/fuse/dev.c
57156 +++ b/fs/fuse/dev.c
57157 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57158 ret = 0;
57159 pipe_lock(pipe);
57160
57161 - if (!pipe->readers) {
57162 + if (!atomic_read(&pipe->readers)) {
57163 send_sig(SIGPIPE, current, 0);
57164 if (!ret)
57165 ret = -EPIPE;
57166 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57167 page_nr++;
57168 ret += buf->len;
57169
57170 - if (pipe->files)
57171 + if (atomic_read(&pipe->files))
57172 do_wakeup = 1;
57173 }
57174
57175 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57176 index 8fec28f..cd40dba 100644
57177 --- a/fs/fuse/dir.c
57178 +++ b/fs/fuse/dir.c
57179 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57180 return link;
57181 }
57182
57183 -static void free_link(char *link)
57184 +static void free_link(const char *link)
57185 {
57186 if (!IS_ERR(link))
57187 free_page((unsigned long) link);
57188 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57189 index 64915ee..6bed500 100644
57190 --- a/fs/gfs2/inode.c
57191 +++ b/fs/gfs2/inode.c
57192 @@ -1506,7 +1506,7 @@ out:
57193
57194 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57195 {
57196 - char *s = nd_get_link(nd);
57197 + const char *s = nd_get_link(nd);
57198 if (!IS_ERR(s))
57199 kfree(s);
57200 }
57201 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57202 index d19b30a..ef89c36 100644
57203 --- a/fs/hugetlbfs/inode.c
57204 +++ b/fs/hugetlbfs/inode.c
57205 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57206 struct mm_struct *mm = current->mm;
57207 struct vm_area_struct *vma;
57208 struct hstate *h = hstate_file(file);
57209 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57210 struct vm_unmapped_area_info info;
57211
57212 if (len & ~huge_page_mask(h))
57213 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57214 return addr;
57215 }
57216
57217 +#ifdef CONFIG_PAX_RANDMMAP
57218 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57219 +#endif
57220 +
57221 if (addr) {
57222 addr = ALIGN(addr, huge_page_size(h));
57223 vma = find_vma(mm, addr);
57224 - if (TASK_SIZE - len >= addr &&
57225 - (!vma || addr + len <= vma->vm_start))
57226 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57227 return addr;
57228 }
57229
57230 info.flags = 0;
57231 info.length = len;
57232 info.low_limit = TASK_UNMAPPED_BASE;
57233 +
57234 +#ifdef CONFIG_PAX_RANDMMAP
57235 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57236 + info.low_limit += mm->delta_mmap;
57237 +#endif
57238 +
57239 info.high_limit = TASK_SIZE;
57240 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57241 info.align_offset = 0;
57242 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57243 };
57244 MODULE_ALIAS_FS("hugetlbfs");
57245
57246 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57247 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57248
57249 static int can_do_hugetlb_shm(void)
57250 {
57251 diff --git a/fs/inode.c b/fs/inode.c
57252 index d6dfb09..602e77e 100644
57253 --- a/fs/inode.c
57254 +++ b/fs/inode.c
57255 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57256
57257 #ifdef CONFIG_SMP
57258 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57259 - static atomic_t shared_last_ino;
57260 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57261 + static atomic_unchecked_t shared_last_ino;
57262 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57263
57264 res = next - LAST_INO_BATCH;
57265 }
57266 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57267 index 4a6cf28..d3a29d3 100644
57268 --- a/fs/jffs2/erase.c
57269 +++ b/fs/jffs2/erase.c
57270 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57271 struct jffs2_unknown_node marker = {
57272 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57273 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57274 - .totlen = cpu_to_je32(c->cleanmarker_size)
57275 + .totlen = cpu_to_je32(c->cleanmarker_size),
57276 + .hdr_crc = cpu_to_je32(0)
57277 };
57278
57279 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57280 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57281 index a6597d6..41b30ec 100644
57282 --- a/fs/jffs2/wbuf.c
57283 +++ b/fs/jffs2/wbuf.c
57284 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57285 {
57286 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57287 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57288 - .totlen = constant_cpu_to_je32(8)
57289 + .totlen = constant_cpu_to_je32(8),
57290 + .hdr_crc = constant_cpu_to_je32(0)
57291 };
57292
57293 /*
57294 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57295 index 6669aa2..36b033d 100644
57296 --- a/fs/jfs/super.c
57297 +++ b/fs/jfs/super.c
57298 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57299
57300 jfs_inode_cachep =
57301 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57302 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57303 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57304 init_once);
57305 if (jfs_inode_cachep == NULL)
57306 return -ENOMEM;
57307 diff --git a/fs/libfs.c b/fs/libfs.c
57308 index 3a3a9b5..3a9b074 100644
57309 --- a/fs/libfs.c
57310 +++ b/fs/libfs.c
57311 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57312
57313 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57314 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57315 + char d_name[sizeof(next->d_iname)];
57316 + const unsigned char *name;
57317 +
57318 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57319 if (!simple_positive(next)) {
57320 spin_unlock(&next->d_lock);
57321 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57322
57323 spin_unlock(&next->d_lock);
57324 spin_unlock(&dentry->d_lock);
57325 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57326 + name = next->d_name.name;
57327 + if (name == next->d_iname) {
57328 + memcpy(d_name, name, next->d_name.len);
57329 + name = d_name;
57330 + }
57331 + if (!dir_emit(ctx, name, next->d_name.len,
57332 next->d_inode->i_ino, dt_type(next->d_inode)))
57333 return 0;
57334 spin_lock(&dentry->d_lock);
57335 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57336 index acd3947..1f896e2 100644
57337 --- a/fs/lockd/clntproc.c
57338 +++ b/fs/lockd/clntproc.c
57339 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57340 /*
57341 * Cookie counter for NLM requests
57342 */
57343 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57344 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57345
57346 void nlmclnt_next_cookie(struct nlm_cookie *c)
57347 {
57348 - u32 cookie = atomic_inc_return(&nlm_cookie);
57349 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57350
57351 memcpy(c->data, &cookie, 4);
57352 c->len=4;
57353 diff --git a/fs/locks.c b/fs/locks.c
57354 index b27a300..4156d0b 100644
57355 --- a/fs/locks.c
57356 +++ b/fs/locks.c
57357 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57358 return;
57359
57360 if (filp->f_op && filp->f_op->flock) {
57361 - struct file_lock fl = {
57362 + struct file_lock flock = {
57363 .fl_pid = current->tgid,
57364 .fl_file = filp,
57365 .fl_flags = FL_FLOCK,
57366 .fl_type = F_UNLCK,
57367 .fl_end = OFFSET_MAX,
57368 };
57369 - filp->f_op->flock(filp, F_SETLKW, &fl);
57370 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57371 - fl.fl_ops->fl_release_private(&fl);
57372 + filp->f_op->flock(filp, F_SETLKW, &flock);
57373 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57374 + flock.fl_ops->fl_release_private(&flock);
57375 }
57376
57377 spin_lock(&inode->i_lock);
57378 diff --git a/fs/namei.c b/fs/namei.c
57379 index 7720fbd..7934bb2 100644
57380 --- a/fs/namei.c
57381 +++ b/fs/namei.c
57382 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57383 if (ret != -EACCES)
57384 return ret;
57385
57386 +#ifdef CONFIG_GRKERNSEC
57387 + /* we'll block if we have to log due to a denied capability use */
57388 + if (mask & MAY_NOT_BLOCK)
57389 + return -ECHILD;
57390 +#endif
57391 +
57392 if (S_ISDIR(inode->i_mode)) {
57393 /* DACs are overridable for directories */
57394 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57395 - return 0;
57396 if (!(mask & MAY_WRITE))
57397 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57398 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57399 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57400 return 0;
57401 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57402 + return 0;
57403 return -EACCES;
57404 }
57405 /*
57406 + * Searching includes executable on directories, else just read.
57407 + */
57408 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57409 + if (mask == MAY_READ)
57410 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57411 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57412 + return 0;
57413 +
57414 + /*
57415 * Read/write DACs are always overridable.
57416 * Executable DACs are overridable when there is
57417 * at least one exec bit set.
57418 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57419 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57420 return 0;
57421
57422 - /*
57423 - * Searching includes executable on directories, else just read.
57424 - */
57425 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57426 - if (mask == MAY_READ)
57427 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57428 - return 0;
57429 -
57430 return -EACCES;
57431 }
57432
57433 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57434 {
57435 struct dentry *dentry = link->dentry;
57436 int error;
57437 - char *s;
57438 + const char *s;
57439
57440 BUG_ON(nd->flags & LOOKUP_RCU);
57441
57442 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57443 if (error)
57444 goto out_put_nd_path;
57445
57446 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57447 + dentry->d_inode, dentry, nd->path.mnt)) {
57448 + error = -EACCES;
57449 + goto out_put_nd_path;
57450 + }
57451 +
57452 nd->last_type = LAST_BIND;
57453 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57454 error = PTR_ERR(*p);
57455 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57456 if (res)
57457 break;
57458 res = walk_component(nd, path, LOOKUP_FOLLOW);
57459 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57460 + res = -EACCES;
57461 put_link(nd, &link, cookie);
57462 } while (res > 0);
57463
57464 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57465 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57466 {
57467 unsigned long a, b, adata, bdata, mask, hash, len;
57468 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57469 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57470
57471 hash = a = 0;
57472 len = -sizeof(unsigned long);
57473 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57474 if (err)
57475 break;
57476 err = lookup_last(nd, &path);
57477 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57478 + err = -EACCES;
57479 put_link(nd, &link, cookie);
57480 }
57481 }
57482 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57483 if (!err)
57484 err = complete_walk(nd);
57485
57486 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57487 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57488 + path_put(&nd->path);
57489 + err = -ENOENT;
57490 + }
57491 + }
57492 +
57493 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57494 if (!can_lookup(nd->inode)) {
57495 path_put(&nd->path);
57496 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57497 retval = path_lookupat(dfd, name->name,
57498 flags | LOOKUP_REVAL, nd);
57499
57500 - if (likely(!retval))
57501 + if (likely(!retval)) {
57502 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57503 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57504 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57505 + path_put(&nd->path);
57506 + return -ENOENT;
57507 + }
57508 + }
57509 + }
57510 return retval;
57511 }
57512
57513 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57514 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57515 return -EPERM;
57516
57517 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57518 + return -EPERM;
57519 + if (gr_handle_rawio(inode))
57520 + return -EPERM;
57521 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57522 + return -EACCES;
57523 +
57524 return 0;
57525 }
57526
57527 @@ -2601,7 +2640,7 @@ looked_up:
57528 * cleared otherwise prior to returning.
57529 */
57530 static int lookup_open(struct nameidata *nd, struct path *path,
57531 - struct file *file,
57532 + struct path *link, struct file *file,
57533 const struct open_flags *op,
57534 bool got_write, int *opened)
57535 {
57536 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57537 /* Negative dentry, just create the file */
57538 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57539 umode_t mode = op->mode;
57540 +
57541 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57542 + error = -EACCES;
57543 + goto out_dput;
57544 + }
57545 +
57546 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57547 + error = -EACCES;
57548 + goto out_dput;
57549 + }
57550 +
57551 if (!IS_POSIXACL(dir->d_inode))
57552 mode &= ~current_umask();
57553 /*
57554 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57555 nd->flags & LOOKUP_EXCL);
57556 if (error)
57557 goto out_dput;
57558 + else
57559 + gr_handle_create(dentry, nd->path.mnt);
57560 }
57561 out_no_open:
57562 path->dentry = dentry;
57563 @@ -2671,7 +2723,7 @@ out_dput:
57564 /*
57565 * Handle the last step of open()
57566 */
57567 -static int do_last(struct nameidata *nd, struct path *path,
57568 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57569 struct file *file, const struct open_flags *op,
57570 int *opened, struct filename *name)
57571 {
57572 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57573 if (error)
57574 return error;
57575
57576 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57577 + error = -ENOENT;
57578 + goto out;
57579 + }
57580 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57581 + error = -EACCES;
57582 + goto out;
57583 + }
57584 +
57585 audit_inode(name, dir, LOOKUP_PARENT);
57586 error = -EISDIR;
57587 /* trailing slashes? */
57588 @@ -2740,7 +2801,7 @@ retry_lookup:
57589 */
57590 }
57591 mutex_lock(&dir->d_inode->i_mutex);
57592 - error = lookup_open(nd, path, file, op, got_write, opened);
57593 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57594 mutex_unlock(&dir->d_inode->i_mutex);
57595
57596 if (error <= 0) {
57597 @@ -2764,11 +2825,28 @@ retry_lookup:
57598 goto finish_open_created;
57599 }
57600
57601 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57602 + error = -ENOENT;
57603 + goto exit_dput;
57604 + }
57605 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57606 + error = -EACCES;
57607 + goto exit_dput;
57608 + }
57609 +
57610 /*
57611 * create/update audit record if it already exists.
57612 */
57613 - if (path->dentry->d_inode)
57614 + if (path->dentry->d_inode) {
57615 + /* only check if O_CREAT is specified, all other checks need to go
57616 + into may_open */
57617 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57618 + error = -EACCES;
57619 + goto exit_dput;
57620 + }
57621 +
57622 audit_inode(name, path->dentry, 0);
57623 + }
57624
57625 /*
57626 * If atomic_open() acquired write access it is dropped now due to
57627 @@ -2809,6 +2887,11 @@ finish_lookup:
57628 }
57629 }
57630 BUG_ON(inode != path->dentry->d_inode);
57631 + /* if we're resolving a symlink to another symlink */
57632 + if (link && gr_handle_symlink_owner(link, inode)) {
57633 + error = -EACCES;
57634 + goto out;
57635 + }
57636 return 1;
57637 }
57638
57639 @@ -2818,7 +2901,6 @@ finish_lookup:
57640 save_parent.dentry = nd->path.dentry;
57641 save_parent.mnt = mntget(path->mnt);
57642 nd->path.dentry = path->dentry;
57643 -
57644 }
57645 nd->inode = inode;
57646 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57647 @@ -2828,7 +2910,18 @@ finish_open:
57648 path_put(&save_parent);
57649 return error;
57650 }
57651 +
57652 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57653 + error = -ENOENT;
57654 + goto out;
57655 + }
57656 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57657 + error = -EACCES;
57658 + goto out;
57659 + }
57660 +
57661 audit_inode(name, nd->path.dentry, 0);
57662 +
57663 error = -EISDIR;
57664 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57665 goto out;
57666 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57667 if (unlikely(error))
57668 goto out;
57669
57670 - error = do_last(nd, &path, file, op, &opened, pathname);
57671 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57672 while (unlikely(error > 0)) { /* trailing symlink */
57673 struct path link = path;
57674 void *cookie;
57675 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57676 error = follow_link(&link, nd, &cookie);
57677 if (unlikely(error))
57678 break;
57679 - error = do_last(nd, &path, file, op, &opened, pathname);
57680 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57681 put_link(nd, &link, cookie);
57682 }
57683 out:
57684 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57685 goto unlock;
57686
57687 error = -EEXIST;
57688 - if (dentry->d_inode)
57689 + if (dentry->d_inode) {
57690 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57691 + error = -ENOENT;
57692 + }
57693 goto fail;
57694 + }
57695 /*
57696 * Special case - lookup gave negative, but... we had foo/bar/
57697 * From the vfs_mknod() POV we just have a negative dentry -
57698 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57699 }
57700 EXPORT_SYMBOL(user_path_create);
57701
57702 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57703 +{
57704 + struct filename *tmp = getname(pathname);
57705 + struct dentry *res;
57706 + if (IS_ERR(tmp))
57707 + return ERR_CAST(tmp);
57708 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57709 + if (IS_ERR(res))
57710 + putname(tmp);
57711 + else
57712 + *to = tmp;
57713 + return res;
57714 +}
57715 +
57716 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57717 {
57718 int error = may_create(dir, dentry);
57719 @@ -3224,6 +3335,17 @@ retry:
57720
57721 if (!IS_POSIXACL(path.dentry->d_inode))
57722 mode &= ~current_umask();
57723 +
57724 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57725 + error = -EPERM;
57726 + goto out;
57727 + }
57728 +
57729 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57730 + error = -EACCES;
57731 + goto out;
57732 + }
57733 +
57734 error = security_path_mknod(&path, dentry, mode, dev);
57735 if (error)
57736 goto out;
57737 @@ -3240,6 +3362,8 @@ retry:
57738 break;
57739 }
57740 out:
57741 + if (!error)
57742 + gr_handle_create(dentry, path.mnt);
57743 done_path_create(&path, dentry);
57744 if (retry_estale(error, lookup_flags)) {
57745 lookup_flags |= LOOKUP_REVAL;
57746 @@ -3292,9 +3416,16 @@ retry:
57747
57748 if (!IS_POSIXACL(path.dentry->d_inode))
57749 mode &= ~current_umask();
57750 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57751 + error = -EACCES;
57752 + goto out;
57753 + }
57754 error = security_path_mkdir(&path, dentry, mode);
57755 if (!error)
57756 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57757 + if (!error)
57758 + gr_handle_create(dentry, path.mnt);
57759 +out:
57760 done_path_create(&path, dentry);
57761 if (retry_estale(error, lookup_flags)) {
57762 lookup_flags |= LOOKUP_REVAL;
57763 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57764 struct filename *name;
57765 struct dentry *dentry;
57766 struct nameidata nd;
57767 + ino_t saved_ino = 0;
57768 + dev_t saved_dev = 0;
57769 unsigned int lookup_flags = 0;
57770 retry:
57771 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57772 @@ -3407,10 +3540,21 @@ retry:
57773 error = -ENOENT;
57774 goto exit3;
57775 }
57776 +
57777 + saved_ino = dentry->d_inode->i_ino;
57778 + saved_dev = gr_get_dev_from_dentry(dentry);
57779 +
57780 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57781 + error = -EACCES;
57782 + goto exit3;
57783 + }
57784 +
57785 error = security_path_rmdir(&nd.path, dentry);
57786 if (error)
57787 goto exit3;
57788 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57789 + if (!error && (saved_dev || saved_ino))
57790 + gr_handle_delete(saved_ino, saved_dev);
57791 exit3:
57792 dput(dentry);
57793 exit2:
57794 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57795 struct dentry *dentry;
57796 struct nameidata nd;
57797 struct inode *inode = NULL;
57798 + ino_t saved_ino = 0;
57799 + dev_t saved_dev = 0;
57800 unsigned int lookup_flags = 0;
57801 retry:
57802 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57803 @@ -3502,10 +3648,22 @@ retry:
57804 if (!inode)
57805 goto slashes;
57806 ihold(inode);
57807 +
57808 + if (inode->i_nlink <= 1) {
57809 + saved_ino = inode->i_ino;
57810 + saved_dev = gr_get_dev_from_dentry(dentry);
57811 + }
57812 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57813 + error = -EACCES;
57814 + goto exit2;
57815 + }
57816 +
57817 error = security_path_unlink(&nd.path, dentry);
57818 if (error)
57819 goto exit2;
57820 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57821 + if (!error && (saved_ino || saved_dev))
57822 + gr_handle_delete(saved_ino, saved_dev);
57823 exit2:
57824 dput(dentry);
57825 }
57826 @@ -3583,9 +3741,17 @@ retry:
57827 if (IS_ERR(dentry))
57828 goto out_putname;
57829
57830 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57831 + error = -EACCES;
57832 + goto out;
57833 + }
57834 +
57835 error = security_path_symlink(&path, dentry, from->name);
57836 if (!error)
57837 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57838 + if (!error)
57839 + gr_handle_create(dentry, path.mnt);
57840 +out:
57841 done_path_create(&path, dentry);
57842 if (retry_estale(error, lookup_flags)) {
57843 lookup_flags |= LOOKUP_REVAL;
57844 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57845 {
57846 struct dentry *new_dentry;
57847 struct path old_path, new_path;
57848 + struct filename *to = NULL;
57849 int how = 0;
57850 int error;
57851
57852 @@ -3688,7 +3855,7 @@ retry:
57853 if (error)
57854 return error;
57855
57856 - new_dentry = user_path_create(newdfd, newname, &new_path,
57857 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57858 (how & LOOKUP_REVAL));
57859 error = PTR_ERR(new_dentry);
57860 if (IS_ERR(new_dentry))
57861 @@ -3700,11 +3867,28 @@ retry:
57862 error = may_linkat(&old_path);
57863 if (unlikely(error))
57864 goto out_dput;
57865 +
57866 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57867 + old_path.dentry->d_inode,
57868 + old_path.dentry->d_inode->i_mode, to)) {
57869 + error = -EACCES;
57870 + goto out_dput;
57871 + }
57872 +
57873 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57874 + old_path.dentry, old_path.mnt, to)) {
57875 + error = -EACCES;
57876 + goto out_dput;
57877 + }
57878 +
57879 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57880 if (error)
57881 goto out_dput;
57882 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57883 + if (!error)
57884 + gr_handle_create(new_dentry, new_path.mnt);
57885 out_dput:
57886 + putname(to);
57887 done_path_create(&new_path, new_dentry);
57888 if (retry_estale(error, how)) {
57889 how |= LOOKUP_REVAL;
57890 @@ -3950,12 +4134,21 @@ retry:
57891 if (new_dentry == trap)
57892 goto exit5;
57893
57894 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57895 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57896 + to);
57897 + if (error)
57898 + goto exit5;
57899 +
57900 error = security_path_rename(&oldnd.path, old_dentry,
57901 &newnd.path, new_dentry);
57902 if (error)
57903 goto exit5;
57904 error = vfs_rename(old_dir->d_inode, old_dentry,
57905 new_dir->d_inode, new_dentry);
57906 + if (!error)
57907 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57908 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57909 exit5:
57910 dput(new_dentry);
57911 exit4:
57912 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57913
57914 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57915 {
57916 + char tmpbuf[64];
57917 + const char *newlink;
57918 int len;
57919
57920 len = PTR_ERR(link);
57921 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57922 len = strlen(link);
57923 if (len > (unsigned) buflen)
57924 len = buflen;
57925 - if (copy_to_user(buffer, link, len))
57926 +
57927 + if (len < sizeof(tmpbuf)) {
57928 + memcpy(tmpbuf, link, len);
57929 + newlink = tmpbuf;
57930 + } else
57931 + newlink = link;
57932 +
57933 + if (copy_to_user(buffer, newlink, len))
57934 len = -EFAULT;
57935 out:
57936 return len;
57937 diff --git a/fs/namespace.c b/fs/namespace.c
57938 index a45ba4f..b4c7d07 100644
57939 --- a/fs/namespace.c
57940 +++ b/fs/namespace.c
57941 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
57942 if (!(sb->s_flags & MS_RDONLY))
57943 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
57944 up_write(&sb->s_umount);
57945 +
57946 + gr_log_remount(mnt->mnt_devname, retval);
57947 +
57948 return retval;
57949 }
57950
57951 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
57952 }
57953 br_write_unlock(&vfsmount_lock);
57954 namespace_unlock();
57955 +
57956 + gr_log_unmount(mnt->mnt_devname, retval);
57957 +
57958 return retval;
57959 }
57960
57961 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
57962 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
57963 */
57964
57965 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
57966 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
57967 {
57968 struct path path;
57969 struct mount *mnt;
57970 @@ -1342,7 +1348,7 @@ out:
57971 /*
57972 * The 2.0 compatible umount. No flags.
57973 */
57974 -SYSCALL_DEFINE1(oldumount, char __user *, name)
57975 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
57976 {
57977 return sys_umount(name, 0);
57978 }
57979 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
57980 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
57981 MS_STRICTATIME);
57982
57983 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
57984 + retval = -EPERM;
57985 + goto dput_out;
57986 + }
57987 +
57988 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
57989 + retval = -EPERM;
57990 + goto dput_out;
57991 + }
57992 +
57993 if (flags & MS_REMOUNT)
57994 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
57995 data_page);
57996 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
57997 dev_name, data_page);
57998 dput_out:
57999 path_put(&path);
58000 +
58001 + gr_log_mount(dev_name, dir_name, retval);
58002 +
58003 return retval;
58004 }
58005
58006 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58007 * number incrementing at 10Ghz will take 12,427 years to wrap which
58008 * is effectively never, so we can ignore the possibility.
58009 */
58010 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58011 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58012
58013 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58014 {
58015 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58016 kfree(new_ns);
58017 return ERR_PTR(ret);
58018 }
58019 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58020 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58021 atomic_set(&new_ns->count, 1);
58022 new_ns->root = NULL;
58023 INIT_LIST_HEAD(&new_ns->list);
58024 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58025 * Allocate a new namespace structure and populate it with contents
58026 * copied from the namespace of the passed in task structure.
58027 */
58028 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58029 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58030 struct user_namespace *user_ns, struct fs_struct *fs)
58031 {
58032 struct mnt_namespace *new_ns;
58033 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58034 }
58035 EXPORT_SYMBOL(mount_subtree);
58036
58037 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58038 - char __user *, type, unsigned long, flags, void __user *, data)
58039 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58040 + const char __user *, type, unsigned long, flags, void __user *, data)
58041 {
58042 int ret;
58043 char *kernel_type;
58044 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58045 if (error)
58046 goto out2;
58047
58048 + if (gr_handle_chroot_pivot()) {
58049 + error = -EPERM;
58050 + goto out2;
58051 + }
58052 +
58053 get_fs_root(current->fs, &root);
58054 old_mp = lock_mount(&old);
58055 error = PTR_ERR(old_mp);
58056 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58057 !nsown_capable(CAP_SYS_ADMIN))
58058 return -EPERM;
58059
58060 - if (fs->users != 1)
58061 + if (atomic_read(&fs->users) != 1)
58062 return -EINVAL;
58063
58064 get_mnt_ns(mnt_ns);
58065 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58066 index f4ccfe6..a5cf064 100644
58067 --- a/fs/nfs/callback_xdr.c
58068 +++ b/fs/nfs/callback_xdr.c
58069 @@ -51,7 +51,7 @@ struct callback_op {
58070 callback_decode_arg_t decode_args;
58071 callback_encode_res_t encode_res;
58072 long res_maxsize;
58073 -};
58074 +} __do_const;
58075
58076 static struct callback_op callback_ops[];
58077
58078 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58079 index 941246f..17d8724 100644
58080 --- a/fs/nfs/inode.c
58081 +++ b/fs/nfs/inode.c
58082 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58083 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58084 }
58085
58086 -static atomic_long_t nfs_attr_generation_counter;
58087 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58088
58089 static unsigned long nfs_read_attr_generation_counter(void)
58090 {
58091 - return atomic_long_read(&nfs_attr_generation_counter);
58092 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58093 }
58094
58095 unsigned long nfs_inc_attr_generation_counter(void)
58096 {
58097 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58098 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58099 }
58100
58101 void nfs_fattr_init(struct nfs_fattr *fattr)
58102 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
58103 index e22862f..92d66eb 100644
58104 --- a/fs/nfs/nfs4state.c
58105 +++ b/fs/nfs/nfs4state.c
58106 @@ -154,6 +154,19 @@ struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
58107 return cred;
58108 }
58109
58110 +static void nfs4_root_machine_cred(struct nfs_client *clp)
58111 +{
58112 + struct rpc_cred *cred, *new;
58113 +
58114 + new = rpc_lookup_machine_cred(NULL);
58115 + spin_lock(&clp->cl_lock);
58116 + cred = clp->cl_machine_cred;
58117 + clp->cl_machine_cred = new;
58118 + spin_unlock(&clp->cl_lock);
58119 + if (cred != NULL)
58120 + put_rpccred(cred);
58121 +}
58122 +
58123 static struct rpc_cred *
58124 nfs4_get_renew_cred_server_locked(struct nfs_server *server)
58125 {
58126 @@ -1896,10 +1909,19 @@ again:
58127 __func__, status);
58128 goto again;
58129 case -EACCES:
58130 - if (i++)
58131 + if (i++ == 0) {
58132 + nfs4_root_machine_cred(clp);
58133 + goto again;
58134 + }
58135 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
58136 break;
58137 case -NFS4ERR_CLID_INUSE:
58138 case -NFS4ERR_WRONGSEC:
58139 + /* No point in retrying if we already used RPC_AUTH_UNIX */
58140 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) {
58141 + status = -EPERM;
58142 + break;
58143 + }
58144 clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX);
58145 if (IS_ERR(clnt)) {
58146 status = PTR_ERR(clnt);
58147 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58148 index 419572f..5414a23 100644
58149 --- a/fs/nfsd/nfs4proc.c
58150 +++ b/fs/nfsd/nfs4proc.c
58151 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58152 nfsd4op_rsize op_rsize_bop;
58153 stateid_getter op_get_currentstateid;
58154 stateid_setter op_set_currentstateid;
58155 -};
58156 +} __do_const;
58157
58158 static struct nfsd4_operation nfsd4_ops[];
58159
58160 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58161 index c2a4701..fd80e29 100644
58162 --- a/fs/nfsd/nfs4xdr.c
58163 +++ b/fs/nfsd/nfs4xdr.c
58164 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58165
58166 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58167
58168 -static nfsd4_dec nfsd4_dec_ops[] = {
58169 +static const nfsd4_dec nfsd4_dec_ops[] = {
58170 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58171 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58172 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58173 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58174 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58175 };
58176
58177 -static nfsd4_dec nfsd41_dec_ops[] = {
58178 +static const nfsd4_dec nfsd41_dec_ops[] = {
58179 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58180 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58181 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58182 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58183 };
58184
58185 struct nfsd4_minorversion_ops {
58186 - nfsd4_dec *decoders;
58187 + const nfsd4_dec *decoders;
58188 int nops;
58189 };
58190
58191 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58192 index e76244e..9fe8f2f1 100644
58193 --- a/fs/nfsd/nfscache.c
58194 +++ b/fs/nfsd/nfscache.c
58195 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58196 {
58197 struct svc_cacherep *rp = rqstp->rq_cacherep;
58198 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58199 - int len;
58200 + long len;
58201 size_t bufsize = 0;
58202
58203 if (!rp)
58204 return;
58205
58206 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58207 - len >>= 2;
58208 + if (statp) {
58209 + len = (char*)statp - (char*)resv->iov_base;
58210 + len = resv->iov_len - len;
58211 + len >>= 2;
58212 + }
58213
58214 /* Don't cache excessive amounts of data and XDR failures */
58215 if (!statp || len > (256 >> 2)) {
58216 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58217 index c827acb..b253b77 100644
58218 --- a/fs/nfsd/vfs.c
58219 +++ b/fs/nfsd/vfs.c
58220 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58221 } else {
58222 oldfs = get_fs();
58223 set_fs(KERNEL_DS);
58224 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58225 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58226 set_fs(oldfs);
58227 }
58228
58229 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58230
58231 /* Write the data. */
58232 oldfs = get_fs(); set_fs(KERNEL_DS);
58233 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58234 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58235 set_fs(oldfs);
58236 if (host_err < 0)
58237 goto out_nfserr;
58238 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58239 */
58240
58241 oldfs = get_fs(); set_fs(KERNEL_DS);
58242 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58243 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58244 set_fs(oldfs);
58245
58246 if (host_err < 0)
58247 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58248 index fea6bd5..8ee9d81 100644
58249 --- a/fs/nls/nls_base.c
58250 +++ b/fs/nls/nls_base.c
58251 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58252
58253 int register_nls(struct nls_table * nls)
58254 {
58255 - struct nls_table ** tmp = &tables;
58256 + struct nls_table *tmp = tables;
58257
58258 if (nls->next)
58259 return -EBUSY;
58260
58261 spin_lock(&nls_lock);
58262 - while (*tmp) {
58263 - if (nls == *tmp) {
58264 + while (tmp) {
58265 + if (nls == tmp) {
58266 spin_unlock(&nls_lock);
58267 return -EBUSY;
58268 }
58269 - tmp = &(*tmp)->next;
58270 + tmp = tmp->next;
58271 }
58272 - nls->next = tables;
58273 + pax_open_kernel();
58274 + *(struct nls_table **)&nls->next = tables;
58275 + pax_close_kernel();
58276 tables = nls;
58277 spin_unlock(&nls_lock);
58278 return 0;
58279 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58280
58281 int unregister_nls(struct nls_table * nls)
58282 {
58283 - struct nls_table ** tmp = &tables;
58284 + struct nls_table * const * tmp = &tables;
58285
58286 spin_lock(&nls_lock);
58287 while (*tmp) {
58288 if (nls == *tmp) {
58289 - *tmp = nls->next;
58290 + pax_open_kernel();
58291 + *(struct nls_table **)tmp = nls->next;
58292 + pax_close_kernel();
58293 spin_unlock(&nls_lock);
58294 return 0;
58295 }
58296 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58297 index 7424929..35f6be5 100644
58298 --- a/fs/nls/nls_euc-jp.c
58299 +++ b/fs/nls/nls_euc-jp.c
58300 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58301 p_nls = load_nls("cp932");
58302
58303 if (p_nls) {
58304 - table.charset2upper = p_nls->charset2upper;
58305 - table.charset2lower = p_nls->charset2lower;
58306 + pax_open_kernel();
58307 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58308 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58309 + pax_close_kernel();
58310 return register_nls(&table);
58311 }
58312
58313 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58314 index e7bc1d7..06bd4bb 100644
58315 --- a/fs/nls/nls_koi8-ru.c
58316 +++ b/fs/nls/nls_koi8-ru.c
58317 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58318 p_nls = load_nls("koi8-u");
58319
58320 if (p_nls) {
58321 - table.charset2upper = p_nls->charset2upper;
58322 - table.charset2lower = p_nls->charset2lower;
58323 + pax_open_kernel();
58324 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58325 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58326 + pax_close_kernel();
58327 return register_nls(&table);
58328 }
58329
58330 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58331 index e44cb64..4807084 100644
58332 --- a/fs/notify/fanotify/fanotify_user.c
58333 +++ b/fs/notify/fanotify/fanotify_user.c
58334 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58335
58336 fd = fanotify_event_metadata.fd;
58337 ret = -EFAULT;
58338 - if (copy_to_user(buf, &fanotify_event_metadata,
58339 - fanotify_event_metadata.event_len))
58340 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58341 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58342 goto out_close_fd;
58343
58344 ret = prepare_for_access_response(group, event, fd);
58345 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58346 index 7b51b05..5ea5ef6 100644
58347 --- a/fs/notify/notification.c
58348 +++ b/fs/notify/notification.c
58349 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58350 * get set to 0 so it will never get 'freed'
58351 */
58352 static struct fsnotify_event *q_overflow_event;
58353 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58354 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58355
58356 /**
58357 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58358 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58359 */
58360 u32 fsnotify_get_cookie(void)
58361 {
58362 - return atomic_inc_return(&fsnotify_sync_cookie);
58363 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58364 }
58365 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58366
58367 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58368 index 9e38daf..5727cae 100644
58369 --- a/fs/ntfs/dir.c
58370 +++ b/fs/ntfs/dir.c
58371 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58372 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58373 ~(s64)(ndir->itype.index.block_size - 1)));
58374 /* Bounds checks. */
58375 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58376 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58377 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58378 "inode 0x%lx or driver bug.", vdir->i_ino);
58379 goto err_out;
58380 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58381 index c5670b8..d590213 100644
58382 --- a/fs/ntfs/file.c
58383 +++ b/fs/ntfs/file.c
58384 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58385 char *addr;
58386 size_t total = 0;
58387 unsigned len;
58388 - int left;
58389 + unsigned left;
58390
58391 do {
58392 len = PAGE_CACHE_SIZE - ofs;
58393 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58394 index 82650d5..db37dcf 100644
58395 --- a/fs/ntfs/super.c
58396 +++ b/fs/ntfs/super.c
58397 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58398 if (!silent)
58399 ntfs_error(sb, "Primary boot sector is invalid.");
58400 } else if (!silent)
58401 - ntfs_error(sb, read_err_str, "primary");
58402 + ntfs_error(sb, read_err_str, "%s", "primary");
58403 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58404 if (bh_primary)
58405 brelse(bh_primary);
58406 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58407 goto hotfix_primary_boot_sector;
58408 brelse(bh_backup);
58409 } else if (!silent)
58410 - ntfs_error(sb, read_err_str, "backup");
58411 + ntfs_error(sb, read_err_str, "%s", "backup");
58412 /* Try to read NT3.51- backup boot sector. */
58413 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58414 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58415 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58416 "sector.");
58417 brelse(bh_backup);
58418 } else if (!silent)
58419 - ntfs_error(sb, read_err_str, "backup");
58420 + ntfs_error(sb, read_err_str, "%s", "backup");
58421 /* We failed. Cleanup and return. */
58422 if (bh_primary)
58423 brelse(bh_primary);
58424 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58425 index aebeacd..0dcdd26 100644
58426 --- a/fs/ocfs2/localalloc.c
58427 +++ b/fs/ocfs2/localalloc.c
58428 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58429 goto bail;
58430 }
58431
58432 - atomic_inc(&osb->alloc_stats.moves);
58433 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58434
58435 bail:
58436 if (handle)
58437 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58438 index 3a90347..c40bef8 100644
58439 --- a/fs/ocfs2/ocfs2.h
58440 +++ b/fs/ocfs2/ocfs2.h
58441 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58442
58443 struct ocfs2_alloc_stats
58444 {
58445 - atomic_t moves;
58446 - atomic_t local_data;
58447 - atomic_t bitmap_data;
58448 - atomic_t bg_allocs;
58449 - atomic_t bg_extends;
58450 + atomic_unchecked_t moves;
58451 + atomic_unchecked_t local_data;
58452 + atomic_unchecked_t bitmap_data;
58453 + atomic_unchecked_t bg_allocs;
58454 + atomic_unchecked_t bg_extends;
58455 };
58456
58457 enum ocfs2_local_alloc_state
58458 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58459 index 5397c07..54afc55 100644
58460 --- a/fs/ocfs2/suballoc.c
58461 +++ b/fs/ocfs2/suballoc.c
58462 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58463 mlog_errno(status);
58464 goto bail;
58465 }
58466 - atomic_inc(&osb->alloc_stats.bg_extends);
58467 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58468
58469 /* You should never ask for this much metadata */
58470 BUG_ON(bits_wanted >
58471 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58472 mlog_errno(status);
58473 goto bail;
58474 }
58475 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58476 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58477
58478 *suballoc_loc = res.sr_bg_blkno;
58479 *suballoc_bit_start = res.sr_bit_offset;
58480 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58481 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58482 res->sr_bits);
58483
58484 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58485 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58486
58487 BUG_ON(res->sr_bits != 1);
58488
58489 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58490 mlog_errno(status);
58491 goto bail;
58492 }
58493 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58494 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58495
58496 BUG_ON(res.sr_bits != 1);
58497
58498 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58499 cluster_start,
58500 num_clusters);
58501 if (!status)
58502 - atomic_inc(&osb->alloc_stats.local_data);
58503 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58504 } else {
58505 if (min_clusters > (osb->bitmap_cpg - 1)) {
58506 /* The only paths asking for contiguousness
58507 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58508 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58509 res.sr_bg_blkno,
58510 res.sr_bit_offset);
58511 - atomic_inc(&osb->alloc_stats.bitmap_data);
58512 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58513 *num_clusters = res.sr_bits;
58514 }
58515 }
58516 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58517 index 121da2d..a0232bc 100644
58518 --- a/fs/ocfs2/super.c
58519 +++ b/fs/ocfs2/super.c
58520 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58521 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58522 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58523 "Stats",
58524 - atomic_read(&osb->alloc_stats.bitmap_data),
58525 - atomic_read(&osb->alloc_stats.local_data),
58526 - atomic_read(&osb->alloc_stats.bg_allocs),
58527 - atomic_read(&osb->alloc_stats.moves),
58528 - atomic_read(&osb->alloc_stats.bg_extends));
58529 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58530 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58531 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58532 + atomic_read_unchecked(&osb->alloc_stats.moves),
58533 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58534
58535 out += snprintf(buf + out, len - out,
58536 "%10s => State: %u Descriptor: %llu Size: %u bits "
58537 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58538 spin_lock_init(&osb->osb_xattr_lock);
58539 ocfs2_init_steal_slots(osb);
58540
58541 - atomic_set(&osb->alloc_stats.moves, 0);
58542 - atomic_set(&osb->alloc_stats.local_data, 0);
58543 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58544 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58545 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58546 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58547 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58548 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58549 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58550 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58551
58552 /* Copy the blockcheck stats from the superblock probe */
58553 osb->osb_ecc_stats = *stats;
58554 diff --git a/fs/open.c b/fs/open.c
58555 index 7931f76..7b03f3b 100644
58556 --- a/fs/open.c
58557 +++ b/fs/open.c
58558 @@ -32,6 +32,8 @@
58559 #include <linux/dnotify.h>
58560 #include <linux/compat.h>
58561
58562 +#define CREATE_TRACE_POINTS
58563 +#include <trace/events/fs.h>
58564 #include "internal.h"
58565
58566 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58567 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58568 error = locks_verify_truncate(inode, NULL, length);
58569 if (!error)
58570 error = security_path_truncate(path);
58571 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58572 + error = -EACCES;
58573 if (!error)
58574 error = do_truncate(path->dentry, length, 0, NULL);
58575
58576 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58577 error = locks_verify_truncate(inode, f.file, length);
58578 if (!error)
58579 error = security_path_truncate(&f.file->f_path);
58580 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58581 + error = -EACCES;
58582 if (!error)
58583 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58584 sb_end_write(inode->i_sb);
58585 @@ -360,6 +366,9 @@ retry:
58586 if (__mnt_is_readonly(path.mnt))
58587 res = -EROFS;
58588
58589 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58590 + res = -EACCES;
58591 +
58592 out_path_release:
58593 path_put(&path);
58594 if (retry_estale(res, lookup_flags)) {
58595 @@ -391,6 +400,8 @@ retry:
58596 if (error)
58597 goto dput_and_out;
58598
58599 + gr_log_chdir(path.dentry, path.mnt);
58600 +
58601 set_fs_pwd(current->fs, &path);
58602
58603 dput_and_out:
58604 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58605 goto out_putf;
58606
58607 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58608 +
58609 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58610 + error = -EPERM;
58611 +
58612 + if (!error)
58613 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58614 +
58615 if (!error)
58616 set_fs_pwd(current->fs, &f.file->f_path);
58617 out_putf:
58618 @@ -449,7 +467,13 @@ retry:
58619 if (error)
58620 goto dput_and_out;
58621
58622 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58623 + goto dput_and_out;
58624 +
58625 set_fs_root(current->fs, &path);
58626 +
58627 + gr_handle_chroot_chdir(&path);
58628 +
58629 error = 0;
58630 dput_and_out:
58631 path_put(&path);
58632 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58633 if (error)
58634 return error;
58635 mutex_lock(&inode->i_mutex);
58636 +
58637 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58638 + error = -EACCES;
58639 + goto out_unlock;
58640 + }
58641 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58642 + error = -EACCES;
58643 + goto out_unlock;
58644 + }
58645 +
58646 error = security_path_chmod(path, mode);
58647 if (error)
58648 goto out_unlock;
58649 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58650 uid = make_kuid(current_user_ns(), user);
58651 gid = make_kgid(current_user_ns(), group);
58652
58653 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58654 + return -EACCES;
58655 +
58656 newattrs.ia_valid = ATTR_CTIME;
58657 if (user != (uid_t) -1) {
58658 if (!uid_valid(uid))
58659 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58660 } else {
58661 fsnotify_open(f);
58662 fd_install(fd, f);
58663 + trace_do_sys_open(tmp->name, flags, mode);
58664 }
58665 }
58666 putname(tmp);
58667 diff --git a/fs/pipe.c b/fs/pipe.c
58668 index d2c45e1..009fe1c 100644
58669 --- a/fs/pipe.c
58670 +++ b/fs/pipe.c
58671 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58672
58673 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58674 {
58675 - if (pipe->files)
58676 + if (atomic_read(&pipe->files))
58677 mutex_lock_nested(&pipe->mutex, subclass);
58678 }
58679
58680 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58681
58682 void pipe_unlock(struct pipe_inode_info *pipe)
58683 {
58684 - if (pipe->files)
58685 + if (atomic_read(&pipe->files))
58686 mutex_unlock(&pipe->mutex);
58687 }
58688 EXPORT_SYMBOL(pipe_unlock);
58689 @@ -449,9 +449,9 @@ redo:
58690 }
58691 if (bufs) /* More to do? */
58692 continue;
58693 - if (!pipe->writers)
58694 + if (!atomic_read(&pipe->writers))
58695 break;
58696 - if (!pipe->waiting_writers) {
58697 + if (!atomic_read(&pipe->waiting_writers)) {
58698 /* syscall merging: Usually we must not sleep
58699 * if O_NONBLOCK is set, or if we got some data.
58700 * But if a writer sleeps in kernel space, then
58701 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58702 ret = 0;
58703 __pipe_lock(pipe);
58704
58705 - if (!pipe->readers) {
58706 + if (!atomic_read(&pipe->readers)) {
58707 send_sig(SIGPIPE, current, 0);
58708 ret = -EPIPE;
58709 goto out;
58710 @@ -562,7 +562,7 @@ redo1:
58711 for (;;) {
58712 int bufs;
58713
58714 - if (!pipe->readers) {
58715 + if (!atomic_read(&pipe->readers)) {
58716 send_sig(SIGPIPE, current, 0);
58717 if (!ret)
58718 ret = -EPIPE;
58719 @@ -653,9 +653,9 @@ redo2:
58720 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58721 do_wakeup = 0;
58722 }
58723 - pipe->waiting_writers++;
58724 + atomic_inc(&pipe->waiting_writers);
58725 pipe_wait(pipe);
58726 - pipe->waiting_writers--;
58727 + atomic_dec(&pipe->waiting_writers);
58728 }
58729 out:
58730 __pipe_unlock(pipe);
58731 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58732 mask = 0;
58733 if (filp->f_mode & FMODE_READ) {
58734 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58735 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58736 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58737 mask |= POLLHUP;
58738 }
58739
58740 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58741 * Most Unices do not set POLLERR for FIFOs but on Linux they
58742 * behave exactly like pipes for poll().
58743 */
58744 - if (!pipe->readers)
58745 + if (!atomic_read(&pipe->readers))
58746 mask |= POLLERR;
58747 }
58748
58749 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58750
58751 __pipe_lock(pipe);
58752 if (file->f_mode & FMODE_READ)
58753 - pipe->readers--;
58754 + atomic_dec(&pipe->readers);
58755 if (file->f_mode & FMODE_WRITE)
58756 - pipe->writers--;
58757 + atomic_dec(&pipe->writers);
58758
58759 - if (pipe->readers || pipe->writers) {
58760 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58761 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58762 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58763 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58764 }
58765 spin_lock(&inode->i_lock);
58766 - if (!--pipe->files) {
58767 + if (atomic_dec_and_test(&pipe->files)) {
58768 inode->i_pipe = NULL;
58769 kill = 1;
58770 }
58771 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58772 kfree(pipe);
58773 }
58774
58775 -static struct vfsmount *pipe_mnt __read_mostly;
58776 +struct vfsmount *pipe_mnt __read_mostly;
58777
58778 /*
58779 * pipefs_dname() is called from d_path().
58780 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58781 goto fail_iput;
58782
58783 inode->i_pipe = pipe;
58784 - pipe->files = 2;
58785 - pipe->readers = pipe->writers = 1;
58786 + atomic_set(&pipe->files, 2);
58787 + atomic_set(&pipe->readers, 1);
58788 + atomic_set(&pipe->writers, 1);
58789 inode->i_fop = &pipefifo_fops;
58790
58791 /*
58792 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58793 spin_lock(&inode->i_lock);
58794 if (inode->i_pipe) {
58795 pipe = inode->i_pipe;
58796 - pipe->files++;
58797 + atomic_inc(&pipe->files);
58798 spin_unlock(&inode->i_lock);
58799 } else {
58800 spin_unlock(&inode->i_lock);
58801 pipe = alloc_pipe_info();
58802 if (!pipe)
58803 return -ENOMEM;
58804 - pipe->files = 1;
58805 + atomic_set(&pipe->files, 1);
58806 spin_lock(&inode->i_lock);
58807 if (unlikely(inode->i_pipe)) {
58808 - inode->i_pipe->files++;
58809 + atomic_inc(&inode->i_pipe->files);
58810 spin_unlock(&inode->i_lock);
58811 free_pipe_info(pipe);
58812 pipe = inode->i_pipe;
58813 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58814 * opened, even when there is no process writing the FIFO.
58815 */
58816 pipe->r_counter++;
58817 - if (pipe->readers++ == 0)
58818 + if (atomic_inc_return(&pipe->readers) == 1)
58819 wake_up_partner(pipe);
58820
58821 - if (!is_pipe && !pipe->writers) {
58822 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58823 if ((filp->f_flags & O_NONBLOCK)) {
58824 /* suppress POLLHUP until we have
58825 * seen a writer */
58826 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58827 * errno=ENXIO when there is no process reading the FIFO.
58828 */
58829 ret = -ENXIO;
58830 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58831 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58832 goto err;
58833
58834 pipe->w_counter++;
58835 - if (!pipe->writers++)
58836 + if (atomic_inc_return(&pipe->writers) == 1)
58837 wake_up_partner(pipe);
58838
58839 - if (!is_pipe && !pipe->readers) {
58840 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58841 if (wait_for_partner(pipe, &pipe->r_counter))
58842 goto err_wr;
58843 }
58844 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58845 * the process can at least talk to itself.
58846 */
58847
58848 - pipe->readers++;
58849 - pipe->writers++;
58850 + atomic_inc(&pipe->readers);
58851 + atomic_inc(&pipe->writers);
58852 pipe->r_counter++;
58853 pipe->w_counter++;
58854 - if (pipe->readers == 1 || pipe->writers == 1)
58855 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58856 wake_up_partner(pipe);
58857 break;
58858
58859 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58860 return 0;
58861
58862 err_rd:
58863 - if (!--pipe->readers)
58864 + if (atomic_dec_and_test(&pipe->readers))
58865 wake_up_interruptible(&pipe->wait);
58866 ret = -ERESTARTSYS;
58867 goto err;
58868
58869 err_wr:
58870 - if (!--pipe->writers)
58871 + if (atomic_dec_and_test(&pipe->writers))
58872 wake_up_interruptible(&pipe->wait);
58873 ret = -ERESTARTSYS;
58874 goto err;
58875
58876 err:
58877 spin_lock(&inode->i_lock);
58878 - if (!--pipe->files) {
58879 + if (atomic_dec_and_test(&pipe->files)) {
58880 inode->i_pipe = NULL;
58881 kill = 1;
58882 }
58883 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58884 index 15af622..0e9f4467 100644
58885 --- a/fs/proc/Kconfig
58886 +++ b/fs/proc/Kconfig
58887 @@ -30,12 +30,12 @@ config PROC_FS
58888
58889 config PROC_KCORE
58890 bool "/proc/kcore support" if !ARM
58891 - depends on PROC_FS && MMU
58892 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58893
58894 config PROC_VMCORE
58895 bool "/proc/vmcore support"
58896 - depends on PROC_FS && CRASH_DUMP
58897 - default y
58898 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58899 + default n
58900 help
58901 Exports the dump image of crashed kernel in ELF format.
58902
58903 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58904 limited in memory.
58905
58906 config PROC_PAGE_MONITOR
58907 - default y
58908 - depends on PROC_FS && MMU
58909 + default n
58910 + depends on PROC_FS && MMU && !GRKERNSEC
58911 bool "Enable /proc page monitoring" if EXPERT
58912 help
58913 Various /proc files exist to monitor process memory utilization:
58914 diff --git a/fs/proc/array.c b/fs/proc/array.c
58915 index cbd0f1b..adec3f0 100644
58916 --- a/fs/proc/array.c
58917 +++ b/fs/proc/array.c
58918 @@ -60,6 +60,7 @@
58919 #include <linux/tty.h>
58920 #include <linux/string.h>
58921 #include <linux/mman.h>
58922 +#include <linux/grsecurity.h>
58923 #include <linux/proc_fs.h>
58924 #include <linux/ioport.h>
58925 #include <linux/uaccess.h>
58926 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58927 seq_putc(m, '\n');
58928 }
58929
58930 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58931 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58932 +{
58933 + if (p->mm)
58934 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58935 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58936 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58937 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58938 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58939 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58940 + else
58941 + seq_printf(m, "PaX:\t-----\n");
58942 +}
58943 +#endif
58944 +
58945 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58946 struct pid *pid, struct task_struct *task)
58947 {
58948 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58949 task_cpus_allowed(m, task);
58950 cpuset_task_status_allowed(m, task);
58951 task_context_switch_counts(m, task);
58952 +
58953 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58954 + task_pax(m, task);
58955 +#endif
58956 +
58957 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58958 + task_grsec_rbac(m, task);
58959 +#endif
58960 +
58961 return 0;
58962 }
58963
58964 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58965 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58966 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58967 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58968 +#endif
58969 +
58970 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58971 struct pid *pid, struct task_struct *task, int whole)
58972 {
58973 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58974 char tcomm[sizeof(task->comm)];
58975 unsigned long flags;
58976
58977 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58978 + if (current->exec_id != m->exec_id) {
58979 + gr_log_badprocpid("stat");
58980 + return 0;
58981 + }
58982 +#endif
58983 +
58984 state = *get_task_state(task);
58985 vsize = eip = esp = 0;
58986 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58987 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58988 gtime = task_gtime(task);
58989 }
58990
58991 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58992 + if (PAX_RAND_FLAGS(mm)) {
58993 + eip = 0;
58994 + esp = 0;
58995 + wchan = 0;
58996 + }
58997 +#endif
58998 +#ifdef CONFIG_GRKERNSEC_HIDESYM
58999 + wchan = 0;
59000 + eip =0;
59001 + esp =0;
59002 +#endif
59003 +
59004 /* scale priority and nice values from timeslices to -20..20 */
59005 /* to make it look like a "normal" Unix priority/nice value */
59006 priority = task_prio(task);
59007 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59008 seq_put_decimal_ull(m, ' ', vsize);
59009 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59010 seq_put_decimal_ull(m, ' ', rsslim);
59011 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59012 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59013 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59014 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59015 +#else
59016 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59017 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59018 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59019 +#endif
59020 seq_put_decimal_ull(m, ' ', esp);
59021 seq_put_decimal_ull(m, ' ', eip);
59022 /* The signal information here is obsolete.
59023 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59024 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59025 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59026
59027 - if (mm && permitted) {
59028 + if (mm && permitted
59029 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59030 + && !PAX_RAND_FLAGS(mm)
59031 +#endif
59032 + ) {
59033 seq_put_decimal_ull(m, ' ', mm->start_data);
59034 seq_put_decimal_ull(m, ' ', mm->end_data);
59035 seq_put_decimal_ull(m, ' ', mm->start_brk);
59036 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59037 struct pid *pid, struct task_struct *task)
59038 {
59039 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59040 - struct mm_struct *mm = get_task_mm(task);
59041 + struct mm_struct *mm;
59042
59043 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59044 + if (current->exec_id != m->exec_id) {
59045 + gr_log_badprocpid("statm");
59046 + return 0;
59047 + }
59048 +#endif
59049 + mm = get_task_mm(task);
59050 if (mm) {
59051 size = task_statm(mm, &shared, &text, &data, &resident);
59052 mmput(mm);
59053 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59054 return 0;
59055 }
59056
59057 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59058 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59059 +{
59060 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59061 +}
59062 +#endif
59063 +
59064 #ifdef CONFIG_CHECKPOINT_RESTORE
59065 static struct pid *
59066 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59067 diff --git a/fs/proc/base.c b/fs/proc/base.c
59068 index 1485e38..8ad4236 100644
59069 --- a/fs/proc/base.c
59070 +++ b/fs/proc/base.c
59071 @@ -113,6 +113,14 @@ struct pid_entry {
59072 union proc_op op;
59073 };
59074
59075 +struct getdents_callback {
59076 + struct linux_dirent __user * current_dir;
59077 + struct linux_dirent __user * previous;
59078 + struct file * file;
59079 + int count;
59080 + int error;
59081 +};
59082 +
59083 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59084 .name = (NAME), \
59085 .len = sizeof(NAME) - 1, \
59086 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59087 if (!mm->arg_end)
59088 goto out_mm; /* Shh! No looking before we're done */
59089
59090 + if (gr_acl_handle_procpidmem(task))
59091 + goto out_mm;
59092 +
59093 len = mm->arg_end - mm->arg_start;
59094
59095 if (len > PAGE_SIZE)
59096 @@ -237,12 +248,28 @@ out:
59097 return res;
59098 }
59099
59100 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59101 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59102 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59103 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59104 +#endif
59105 +
59106 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59107 {
59108 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59109 int res = PTR_ERR(mm);
59110 if (mm && !IS_ERR(mm)) {
59111 unsigned int nwords = 0;
59112 +
59113 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59114 + /* allow if we're currently ptracing this task */
59115 + if (PAX_RAND_FLAGS(mm) &&
59116 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59117 + mmput(mm);
59118 + return 0;
59119 + }
59120 +#endif
59121 +
59122 do {
59123 nwords += 2;
59124 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59125 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59126 }
59127
59128
59129 -#ifdef CONFIG_KALLSYMS
59130 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59131 /*
59132 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59133 * Returns the resolved symbol. If that fails, simply return the address.
59134 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59135 mutex_unlock(&task->signal->cred_guard_mutex);
59136 }
59137
59138 -#ifdef CONFIG_STACKTRACE
59139 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59140
59141 #define MAX_STACK_TRACE_DEPTH 64
59142
59143 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59144 return count;
59145 }
59146
59147 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59148 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59149 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59150 {
59151 long nr;
59152 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59153 /************************************************************************/
59154
59155 /* permission checks */
59156 -static int proc_fd_access_allowed(struct inode *inode)
59157 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59158 {
59159 struct task_struct *task;
59160 int allowed = 0;
59161 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59162 */
59163 task = get_proc_task(inode);
59164 if (task) {
59165 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59166 + if (log)
59167 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59168 + else
59169 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59170 put_task_struct(task);
59171 }
59172 return allowed;
59173 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59174 struct task_struct *task,
59175 int hide_pid_min)
59176 {
59177 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59178 + return false;
59179 +
59180 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59181 + rcu_read_lock();
59182 + {
59183 + const struct cred *tmpcred = current_cred();
59184 + const struct cred *cred = __task_cred(task);
59185 +
59186 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59187 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59188 + || in_group_p(grsec_proc_gid)
59189 +#endif
59190 + ) {
59191 + rcu_read_unlock();
59192 + return true;
59193 + }
59194 + }
59195 + rcu_read_unlock();
59196 +
59197 + if (!pid->hide_pid)
59198 + return false;
59199 +#endif
59200 +
59201 if (pid->hide_pid < hide_pid_min)
59202 return true;
59203 if (in_group_p(pid->pid_gid))
59204 return true;
59205 +
59206 return ptrace_may_access(task, PTRACE_MODE_READ);
59207 }
59208
59209 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59210 put_task_struct(task);
59211
59212 if (!has_perms) {
59213 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59214 + {
59215 +#else
59216 if (pid->hide_pid == 2) {
59217 +#endif
59218 /*
59219 * Let's make getdents(), stat(), and open()
59220 * consistent with each other. If a process
59221 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59222 if (!task)
59223 return -ESRCH;
59224
59225 + if (gr_acl_handle_procpidmem(task)) {
59226 + put_task_struct(task);
59227 + return -EPERM;
59228 + }
59229 +
59230 mm = mm_access(task, mode);
59231 put_task_struct(task);
59232
59233 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59234
59235 file->private_data = mm;
59236
59237 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59238 + file->f_version = current->exec_id;
59239 +#endif
59240 +
59241 return 0;
59242 }
59243
59244 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59245 ssize_t copied;
59246 char *page;
59247
59248 +#ifdef CONFIG_GRKERNSEC
59249 + if (write)
59250 + return -EPERM;
59251 +#endif
59252 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59253 + if (file->f_version != current->exec_id) {
59254 + gr_log_badprocpid("mem");
59255 + return 0;
59256 + }
59257 +#endif
59258 +
59259 if (!mm)
59260 return 0;
59261
59262 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59263 goto free;
59264
59265 while (count > 0) {
59266 - int this_len = min_t(int, count, PAGE_SIZE);
59267 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59268
59269 if (write && copy_from_user(page, buf, this_len)) {
59270 copied = -EFAULT;
59271 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59272 if (!mm)
59273 return 0;
59274
59275 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59276 + if (file->f_version != current->exec_id) {
59277 + gr_log_badprocpid("environ");
59278 + return 0;
59279 + }
59280 +#endif
59281 +
59282 page = (char *)__get_free_page(GFP_TEMPORARY);
59283 if (!page)
59284 return -ENOMEM;
59285 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59286 goto free;
59287 while (count > 0) {
59288 size_t this_len, max_len;
59289 - int retval;
59290 + ssize_t retval;
59291
59292 if (src >= (mm->env_end - mm->env_start))
59293 break;
59294 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59295 int error = -EACCES;
59296
59297 /* Are we allowed to snoop on the tasks file descriptors? */
59298 - if (!proc_fd_access_allowed(inode))
59299 + if (!proc_fd_access_allowed(inode, 0))
59300 goto out;
59301
59302 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59303 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59304 struct path path;
59305
59306 /* Are we allowed to snoop on the tasks file descriptors? */
59307 - if (!proc_fd_access_allowed(inode))
59308 - goto out;
59309 + /* logging this is needed for learning on chromium to work properly,
59310 + but we don't want to flood the logs from 'ps' which does a readlink
59311 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59312 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59313 + */
59314 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59315 + if (!proc_fd_access_allowed(inode,0))
59316 + goto out;
59317 + } else {
59318 + if (!proc_fd_access_allowed(inode,1))
59319 + goto out;
59320 + }
59321
59322 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59323 if (error)
59324 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59325 rcu_read_lock();
59326 cred = __task_cred(task);
59327 inode->i_uid = cred->euid;
59328 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59329 + inode->i_gid = grsec_proc_gid;
59330 +#else
59331 inode->i_gid = cred->egid;
59332 +#endif
59333 rcu_read_unlock();
59334 }
59335 security_task_to_inode(task, inode);
59336 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59337 return -ENOENT;
59338 }
59339 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59340 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59341 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59342 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59343 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59344 +#endif
59345 task_dumpable(task)) {
59346 cred = __task_cred(task);
59347 stat->uid = cred->euid;
59348 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59349 + stat->gid = grsec_proc_gid;
59350 +#else
59351 stat->gid = cred->egid;
59352 +#endif
59353 }
59354 }
59355 rcu_read_unlock();
59356 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59357
59358 if (task) {
59359 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59360 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59361 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59362 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59363 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59364 +#endif
59365 task_dumpable(task)) {
59366 rcu_read_lock();
59367 cred = __task_cred(task);
59368 inode->i_uid = cred->euid;
59369 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59370 + inode->i_gid = grsec_proc_gid;
59371 +#else
59372 inode->i_gid = cred->egid;
59373 +#endif
59374 rcu_read_unlock();
59375 } else {
59376 inode->i_uid = GLOBAL_ROOT_UID;
59377 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59378 if (!task)
59379 goto out_no_task;
59380
59381 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59382 + goto out;
59383 +
59384 /*
59385 * Yes, it does not scale. And it should not. Don't add
59386 * new entries into /proc/<tgid>/ without very good reasons.
59387 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59388 if (!task)
59389 return -ENOENT;
59390
59391 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59392 + goto out;
59393 +
59394 if (!dir_emit_dots(file, ctx))
59395 goto out;
59396
59397 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59398 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59399 #endif
59400 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59401 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59402 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59403 INF("syscall", S_IRUGO, proc_pid_syscall),
59404 #endif
59405 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59406 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59407 #ifdef CONFIG_SECURITY
59408 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59409 #endif
59410 -#ifdef CONFIG_KALLSYMS
59411 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59412 INF("wchan", S_IRUGO, proc_pid_wchan),
59413 #endif
59414 -#ifdef CONFIG_STACKTRACE
59415 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59416 ONE("stack", S_IRUGO, proc_pid_stack),
59417 #endif
59418 #ifdef CONFIG_SCHEDSTATS
59419 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59420 #ifdef CONFIG_HARDWALL
59421 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59422 #endif
59423 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59424 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59425 +#endif
59426 #ifdef CONFIG_USER_NS
59427 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59428 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59429 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59430 if (!inode)
59431 goto out;
59432
59433 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59434 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59435 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59436 + inode->i_gid = grsec_proc_gid;
59437 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59438 +#else
59439 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59440 +#endif
59441 inode->i_op = &proc_tgid_base_inode_operations;
59442 inode->i_fop = &proc_tgid_base_operations;
59443 inode->i_flags|=S_IMMUTABLE;
59444 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59445 if (!task)
59446 goto out;
59447
59448 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59449 + goto out_put_task;
59450 +
59451 result = proc_pid_instantiate(dir, dentry, task, NULL);
59452 +out_put_task:
59453 put_task_struct(task);
59454 out:
59455 return ERR_PTR(result);
59456 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59457 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59458 #endif
59459 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59460 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59461 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59462 INF("syscall", S_IRUGO, proc_pid_syscall),
59463 #endif
59464 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59465 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59466 #ifdef CONFIG_SECURITY
59467 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59468 #endif
59469 -#ifdef CONFIG_KALLSYMS
59470 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59471 INF("wchan", S_IRUGO, proc_pid_wchan),
59472 #endif
59473 -#ifdef CONFIG_STACKTRACE
59474 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59475 ONE("stack", S_IRUGO, proc_pid_stack),
59476 #endif
59477 #ifdef CONFIG_SCHEDSTATS
59478 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59479 index 82676e3..5f8518a 100644
59480 --- a/fs/proc/cmdline.c
59481 +++ b/fs/proc/cmdline.c
59482 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59483
59484 static int __init proc_cmdline_init(void)
59485 {
59486 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59487 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59488 +#else
59489 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59490 +#endif
59491 return 0;
59492 }
59493 module_init(proc_cmdline_init);
59494 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59495 index b143471..bb105e5 100644
59496 --- a/fs/proc/devices.c
59497 +++ b/fs/proc/devices.c
59498 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59499
59500 static int __init proc_devices_init(void)
59501 {
59502 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59503 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59504 +#else
59505 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59506 +#endif
59507 return 0;
59508 }
59509 module_init(proc_devices_init);
59510 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59511 index 0ff80f9..a1d7500 100644
59512 --- a/fs/proc/fd.c
59513 +++ b/fs/proc/fd.c
59514 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59515 if (!task)
59516 return -ENOENT;
59517
59518 - files = get_files_struct(task);
59519 + if (!gr_acl_handle_procpidmem(task))
59520 + files = get_files_struct(task);
59521 put_task_struct(task);
59522
59523 if (files) {
59524 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59525 */
59526 int proc_fd_permission(struct inode *inode, int mask)
59527 {
59528 + struct task_struct *task;
59529 int rv = generic_permission(inode, mask);
59530 - if (rv == 0)
59531 - return 0;
59532 +
59533 if (task_pid(current) == proc_pid(inode))
59534 rv = 0;
59535 +
59536 + task = get_proc_task(inode);
59537 + if (task == NULL)
59538 + return rv;
59539 +
59540 + if (gr_acl_handle_procpidmem(task))
59541 + rv = -EACCES;
59542 +
59543 + put_task_struct(task);
59544 +
59545 return rv;
59546 }
59547
59548 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59549 index 073aea6..0630370 100644
59550 --- a/fs/proc/inode.c
59551 +++ b/fs/proc/inode.c
59552 @@ -23,11 +23,17 @@
59553 #include <linux/slab.h>
59554 #include <linux/mount.h>
59555 #include <linux/magic.h>
59556 +#include <linux/grsecurity.h>
59557
59558 #include <asm/uaccess.h>
59559
59560 #include "internal.h"
59561
59562 +#ifdef CONFIG_PROC_SYSCTL
59563 +extern const struct inode_operations proc_sys_inode_operations;
59564 +extern const struct inode_operations proc_sys_dir_operations;
59565 +#endif
59566 +
59567 static void proc_evict_inode(struct inode *inode)
59568 {
59569 struct proc_dir_entry *de;
59570 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59571 ns = PROC_I(inode)->ns.ns;
59572 if (ns_ops && ns)
59573 ns_ops->put(ns);
59574 +
59575 +#ifdef CONFIG_PROC_SYSCTL
59576 + if (inode->i_op == &proc_sys_inode_operations ||
59577 + inode->i_op == &proc_sys_dir_operations)
59578 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59579 +#endif
59580 +
59581 }
59582
59583 static struct kmem_cache * proc_inode_cachep;
59584 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59585 if (de->mode) {
59586 inode->i_mode = de->mode;
59587 inode->i_uid = de->uid;
59588 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59589 + inode->i_gid = grsec_proc_gid;
59590 +#else
59591 inode->i_gid = de->gid;
59592 +#endif
59593 }
59594 if (de->size)
59595 inode->i_size = de->size;
59596 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59597 index 651d09a..60c73ae 100644
59598 --- a/fs/proc/internal.h
59599 +++ b/fs/proc/internal.h
59600 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59601 struct pid *, struct task_struct *);
59602 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59603 struct pid *, struct task_struct *);
59604 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59605 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59606 +#endif
59607
59608 /*
59609 * base.c
59610 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59611 index 06ea155..9a798c7 100644
59612 --- a/fs/proc/kcore.c
59613 +++ b/fs/proc/kcore.c
59614 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59615 * the addresses in the elf_phdr on our list.
59616 */
59617 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59618 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59619 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59620 + if (tsz > buflen)
59621 tsz = buflen;
59622 -
59623 +
59624 while (buflen) {
59625 struct kcore_list *m;
59626
59627 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59628 kfree(elf_buf);
59629 } else {
59630 if (kern_addr_valid(start)) {
59631 - unsigned long n;
59632 + char *elf_buf;
59633 + mm_segment_t oldfs;
59634
59635 - n = copy_to_user(buffer, (char *)start, tsz);
59636 - /*
59637 - * We cannot distinguish between fault on source
59638 - * and fault on destination. When this happens
59639 - * we clear too and hope it will trigger the
59640 - * EFAULT again.
59641 - */
59642 - if (n) {
59643 - if (clear_user(buffer + tsz - n,
59644 - n))
59645 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59646 + if (!elf_buf)
59647 + return -ENOMEM;
59648 + oldfs = get_fs();
59649 + set_fs(KERNEL_DS);
59650 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59651 + set_fs(oldfs);
59652 + if (copy_to_user(buffer, elf_buf, tsz)) {
59653 + kfree(elf_buf);
59654 return -EFAULT;
59655 + }
59656 }
59657 + set_fs(oldfs);
59658 + kfree(elf_buf);
59659 } else {
59660 if (clear_user(buffer, tsz))
59661 return -EFAULT;
59662 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59663
59664 static int open_kcore(struct inode *inode, struct file *filp)
59665 {
59666 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59667 + return -EPERM;
59668 +#endif
59669 if (!capable(CAP_SYS_RAWIO))
59670 return -EPERM;
59671 if (kcore_need_update)
59672 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59673 index 5aa847a..f77c8d4 100644
59674 --- a/fs/proc/meminfo.c
59675 +++ b/fs/proc/meminfo.c
59676 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59677 vmi.used >> 10,
59678 vmi.largest_chunk >> 10
59679 #ifdef CONFIG_MEMORY_FAILURE
59680 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59681 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59682 #endif
59683 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59684 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59685 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59686 index ccfd99b..1b7e255 100644
59687 --- a/fs/proc/nommu.c
59688 +++ b/fs/proc/nommu.c
59689 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59690 if (len < 1)
59691 len = 1;
59692 seq_printf(m, "%*c", len, ' ');
59693 - seq_path(m, &file->f_path, "");
59694 + seq_path(m, &file->f_path, "\n\\");
59695 }
59696
59697 seq_putc(m, '\n');
59698 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59699 index 4677bb7..408e936 100644
59700 --- a/fs/proc/proc_net.c
59701 +++ b/fs/proc/proc_net.c
59702 @@ -23,6 +23,7 @@
59703 #include <linux/nsproxy.h>
59704 #include <net/net_namespace.h>
59705 #include <linux/seq_file.h>
59706 +#include <linux/grsecurity.h>
59707
59708 #include "internal.h"
59709
59710 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59711 struct task_struct *task;
59712 struct nsproxy *ns;
59713 struct net *net = NULL;
59714 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59715 + const struct cred *cred = current_cred();
59716 +#endif
59717 +
59718 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59719 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59720 + return net;
59721 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59722 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59723 + return net;
59724 +#endif
59725
59726 rcu_read_lock();
59727 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59728 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59729 index 7129046..130793a 100644
59730 --- a/fs/proc/proc_sysctl.c
59731 +++ b/fs/proc/proc_sysctl.c
59732 @@ -11,13 +11,18 @@
59733 #include <linux/namei.h>
59734 #include <linux/mm.h>
59735 #include <linux/module.h>
59736 +#include <linux/nsproxy.h>
59737 #include "internal.h"
59738
59739 +extern int gr_handle_chroot_sysctl(const int op);
59740 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59741 + const int op);
59742 +
59743 static const struct dentry_operations proc_sys_dentry_operations;
59744 static const struct file_operations proc_sys_file_operations;
59745 -static const struct inode_operations proc_sys_inode_operations;
59746 +const struct inode_operations proc_sys_inode_operations;
59747 static const struct file_operations proc_sys_dir_file_operations;
59748 -static const struct inode_operations proc_sys_dir_operations;
59749 +const struct inode_operations proc_sys_dir_operations;
59750
59751 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59752 {
59753 @@ -467,6 +472,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59754
59755 err = NULL;
59756 d_set_d_op(dentry, &proc_sys_dentry_operations);
59757 +
59758 + gr_handle_proc_create(dentry, inode);
59759 +
59760 d_add(dentry, inode);
59761
59762 out:
59763 @@ -482,6 +490,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59764 struct inode *inode = file_inode(filp);
59765 struct ctl_table_header *head = grab_header(inode);
59766 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59767 + int op = write ? MAY_WRITE : MAY_READ;
59768 ssize_t error;
59769 size_t res;
59770
59771 @@ -493,7 +502,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59772 * and won't be until we finish.
59773 */
59774 error = -EPERM;
59775 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59776 + if (sysctl_perm(head, table, op))
59777 goto out;
59778
59779 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59780 @@ -501,6 +510,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59781 if (!table->proc_handler)
59782 goto out;
59783
59784 +#ifdef CONFIG_GRKERNSEC
59785 + error = -EPERM;
59786 + if (gr_handle_chroot_sysctl(op))
59787 + goto out;
59788 + dget(filp->f_path.dentry);
59789 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59790 + dput(filp->f_path.dentry);
59791 + goto out;
59792 + }
59793 + dput(filp->f_path.dentry);
59794 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59795 + goto out;
59796 + if (write) {
59797 + if (current->nsproxy->net_ns != table->extra2) {
59798 + if (!capable(CAP_SYS_ADMIN))
59799 + goto out;
59800 + } else if (!nsown_capable(CAP_NET_ADMIN))
59801 + goto out;
59802 + }
59803 +#endif
59804 +
59805 /* careful: calling conventions are nasty here */
59806 res = count;
59807 error = table->proc_handler(table, write, buf, &res, ppos);
59808 @@ -598,6 +628,9 @@ static bool proc_sys_fill_cache(struct file *file,
59809 return false;
59810 } else {
59811 d_set_d_op(child, &proc_sys_dentry_operations);
59812 +
59813 + gr_handle_proc_create(child, inode);
59814 +
59815 d_add(child, inode);
59816 }
59817 } else {
59818 @@ -641,6 +674,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59819 if ((*pos)++ < ctx->pos)
59820 return true;
59821
59822 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59823 + return 0;
59824 +
59825 if (unlikely(S_ISLNK(table->mode)))
59826 res = proc_sys_link_fill_cache(file, ctx, head, table);
59827 else
59828 @@ -734,6 +770,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59829 if (IS_ERR(head))
59830 return PTR_ERR(head);
59831
59832 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59833 + return -ENOENT;
59834 +
59835 generic_fillattr(inode, stat);
59836 if (table)
59837 stat->mode = (stat->mode & S_IFMT) | table->mode;
59838 @@ -756,13 +795,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59839 .llseek = generic_file_llseek,
59840 };
59841
59842 -static const struct inode_operations proc_sys_inode_operations = {
59843 +const struct inode_operations proc_sys_inode_operations = {
59844 .permission = proc_sys_permission,
59845 .setattr = proc_sys_setattr,
59846 .getattr = proc_sys_getattr,
59847 };
59848
59849 -static const struct inode_operations proc_sys_dir_operations = {
59850 +const struct inode_operations proc_sys_dir_operations = {
59851 .lookup = proc_sys_lookup,
59852 .permission = proc_sys_permission,
59853 .setattr = proc_sys_setattr,
59854 @@ -839,7 +878,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59855 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59856 const char *name, int namelen)
59857 {
59858 - struct ctl_table *table;
59859 + ctl_table_no_const *table;
59860 struct ctl_dir *new;
59861 struct ctl_node *node;
59862 char *new_name;
59863 @@ -851,7 +890,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59864 return NULL;
59865
59866 node = (struct ctl_node *)(new + 1);
59867 - table = (struct ctl_table *)(node + 1);
59868 + table = (ctl_table_no_const *)(node + 1);
59869 new_name = (char *)(table + 2);
59870 memcpy(new_name, name, namelen);
59871 new_name[namelen] = '\0';
59872 @@ -1020,7 +1059,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59873 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59874 struct ctl_table_root *link_root)
59875 {
59876 - struct ctl_table *link_table, *entry, *link;
59877 + ctl_table_no_const *link_table, *link;
59878 + struct ctl_table *entry;
59879 struct ctl_table_header *links;
59880 struct ctl_node *node;
59881 char *link_name;
59882 @@ -1043,7 +1083,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59883 return NULL;
59884
59885 node = (struct ctl_node *)(links + 1);
59886 - link_table = (struct ctl_table *)(node + nr_entries);
59887 + link_table = (ctl_table_no_const *)(node + nr_entries);
59888 link_name = (char *)&link_table[nr_entries + 1];
59889
59890 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59891 @@ -1291,8 +1331,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59892 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59893 struct ctl_table *table)
59894 {
59895 - struct ctl_table *ctl_table_arg = NULL;
59896 - struct ctl_table *entry, *files;
59897 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59898 + struct ctl_table *entry;
59899 int nr_files = 0;
59900 int nr_dirs = 0;
59901 int err = -ENOMEM;
59902 @@ -1304,10 +1344,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59903 nr_files++;
59904 }
59905
59906 - files = table;
59907 /* If there are mixed files and directories we need a new table */
59908 if (nr_dirs && nr_files) {
59909 - struct ctl_table *new;
59910 + ctl_table_no_const *new;
59911 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59912 GFP_KERNEL);
59913 if (!files)
59914 @@ -1325,7 +1364,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59915 /* Register everything except a directory full of subdirectories */
59916 if (nr_files || !nr_dirs) {
59917 struct ctl_table_header *header;
59918 - header = __register_sysctl_table(set, path, files);
59919 + header = __register_sysctl_table(set, path, files ? files : table);
59920 if (!header) {
59921 kfree(ctl_table_arg);
59922 goto out;
59923 diff --git a/fs/proc/root.c b/fs/proc/root.c
59924 index 0e0e83c..005ba6a 100644
59925 --- a/fs/proc/root.c
59926 +++ b/fs/proc/root.c
59927 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
59928 #ifdef CONFIG_PROC_DEVICETREE
59929 proc_device_tree_init();
59930 #endif
59931 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59932 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59933 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59934 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59935 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59936 +#endif
59937 +#else
59938 proc_mkdir("bus", NULL);
59939 +#endif
59940 proc_sys_init();
59941 }
59942
59943 diff --git a/fs/proc/self.c b/fs/proc/self.c
59944 index 6b6a993..807cccc 100644
59945 --- a/fs/proc/self.c
59946 +++ b/fs/proc/self.c
59947 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59948 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59949 void *cookie)
59950 {
59951 - char *s = nd_get_link(nd);
59952 + const char *s = nd_get_link(nd);
59953 if (!IS_ERR(s))
59954 kfree(s);
59955 }
59956 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59957 index 7a9e255..03763e3 100644
59958 --- a/fs/proc/task_mmu.c
59959 +++ b/fs/proc/task_mmu.c
59960 @@ -12,12 +12,19 @@
59961 #include <linux/swap.h>
59962 #include <linux/swapops.h>
59963 #include <linux/mmu_notifier.h>
59964 +#include <linux/grsecurity.h>
59965
59966 #include <asm/elf.h>
59967 #include <asm/uaccess.h>
59968 #include <asm/tlbflush.h>
59969 #include "internal.h"
59970
59971 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59972 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59973 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59974 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59975 +#endif
59976 +
59977 void task_mem(struct seq_file *m, struct mm_struct *mm)
59978 {
59979 unsigned long data, text, lib, swap;
59980 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59981 "VmExe:\t%8lu kB\n"
59982 "VmLib:\t%8lu kB\n"
59983 "VmPTE:\t%8lu kB\n"
59984 - "VmSwap:\t%8lu kB\n",
59985 - hiwater_vm << (PAGE_SHIFT-10),
59986 + "VmSwap:\t%8lu kB\n"
59987 +
59988 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59989 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
59990 +#endif
59991 +
59992 + ,hiwater_vm << (PAGE_SHIFT-10),
59993 total_vm << (PAGE_SHIFT-10),
59994 mm->locked_vm << (PAGE_SHIFT-10),
59995 mm->pinned_vm << (PAGE_SHIFT-10),
59996 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59997 data << (PAGE_SHIFT-10),
59998 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
59999 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60000 - swap << (PAGE_SHIFT-10));
60001 + swap << (PAGE_SHIFT-10)
60002 +
60003 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60004 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60005 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60006 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60007 +#else
60008 + , mm->context.user_cs_base
60009 + , mm->context.user_cs_limit
60010 +#endif
60011 +#endif
60012 +
60013 + );
60014 }
60015
60016 unsigned long task_vsize(struct mm_struct *mm)
60017 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60018 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60019 }
60020
60021 - /* We don't show the stack guard page in /proc/maps */
60022 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60023 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60024 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60025 +#else
60026 start = vma->vm_start;
60027 - if (stack_guard_page_start(vma, start))
60028 - start += PAGE_SIZE;
60029 end = vma->vm_end;
60030 - if (stack_guard_page_end(vma, end))
60031 - end -= PAGE_SIZE;
60032 +#endif
60033
60034 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60035 start,
60036 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60037 flags & VM_WRITE ? 'w' : '-',
60038 flags & VM_EXEC ? 'x' : '-',
60039 flags & VM_MAYSHARE ? 's' : 'p',
60040 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60041 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60042 +#else
60043 pgoff,
60044 +#endif
60045 MAJOR(dev), MINOR(dev), ino, &len);
60046
60047 /*
60048 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60049 */
60050 if (file) {
60051 pad_len_spaces(m, len);
60052 - seq_path(m, &file->f_path, "\n");
60053 + seq_path(m, &file->f_path, "\n\\");
60054 goto done;
60055 }
60056
60057 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60058 * Thread stack in /proc/PID/task/TID/maps or
60059 * the main process stack.
60060 */
60061 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60062 - vma->vm_end >= mm->start_stack)) {
60063 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60064 + (vma->vm_start <= mm->start_stack &&
60065 + vma->vm_end >= mm->start_stack)) {
60066 name = "[stack]";
60067 } else {
60068 /* Thread stack in /proc/PID/maps */
60069 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60070 struct proc_maps_private *priv = m->private;
60071 struct task_struct *task = priv->task;
60072
60073 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60074 + if (current->exec_id != m->exec_id) {
60075 + gr_log_badprocpid("maps");
60076 + return 0;
60077 + }
60078 +#endif
60079 +
60080 show_map_vma(m, vma, is_pid);
60081
60082 if (m->count < m->size) /* vma is copied successfully */
60083 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60084 .private = &mss,
60085 };
60086
60087 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60088 + if (current->exec_id != m->exec_id) {
60089 + gr_log_badprocpid("smaps");
60090 + return 0;
60091 + }
60092 +#endif
60093 memset(&mss, 0, sizeof mss);
60094 - mss.vma = vma;
60095 - /* mmap_sem is held in m_start */
60096 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60097 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60098 -
60099 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60100 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60101 +#endif
60102 + mss.vma = vma;
60103 + /* mmap_sem is held in m_start */
60104 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60105 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60106 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60107 + }
60108 +#endif
60109 show_map_vma(m, vma, is_pid);
60110
60111 seq_printf(m,
60112 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60113 "KernelPageSize: %8lu kB\n"
60114 "MMUPageSize: %8lu kB\n"
60115 "Locked: %8lu kB\n",
60116 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60117 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60118 +#else
60119 (vma->vm_end - vma->vm_start) >> 10,
60120 +#endif
60121 mss.resident >> 10,
60122 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60123 mss.shared_clean >> 10,
60124 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60125 int n;
60126 char buffer[50];
60127
60128 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60129 + if (current->exec_id != m->exec_id) {
60130 + gr_log_badprocpid("numa_maps");
60131 + return 0;
60132 + }
60133 +#endif
60134 +
60135 if (!mm)
60136 return 0;
60137
60138 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60139 mpol_to_str(buffer, sizeof(buffer), pol);
60140 mpol_cond_put(pol);
60141
60142 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60143 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60144 +#else
60145 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60146 +#endif
60147
60148 if (file) {
60149 seq_printf(m, " file=");
60150 - seq_path(m, &file->f_path, "\n\t= ");
60151 + seq_path(m, &file->f_path, "\n\t\\= ");
60152 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60153 seq_printf(m, " heap");
60154 } else {
60155 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60156 index 56123a6..5a2f6ec 100644
60157 --- a/fs/proc/task_nommu.c
60158 +++ b/fs/proc/task_nommu.c
60159 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60160 else
60161 bytes += kobjsize(mm);
60162
60163 - if (current->fs && current->fs->users > 1)
60164 + if (current->fs && atomic_read(&current->fs->users) > 1)
60165 sbytes += kobjsize(current->fs);
60166 else
60167 bytes += kobjsize(current->fs);
60168 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60169
60170 if (file) {
60171 pad_len_spaces(m, len);
60172 - seq_path(m, &file->f_path, "");
60173 + seq_path(m, &file->f_path, "\n\\");
60174 } else if (mm) {
60175 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60176
60177 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60178 index a1a16eb..6be46ed 100644
60179 --- a/fs/proc/vmcore.c
60180 +++ b/fs/proc/vmcore.c
60181 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60182 nr_bytes = count;
60183
60184 /* If pfn is not ram, return zeros for sparse dump files */
60185 - if (pfn_is_ram(pfn) == 0)
60186 - memset(buf, 0, nr_bytes);
60187 - else {
60188 + if (pfn_is_ram(pfn) == 0) {
60189 + if (userbuf) {
60190 + if (clear_user((char __force_user *)buf, nr_bytes))
60191 + return -EFAULT;
60192 + } else
60193 + memset(buf, 0, nr_bytes);
60194 + } else {
60195 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60196 offset, userbuf);
60197 if (tmp < 0)
60198 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60199 if (*fpos < m->offset + m->size) {
60200 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60201 start = m->paddr + *fpos - m->offset;
60202 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60203 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60204 if (tmp < 0)
60205 return tmp;
60206 buflen -= tsz;
60207 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60208 index b00fcc9..e0c6381 100644
60209 --- a/fs/qnx6/qnx6.h
60210 +++ b/fs/qnx6/qnx6.h
60211 @@ -74,7 +74,7 @@ enum {
60212 BYTESEX_BE,
60213 };
60214
60215 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60216 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60217 {
60218 if (sbi->s_bytesex == BYTESEX_LE)
60219 return le64_to_cpu((__force __le64)n);
60220 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60221 return (__force __fs64)cpu_to_be64(n);
60222 }
60223
60224 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60225 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60226 {
60227 if (sbi->s_bytesex == BYTESEX_LE)
60228 return le32_to_cpu((__force __le32)n);
60229 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60230 index 16e8abb..2dcf914 100644
60231 --- a/fs/quota/netlink.c
60232 +++ b/fs/quota/netlink.c
60233 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60234 void quota_send_warning(struct kqid qid, dev_t dev,
60235 const char warntype)
60236 {
60237 - static atomic_t seq;
60238 + static atomic_unchecked_t seq;
60239 struct sk_buff *skb;
60240 void *msg_head;
60241 int ret;
60242 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60243 "VFS: Not enough memory to send quota warning.\n");
60244 return;
60245 }
60246 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60247 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60248 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60249 if (!msg_head) {
60250 printk(KERN_ERR
60251 diff --git a/fs/read_write.c b/fs/read_write.c
60252 index 122a384..0b7ecf2 100644
60253 --- a/fs/read_write.c
60254 +++ b/fs/read_write.c
60255 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60256
60257 old_fs = get_fs();
60258 set_fs(get_ds());
60259 - p = (__force const char __user *)buf;
60260 + p = (const char __force_user *)buf;
60261 if (count > MAX_RW_COUNT)
60262 count = MAX_RW_COUNT;
60263 if (file->f_op->write)
60264 diff --git a/fs/readdir.c b/fs/readdir.c
60265 index 93d71e5..6a14be8 100644
60266 --- a/fs/readdir.c
60267 +++ b/fs/readdir.c
60268 @@ -17,6 +17,7 @@
60269 #include <linux/security.h>
60270 #include <linux/syscalls.h>
60271 #include <linux/unistd.h>
60272 +#include <linux/namei.h>
60273
60274 #include <asm/uaccess.h>
60275
60276 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60277 struct readdir_callback {
60278 struct dir_context ctx;
60279 struct old_linux_dirent __user * dirent;
60280 + struct file * file;
60281 int result;
60282 };
60283
60284 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60285 buf->result = -EOVERFLOW;
60286 return -EOVERFLOW;
60287 }
60288 +
60289 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60290 + return 0;
60291 +
60292 buf->result++;
60293 dirent = buf->dirent;
60294 if (!access_ok(VERIFY_WRITE, dirent,
60295 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60296 if (!f.file)
60297 return -EBADF;
60298
60299 + buf.file = f.file;
60300 error = iterate_dir(f.file, &buf.ctx);
60301 if (buf.result)
60302 error = buf.result;
60303 @@ -142,6 +149,7 @@ struct getdents_callback {
60304 struct dir_context ctx;
60305 struct linux_dirent __user * current_dir;
60306 struct linux_dirent __user * previous;
60307 + struct file * file;
60308 int count;
60309 int error;
60310 };
60311 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60312 buf->error = -EOVERFLOW;
60313 return -EOVERFLOW;
60314 }
60315 +
60316 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60317 + return 0;
60318 +
60319 dirent = buf->previous;
60320 if (dirent) {
60321 if (__put_user(offset, &dirent->d_off))
60322 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60323 if (!f.file)
60324 return -EBADF;
60325
60326 + buf.file = f.file;
60327 error = iterate_dir(f.file, &buf.ctx);
60328 if (error >= 0)
60329 error = buf.error;
60330 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60331 struct dir_context ctx;
60332 struct linux_dirent64 __user * current_dir;
60333 struct linux_dirent64 __user * previous;
60334 + struct file *file;
60335 int count;
60336 int error;
60337 };
60338 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60339 buf->error = -EINVAL; /* only used if we fail.. */
60340 if (reclen > buf->count)
60341 return -EINVAL;
60342 +
60343 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60344 + return 0;
60345 +
60346 dirent = buf->previous;
60347 if (dirent) {
60348 if (__put_user(offset, &dirent->d_off))
60349 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60350 if (!f.file)
60351 return -EBADF;
60352
60353 + buf.file = f.file;
60354 error = iterate_dir(f.file, &buf.ctx);
60355 if (error >= 0)
60356 error = buf.error;
60357 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60358 index 2b7882b..1c5ef48 100644
60359 --- a/fs/reiserfs/do_balan.c
60360 +++ b/fs/reiserfs/do_balan.c
60361 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60362 return;
60363 }
60364
60365 - atomic_inc(&(fs_generation(tb->tb_sb)));
60366 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60367 do_balance_starts(tb);
60368
60369 /* balance leaf returns 0 except if combining L R and S into
60370 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60371 index a958444..42b2323 100644
60372 --- a/fs/reiserfs/procfs.c
60373 +++ b/fs/reiserfs/procfs.c
60374 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60375 "SMALL_TAILS " : "NO_TAILS ",
60376 replay_only(sb) ? "REPLAY_ONLY " : "",
60377 convert_reiserfs(sb) ? "CONV " : "",
60378 - atomic_read(&r->s_generation_counter),
60379 + atomic_read_unchecked(&r->s_generation_counter),
60380 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60381 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60382 SF(s_good_search_by_key_reada), SF(s_bmaps),
60383 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60384 index 3df5ce6..8c0f4b0 100644
60385 --- a/fs/reiserfs/reiserfs.h
60386 +++ b/fs/reiserfs/reiserfs.h
60387 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60388 /* Comment? -Hans */
60389 wait_queue_head_t s_wait;
60390 /* To be obsoleted soon by per buffer seals.. -Hans */
60391 - atomic_t s_generation_counter; // increased by one every time the
60392 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60393 // tree gets re-balanced
60394 unsigned long s_properties; /* File system properties. Currently holds
60395 on-disk FS format */
60396 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60397 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60398
60399 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60400 -#define get_generation(s) atomic_read (&fs_generation(s))
60401 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60402 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60403 #define __fs_changed(gen,s) (gen != get_generation (s))
60404 #define fs_changed(gen,s) \
60405 diff --git a/fs/select.c b/fs/select.c
60406 index dfd5cb1..1754d57 100644
60407 --- a/fs/select.c
60408 +++ b/fs/select.c
60409 @@ -20,6 +20,7 @@
60410 #include <linux/export.h>
60411 #include <linux/slab.h>
60412 #include <linux/poll.h>
60413 +#include <linux/security.h>
60414 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60415 #include <linux/file.h>
60416 #include <linux/fdtable.h>
60417 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60418 struct poll_list *walk = head;
60419 unsigned long todo = nfds;
60420
60421 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60422 if (nfds > rlimit(RLIMIT_NOFILE))
60423 return -EINVAL;
60424
60425 diff --git a/fs/seq_file.c b/fs/seq_file.c
60426 index a290157..5fa85e4 100644
60427 --- a/fs/seq_file.c
60428 +++ b/fs/seq_file.c
60429 @@ -10,6 +10,7 @@
60430 #include <linux/seq_file.h>
60431 #include <linux/slab.h>
60432 #include <linux/cred.h>
60433 +#include <linux/sched.h>
60434
60435 #include <asm/uaccess.h>
60436 #include <asm/page.h>
60437 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60438 #ifdef CONFIG_USER_NS
60439 p->user_ns = file->f_cred->user_ns;
60440 #endif
60441 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60442 + p->exec_id = current->exec_id;
60443 +#endif
60444
60445 /*
60446 * Wrappers around seq_open(e.g. swaps_open) need to be
60447 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60448 return 0;
60449 }
60450 if (!m->buf) {
60451 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60452 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60453 if (!m->buf)
60454 return -ENOMEM;
60455 }
60456 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60457 Eoverflow:
60458 m->op->stop(m, p);
60459 kfree(m->buf);
60460 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60461 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60462 return !m->buf ? -ENOMEM : -EAGAIN;
60463 }
60464
60465 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60466
60467 /* grab buffer if we didn't have one */
60468 if (!m->buf) {
60469 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60470 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60471 if (!m->buf)
60472 goto Enomem;
60473 }
60474 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60475 goto Fill;
60476 m->op->stop(m, p);
60477 kfree(m->buf);
60478 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60479 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60480 if (!m->buf)
60481 goto Enomem;
60482 m->count = 0;
60483 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
60484 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60485 void *data)
60486 {
60487 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60488 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60489 int res = -ENOMEM;
60490
60491 if (op) {
60492 diff --git a/fs/splice.c b/fs/splice.c
60493 index 3b7ee65..87fc2e4 100644
60494 --- a/fs/splice.c
60495 +++ b/fs/splice.c
60496 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60497 pipe_lock(pipe);
60498
60499 for (;;) {
60500 - if (!pipe->readers) {
60501 + if (!atomic_read(&pipe->readers)) {
60502 send_sig(SIGPIPE, current, 0);
60503 if (!ret)
60504 ret = -EPIPE;
60505 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60506 page_nr++;
60507 ret += buf->len;
60508
60509 - if (pipe->files)
60510 + if (atomic_read(&pipe->files))
60511 do_wakeup = 1;
60512
60513 if (!--spd->nr_pages)
60514 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60515 do_wakeup = 0;
60516 }
60517
60518 - pipe->waiting_writers++;
60519 + atomic_inc(&pipe->waiting_writers);
60520 pipe_wait(pipe);
60521 - pipe->waiting_writers--;
60522 + atomic_dec(&pipe->waiting_writers);
60523 }
60524
60525 pipe_unlock(pipe);
60526 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60527 old_fs = get_fs();
60528 set_fs(get_ds());
60529 /* The cast to a user pointer is valid due to the set_fs() */
60530 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60531 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60532 set_fs(old_fs);
60533
60534 return res;
60535 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60536 old_fs = get_fs();
60537 set_fs(get_ds());
60538 /* The cast to a user pointer is valid due to the set_fs() */
60539 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60540 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60541 set_fs(old_fs);
60542
60543 return res;
60544 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60545 goto err;
60546
60547 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60548 - vec[i].iov_base = (void __user *) page_address(page);
60549 + vec[i].iov_base = (void __force_user *) page_address(page);
60550 vec[i].iov_len = this_len;
60551 spd.pages[i] = page;
60552 spd.nr_pages++;
60553 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60554 ops->release(pipe, buf);
60555 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60556 pipe->nrbufs--;
60557 - if (pipe->files)
60558 + if (atomic_read(&pipe->files))
60559 sd->need_wakeup = true;
60560 }
60561
60562 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60563 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60564 {
60565 while (!pipe->nrbufs) {
60566 - if (!pipe->writers)
60567 + if (!atomic_read(&pipe->writers))
60568 return 0;
60569
60570 - if (!pipe->waiting_writers && sd->num_spliced)
60571 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60572 return 0;
60573
60574 if (sd->flags & SPLICE_F_NONBLOCK)
60575 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60576 * out of the pipe right after the splice_to_pipe(). So set
60577 * PIPE_READERS appropriately.
60578 */
60579 - pipe->readers = 1;
60580 + atomic_set(&pipe->readers, 1);
60581
60582 current->splice_pipe = pipe;
60583 }
60584 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60585
60586 partial[buffers].offset = off;
60587 partial[buffers].len = plen;
60588 + partial[buffers].private = 0;
60589
60590 off = 0;
60591 len -= plen;
60592 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60593 ret = -ERESTARTSYS;
60594 break;
60595 }
60596 - if (!pipe->writers)
60597 + if (!atomic_read(&pipe->writers))
60598 break;
60599 - if (!pipe->waiting_writers) {
60600 + if (!atomic_read(&pipe->waiting_writers)) {
60601 if (flags & SPLICE_F_NONBLOCK) {
60602 ret = -EAGAIN;
60603 break;
60604 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60605 pipe_lock(pipe);
60606
60607 while (pipe->nrbufs >= pipe->buffers) {
60608 - if (!pipe->readers) {
60609 + if (!atomic_read(&pipe->readers)) {
60610 send_sig(SIGPIPE, current, 0);
60611 ret = -EPIPE;
60612 break;
60613 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60614 ret = -ERESTARTSYS;
60615 break;
60616 }
60617 - pipe->waiting_writers++;
60618 + atomic_inc(&pipe->waiting_writers);
60619 pipe_wait(pipe);
60620 - pipe->waiting_writers--;
60621 + atomic_dec(&pipe->waiting_writers);
60622 }
60623
60624 pipe_unlock(pipe);
60625 @@ -1862,14 +1863,14 @@ retry:
60626 pipe_double_lock(ipipe, opipe);
60627
60628 do {
60629 - if (!opipe->readers) {
60630 + if (!atomic_read(&opipe->readers)) {
60631 send_sig(SIGPIPE, current, 0);
60632 if (!ret)
60633 ret = -EPIPE;
60634 break;
60635 }
60636
60637 - if (!ipipe->nrbufs && !ipipe->writers)
60638 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60639 break;
60640
60641 /*
60642 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60643 pipe_double_lock(ipipe, opipe);
60644
60645 do {
60646 - if (!opipe->readers) {
60647 + if (!atomic_read(&opipe->readers)) {
60648 send_sig(SIGPIPE, current, 0);
60649 if (!ret)
60650 ret = -EPIPE;
60651 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60652 * return EAGAIN if we have the potential of some data in the
60653 * future, otherwise just return 0
60654 */
60655 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60656 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60657 ret = -EAGAIN;
60658
60659 pipe_unlock(ipipe);
60660 diff --git a/fs/stat.c b/fs/stat.c
60661 index 04ce1ac..a13dd1e 100644
60662 --- a/fs/stat.c
60663 +++ b/fs/stat.c
60664 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60665 stat->gid = inode->i_gid;
60666 stat->rdev = inode->i_rdev;
60667 stat->size = i_size_read(inode);
60668 - stat->atime = inode->i_atime;
60669 - stat->mtime = inode->i_mtime;
60670 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60671 + stat->atime = inode->i_ctime;
60672 + stat->mtime = inode->i_ctime;
60673 + } else {
60674 + stat->atime = inode->i_atime;
60675 + stat->mtime = inode->i_mtime;
60676 + }
60677 stat->ctime = inode->i_ctime;
60678 stat->blksize = (1 << inode->i_blkbits);
60679 stat->blocks = inode->i_blocks;
60680 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60681 if (retval)
60682 return retval;
60683
60684 - if (inode->i_op->getattr)
60685 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60686 + if (inode->i_op->getattr) {
60687 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60688 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60689 + stat->atime = stat->ctime;
60690 + stat->mtime = stat->ctime;
60691 + }
60692 + return retval;
60693 + }
60694
60695 generic_fillattr(inode, stat);
60696 return 0;
60697 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60698 index 15c68f9..36a8b3e 100644
60699 --- a/fs/sysfs/bin.c
60700 +++ b/fs/sysfs/bin.c
60701 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60702 return ret;
60703 }
60704
60705 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60706 - void *buf, int len, int write)
60707 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60708 + void *buf, size_t len, int write)
60709 {
60710 struct file *file = vma->vm_file;
60711 struct bin_buffer *bb = file->private_data;
60712 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60713 - int ret;
60714 + ssize_t ret;
60715
60716 if (!bb->vm_ops)
60717 return -EINVAL;
60718 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60719 index e068e74..92edeb8 100644
60720 --- a/fs/sysfs/dir.c
60721 +++ b/fs/sysfs/dir.c
60722 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60723 *
60724 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60725 */
60726 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60727 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60728 {
60729 unsigned long hash = init_name_hash();
60730 unsigned int len = strlen(name);
60731 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60732 struct sysfs_dirent *sd;
60733 int rc;
60734
60735 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60736 + const char *parent_name = parent_sd->s_name;
60737 +
60738 + mode = S_IFDIR | S_IRWXU;
60739 +
60740 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60741 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60742 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60743 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60744 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60745 +#endif
60746 +
60747 /* allocate */
60748 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60749 if (!sd)
60750 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60751 index d2bb7ed..fe8c331 100644
60752 --- a/fs/sysfs/file.c
60753 +++ b/fs/sysfs/file.c
60754 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60755
60756 struct sysfs_open_dirent {
60757 atomic_t refcnt;
60758 - atomic_t event;
60759 + atomic_unchecked_t event;
60760 wait_queue_head_t poll;
60761 struct list_head buffers; /* goes through sysfs_buffer.list */
60762 };
60763 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60764 if (!sysfs_get_active(attr_sd))
60765 return -ENODEV;
60766
60767 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60768 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60769 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60770
60771 sysfs_put_active(attr_sd);
60772 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60773 return -ENOMEM;
60774
60775 atomic_set(&new_od->refcnt, 0);
60776 - atomic_set(&new_od->event, 1);
60777 + atomic_set_unchecked(&new_od->event, 1);
60778 init_waitqueue_head(&new_od->poll);
60779 INIT_LIST_HEAD(&new_od->buffers);
60780 goto retry;
60781 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60782
60783 sysfs_put_active(attr_sd);
60784
60785 - if (buffer->event != atomic_read(&od->event))
60786 + if (buffer->event != atomic_read_unchecked(&od->event))
60787 goto trigger;
60788
60789 return DEFAULT_POLLMASK;
60790 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60791 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60792 od = sd->s_attr.open;
60793 if (od) {
60794 - atomic_inc(&od->event);
60795 + atomic_inc_unchecked(&od->event);
60796 wake_up_interruptible(&od->poll);
60797 }
60798 }
60799 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60800 index 8c940df..25b733e 100644
60801 --- a/fs/sysfs/symlink.c
60802 +++ b/fs/sysfs/symlink.c
60803 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60804
60805 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60806 {
60807 - char *page = nd_get_link(nd);
60808 + const char *page = nd_get_link(nd);
60809 if (!IS_ERR(page))
60810 free_page((unsigned long)page);
60811 }
60812 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60813 index 69d4889..a810bd4 100644
60814 --- a/fs/sysv/sysv.h
60815 +++ b/fs/sysv/sysv.h
60816 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60817 #endif
60818 }
60819
60820 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60821 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60822 {
60823 if (sbi->s_bytesex == BYTESEX_PDP)
60824 return PDP_swab((__force __u32)n);
60825 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60826 index e18b988..f1d4ad0f 100644
60827 --- a/fs/ubifs/io.c
60828 +++ b/fs/ubifs/io.c
60829 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60830 return err;
60831 }
60832
60833 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60834 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60835 {
60836 int err;
60837
60838 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60839 index c175b4d..8f36a16 100644
60840 --- a/fs/udf/misc.c
60841 +++ b/fs/udf/misc.c
60842 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60843
60844 u8 udf_tag_checksum(const struct tag *t)
60845 {
60846 - u8 *data = (u8 *)t;
60847 + const u8 *data = (const u8 *)t;
60848 u8 checksum = 0;
60849 int i;
60850 for (i = 0; i < sizeof(struct tag); ++i)
60851 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60852 index 8d974c4..b82f6ec 100644
60853 --- a/fs/ufs/swab.h
60854 +++ b/fs/ufs/swab.h
60855 @@ -22,7 +22,7 @@ enum {
60856 BYTESEX_BE
60857 };
60858
60859 -static inline u64
60860 +static inline u64 __intentional_overflow(-1)
60861 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60862 {
60863 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60864 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60865 return (__force __fs64)cpu_to_be64(n);
60866 }
60867
60868 -static inline u32
60869 +static inline u32 __intentional_overflow(-1)
60870 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60871 {
60872 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60873 diff --git a/fs/utimes.c b/fs/utimes.c
60874 index f4fb7ec..3fe03c0 100644
60875 --- a/fs/utimes.c
60876 +++ b/fs/utimes.c
60877 @@ -1,6 +1,7 @@
60878 #include <linux/compiler.h>
60879 #include <linux/file.h>
60880 #include <linux/fs.h>
60881 +#include <linux/security.h>
60882 #include <linux/linkage.h>
60883 #include <linux/mount.h>
60884 #include <linux/namei.h>
60885 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60886 goto mnt_drop_write_and_out;
60887 }
60888 }
60889 +
60890 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60891 + error = -EACCES;
60892 + goto mnt_drop_write_and_out;
60893 + }
60894 +
60895 mutex_lock(&inode->i_mutex);
60896 error = notify_change(path->dentry, &newattrs);
60897 mutex_unlock(&inode->i_mutex);
60898 diff --git a/fs/xattr.c b/fs/xattr.c
60899 index 3377dff..4d074d9 100644
60900 --- a/fs/xattr.c
60901 +++ b/fs/xattr.c
60902 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60903 return rc;
60904 }
60905
60906 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60907 +ssize_t
60908 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60909 +{
60910 + struct inode *inode = dentry->d_inode;
60911 + ssize_t error;
60912 +
60913 + error = inode_permission(inode, MAY_EXEC);
60914 + if (error)
60915 + return error;
60916 +
60917 + if (inode->i_op->getxattr)
60918 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60919 + else
60920 + error = -EOPNOTSUPP;
60921 +
60922 + return error;
60923 +}
60924 +EXPORT_SYMBOL(pax_getxattr);
60925 +#endif
60926 +
60927 ssize_t
60928 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60929 {
60930 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60931 * Extended attribute SET operations
60932 */
60933 static long
60934 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60935 +setxattr(struct path *path, const char __user *name, const void __user *value,
60936 size_t size, int flags)
60937 {
60938 int error;
60939 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60940 posix_acl_fix_xattr_from_user(kvalue, size);
60941 }
60942
60943 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60944 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60945 + error = -EACCES;
60946 + goto out;
60947 + }
60948 +
60949 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60950 out:
60951 if (vvalue)
60952 vfree(vvalue);
60953 @@ -377,7 +403,7 @@ retry:
60954 return error;
60955 error = mnt_want_write(path.mnt);
60956 if (!error) {
60957 - error = setxattr(path.dentry, name, value, size, flags);
60958 + error = setxattr(&path, name, value, size, flags);
60959 mnt_drop_write(path.mnt);
60960 }
60961 path_put(&path);
60962 @@ -401,7 +427,7 @@ retry:
60963 return error;
60964 error = mnt_want_write(path.mnt);
60965 if (!error) {
60966 - error = setxattr(path.dentry, name, value, size, flags);
60967 + error = setxattr(&path, name, value, size, flags);
60968 mnt_drop_write(path.mnt);
60969 }
60970 path_put(&path);
60971 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60972 const void __user *,value, size_t, size, int, flags)
60973 {
60974 struct fd f = fdget(fd);
60975 - struct dentry *dentry;
60976 int error = -EBADF;
60977
60978 if (!f.file)
60979 return error;
60980 - dentry = f.file->f_path.dentry;
60981 - audit_inode(NULL, dentry, 0);
60982 + audit_inode(NULL, f.file->f_path.dentry, 0);
60983 error = mnt_want_write_file(f.file);
60984 if (!error) {
60985 - error = setxattr(dentry, name, value, size, flags);
60986 + error = setxattr(&f.file->f_path, name, value, size, flags);
60987 mnt_drop_write_file(f.file);
60988 }
60989 fdput(f);
60990 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
60991 index 9fbea87..6b19972 100644
60992 --- a/fs/xattr_acl.c
60993 +++ b/fs/xattr_acl.c
60994 @@ -76,8 +76,8 @@ struct posix_acl *
60995 posix_acl_from_xattr(struct user_namespace *user_ns,
60996 const void *value, size_t size)
60997 {
60998 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
60999 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61000 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61001 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61002 int count;
61003 struct posix_acl *acl;
61004 struct posix_acl_entry *acl_e;
61005 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61006 index 05c698c..6b918af 100644
61007 --- a/fs/xfs/xfs_bmap.c
61008 +++ b/fs/xfs/xfs_bmap.c
61009 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
61010
61011 #else
61012 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61013 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61014 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61015 #endif /* DEBUG */
61016
61017 /*
61018 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
61019 index 97676a3..399a75d 100644
61020 --- a/fs/xfs/xfs_dir2_sf.c
61021 +++ b/fs/xfs/xfs_dir2_sf.c
61022 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
61023
61024 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
61025 ctx->pos = off & 0x7fffffff;
61026 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61027 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61028 + char name[sfep->namelen];
61029 + memcpy(name, sfep->name, sfep->namelen);
61030 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
61031 + return 0;
61032 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61033 ino, DT_UNKNOWN))
61034 return 0;
61035 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
61036 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61037 index 6e2bca5..6ce80d3 100644
61038 --- a/fs/xfs/xfs_ioctl.c
61039 +++ b/fs/xfs/xfs_ioctl.c
61040 @@ -127,7 +127,7 @@ xfs_find_handle(
61041 }
61042
61043 error = -EFAULT;
61044 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61045 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61046 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61047 goto out_put;
61048
61049 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61050 index 96dda62..d6c6a52 100644
61051 --- a/fs/xfs/xfs_iops.c
61052 +++ b/fs/xfs/xfs_iops.c
61053 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61054 struct nameidata *nd,
61055 void *p)
61056 {
61057 - char *s = nd_get_link(nd);
61058 + const char *s = nd_get_link(nd);
61059
61060 if (!IS_ERR(s))
61061 kfree(s);
61062 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61063 new file mode 100644
61064 index 0000000..6d22fbe
61065 --- /dev/null
61066 +++ b/grsecurity/Kconfig
61067 @@ -0,0 +1,1112 @@
61068 +#
61069 +# grecurity configuration
61070 +#
61071 +menu "Memory Protections"
61072 +depends on GRKERNSEC
61073 +
61074 +config GRKERNSEC_KMEM
61075 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61076 + default y if GRKERNSEC_CONFIG_AUTO
61077 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61078 + help
61079 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61080 + be written to or read from to modify or leak the contents of the running
61081 + kernel. /dev/port will also not be allowed to be opened and support
61082 + for /dev/cpu/*/msr will be removed. If you have module
61083 + support disabled, enabling this will close up five ways that are
61084 + currently used to insert malicious code into the running kernel.
61085 +
61086 + Even with all these features enabled, we still highly recommend that
61087 + you use the RBAC system, as it is still possible for an attacker to
61088 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61089 +
61090 + If you are not using XFree86, you may be able to stop this additional
61091 + case by enabling the 'Disable privileged I/O' option. Though nothing
61092 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61093 + but only to video memory, which is the only writing we allow in this
61094 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61095 + not be allowed to mprotect it with PROT_WRITE later.
61096 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61097 + from working.
61098 +
61099 + It is highly recommended that you say Y here if you meet all the
61100 + conditions above.
61101 +
61102 +config GRKERNSEC_VM86
61103 + bool "Restrict VM86 mode"
61104 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61105 + depends on X86_32
61106 +
61107 + help
61108 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61109 + make use of a special execution mode on 32bit x86 processors called
61110 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61111 + video cards and will still work with this option enabled. The purpose
61112 + of the option is to prevent exploitation of emulation errors in
61113 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61114 + Nearly all users should be able to enable this option.
61115 +
61116 +config GRKERNSEC_IO
61117 + bool "Disable privileged I/O"
61118 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61119 + depends on X86
61120 + select RTC_CLASS
61121 + select RTC_INTF_DEV
61122 + select RTC_DRV_CMOS
61123 +
61124 + help
61125 + If you say Y here, all ioperm and iopl calls will return an error.
61126 + Ioperm and iopl can be used to modify the running kernel.
61127 + Unfortunately, some programs need this access to operate properly,
61128 + the most notable of which are XFree86 and hwclock. hwclock can be
61129 + remedied by having RTC support in the kernel, so real-time
61130 + clock support is enabled if this option is enabled, to ensure
61131 + that hwclock operates correctly. XFree86 still will not
61132 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61133 + IF YOU USE XFree86. If you use XFree86 and you still want to
61134 + protect your kernel against modification, use the RBAC system.
61135 +
61136 +config GRKERNSEC_JIT_HARDEN
61137 + bool "Harden BPF JIT against spray attacks"
61138 + default y if GRKERNSEC_CONFIG_AUTO
61139 + depends on BPF_JIT
61140 + help
61141 + If you say Y here, the native code generated by the kernel's Berkeley
61142 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61143 + attacks that attempt to fit attacker-beneficial instructions in
61144 + 32bit immediate fields of JIT-generated native instructions. The
61145 + attacker will generally aim to cause an unintended instruction sequence
61146 + of JIT-generated native code to execute by jumping into the middle of
61147 + a generated instruction. This feature effectively randomizes the 32bit
61148 + immediate constants present in the generated code to thwart such attacks.
61149 +
61150 + If you're using KERNEXEC, it's recommended that you enable this option
61151 + to supplement the hardening of the kernel.
61152 +
61153 +config GRKERNSEC_PERF_HARDEN
61154 + bool "Disable unprivileged PERF_EVENTS usage by default"
61155 + default y if GRKERNSEC_CONFIG_AUTO
61156 + depends on PERF_EVENTS
61157 + help
61158 + If you say Y here, the range of acceptable values for the
61159 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61160 + default to a new value: 3. When the sysctl is set to this value, no
61161 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61162 +
61163 + Though PERF_EVENTS can be used legitimately for performance monitoring
61164 + and low-level application profiling, it is forced on regardless of
61165 + configuration, has been at fault for several vulnerabilities, and
61166 + creates new opportunities for side channels and other information leaks.
61167 +
61168 + This feature puts PERF_EVENTS into a secure default state and permits
61169 + the administrator to change out of it temporarily if unprivileged
61170 + application profiling is needed.
61171 +
61172 +config GRKERNSEC_RAND_THREADSTACK
61173 + bool "Insert random gaps between thread stacks"
61174 + default y if GRKERNSEC_CONFIG_AUTO
61175 + depends on PAX_RANDMMAP && !PPC
61176 + help
61177 + If you say Y here, a random-sized gap will be enforced between allocated
61178 + thread stacks. Glibc's NPTL and other threading libraries that
61179 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61180 + The implementation currently provides 8 bits of entropy for the gap.
61181 +
61182 + Many distributions do not compile threaded remote services with the
61183 + -fstack-check argument to GCC, causing the variable-sized stack-based
61184 + allocator, alloca(), to not probe the stack on allocation. This
61185 + permits an unbounded alloca() to skip over any guard page and potentially
61186 + modify another thread's stack reliably. An enforced random gap
61187 + reduces the reliability of such an attack and increases the chance
61188 + that such a read/write to another thread's stack instead lands in
61189 + an unmapped area, causing a crash and triggering grsecurity's
61190 + anti-bruteforcing logic.
61191 +
61192 +config GRKERNSEC_PROC_MEMMAP
61193 + bool "Harden ASLR against information leaks and entropy reduction"
61194 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61195 + depends on PAX_NOEXEC || PAX_ASLR
61196 + help
61197 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61198 + give no information about the addresses of its mappings if
61199 + PaX features that rely on random addresses are enabled on the task.
61200 + In addition to sanitizing this information and disabling other
61201 + dangerous sources of information, this option causes reads of sensitive
61202 + /proc/<pid> entries where the file descriptor was opened in a different
61203 + task than the one performing the read. Such attempts are logged.
61204 + This option also limits argv/env strings for suid/sgid binaries
61205 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61206 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61207 + binaries to prevent alternative mmap layouts from being abused.
61208 +
61209 + If you use PaX it is essential that you say Y here as it closes up
61210 + several holes that make full ASLR useless locally.
61211 +
61212 +config GRKERNSEC_BRUTE
61213 + bool "Deter exploit bruteforcing"
61214 + default y if GRKERNSEC_CONFIG_AUTO
61215 + help
61216 + If you say Y here, attempts to bruteforce exploits against forking
61217 + daemons such as apache or sshd, as well as against suid/sgid binaries
61218 + will be deterred. When a child of a forking daemon is killed by PaX
61219 + or crashes due to an illegal instruction or other suspicious signal,
61220 + the parent process will be delayed 30 seconds upon every subsequent
61221 + fork until the administrator is able to assess the situation and
61222 + restart the daemon.
61223 + In the suid/sgid case, the attempt is logged, the user has all their
61224 + existing instances of the suid/sgid binary terminated and will
61225 + be unable to execute any suid/sgid binaries for 15 minutes.
61226 +
61227 + It is recommended that you also enable signal logging in the auditing
61228 + section so that logs are generated when a process triggers a suspicious
61229 + signal.
61230 + If the sysctl option is enabled, a sysctl option with name
61231 + "deter_bruteforce" is created.
61232 +
61233 +
61234 +config GRKERNSEC_MODHARDEN
61235 + bool "Harden module auto-loading"
61236 + default y if GRKERNSEC_CONFIG_AUTO
61237 + depends on MODULES
61238 + help
61239 + If you say Y here, module auto-loading in response to use of some
61240 + feature implemented by an unloaded module will be restricted to
61241 + root users. Enabling this option helps defend against attacks
61242 + by unprivileged users who abuse the auto-loading behavior to
61243 + cause a vulnerable module to load that is then exploited.
61244 +
61245 + If this option prevents a legitimate use of auto-loading for a
61246 + non-root user, the administrator can execute modprobe manually
61247 + with the exact name of the module mentioned in the alert log.
61248 + Alternatively, the administrator can add the module to the list
61249 + of modules loaded at boot by modifying init scripts.
61250 +
61251 + Modification of init scripts will most likely be needed on
61252 + Ubuntu servers with encrypted home directory support enabled,
61253 + as the first non-root user logging in will cause the ecb(aes),
61254 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61255 +
61256 +config GRKERNSEC_HIDESYM
61257 + bool "Hide kernel symbols"
61258 + default y if GRKERNSEC_CONFIG_AUTO
61259 + select PAX_USERCOPY_SLABS
61260 + help
61261 + If you say Y here, getting information on loaded modules, and
61262 + displaying all kernel symbols through a syscall will be restricted
61263 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61264 + /proc/kallsyms will be restricted to the root user. The RBAC
61265 + system can hide that entry even from root.
61266 +
61267 + This option also prevents leaking of kernel addresses through
61268 + several /proc entries.
61269 +
61270 + Note that this option is only effective provided the following
61271 + conditions are met:
61272 + 1) The kernel using grsecurity is not precompiled by some distribution
61273 + 2) You have also enabled GRKERNSEC_DMESG
61274 + 3) You are using the RBAC system and hiding other files such as your
61275 + kernel image and System.map. Alternatively, enabling this option
61276 + causes the permissions on /boot, /lib/modules, and the kernel
61277 + source directory to change at compile time to prevent
61278 + reading by non-root users.
61279 + If the above conditions are met, this option will aid in providing a
61280 + useful protection against local kernel exploitation of overflows
61281 + and arbitrary read/write vulnerabilities.
61282 +
61283 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61284 + in addition to this feature.
61285 +
61286 +config GRKERNSEC_KERN_LOCKOUT
61287 + bool "Active kernel exploit response"
61288 + default y if GRKERNSEC_CONFIG_AUTO
61289 + depends on X86 || ARM || PPC || SPARC
61290 + help
61291 + If you say Y here, when a PaX alert is triggered due to suspicious
61292 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61293 + or an OOPS occurs due to bad memory accesses, instead of just
61294 + terminating the offending process (and potentially allowing
61295 + a subsequent exploit from the same user), we will take one of two
61296 + actions:
61297 + If the user was root, we will panic the system
61298 + If the user was non-root, we will log the attempt, terminate
61299 + all processes owned by the user, then prevent them from creating
61300 + any new processes until the system is restarted
61301 + This deters repeated kernel exploitation/bruteforcing attempts
61302 + and is useful for later forensics.
61303 +
61304 +config GRKERNSEC_OLD_ARM_USERLAND
61305 + bool "Old ARM userland compatibility"
61306 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61307 + help
61308 + If you say Y here, stubs of executable code to perform such operations
61309 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61310 + table. This is unfortunately needed for old ARM userland meant to run
61311 + across a wide range of processors. Without this option enabled,
61312 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61313 + which is enough for Linaro userlands or other userlands designed for v6
61314 + and newer ARM CPUs. It's recommended that you try without this option enabled
61315 + first, and only enable it if your userland does not boot (it will likely fail
61316 + at init time).
61317 +
61318 +endmenu
61319 +menu "Role Based Access Control Options"
61320 +depends on GRKERNSEC
61321 +
61322 +config GRKERNSEC_RBAC_DEBUG
61323 + bool
61324 +
61325 +config GRKERNSEC_NO_RBAC
61326 + bool "Disable RBAC system"
61327 + help
61328 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61329 + preventing the RBAC system from being enabled. You should only say Y
61330 + here if you have no intention of using the RBAC system, so as to prevent
61331 + an attacker with root access from misusing the RBAC system to hide files
61332 + and processes when loadable module support and /dev/[k]mem have been
61333 + locked down.
61334 +
61335 +config GRKERNSEC_ACL_HIDEKERN
61336 + bool "Hide kernel processes"
61337 + help
61338 + If you say Y here, all kernel threads will be hidden to all
61339 + processes but those whose subject has the "view hidden processes"
61340 + flag.
61341 +
61342 +config GRKERNSEC_ACL_MAXTRIES
61343 + int "Maximum tries before password lockout"
61344 + default 3
61345 + help
61346 + This option enforces the maximum number of times a user can attempt
61347 + to authorize themselves with the grsecurity RBAC system before being
61348 + denied the ability to attempt authorization again for a specified time.
61349 + The lower the number, the harder it will be to brute-force a password.
61350 +
61351 +config GRKERNSEC_ACL_TIMEOUT
61352 + int "Time to wait after max password tries, in seconds"
61353 + default 30
61354 + help
61355 + This option specifies the time the user must wait after attempting to
61356 + authorize to the RBAC system with the maximum number of invalid
61357 + passwords. The higher the number, the harder it will be to brute-force
61358 + a password.
61359 +
61360 +endmenu
61361 +menu "Filesystem Protections"
61362 +depends on GRKERNSEC
61363 +
61364 +config GRKERNSEC_PROC
61365 + bool "Proc restrictions"
61366 + default y if GRKERNSEC_CONFIG_AUTO
61367 + help
61368 + If you say Y here, the permissions of the /proc filesystem
61369 + will be altered to enhance system security and privacy. You MUST
61370 + choose either a user only restriction or a user and group restriction.
61371 + Depending upon the option you choose, you can either restrict users to
61372 + see only the processes they themselves run, or choose a group that can
61373 + view all processes and files normally restricted to root if you choose
61374 + the "restrict to user only" option. NOTE: If you're running identd or
61375 + ntpd as a non-root user, you will have to run it as the group you
61376 + specify here.
61377 +
61378 +config GRKERNSEC_PROC_USER
61379 + bool "Restrict /proc to user only"
61380 + depends on GRKERNSEC_PROC
61381 + help
61382 + If you say Y here, non-root users will only be able to view their own
61383 + processes, and restricts them from viewing network-related information,
61384 + and viewing kernel symbol and module information.
61385 +
61386 +config GRKERNSEC_PROC_USERGROUP
61387 + bool "Allow special group"
61388 + default y if GRKERNSEC_CONFIG_AUTO
61389 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61390 + help
61391 + If you say Y here, you will be able to select a group that will be
61392 + able to view all processes and network-related information. If you've
61393 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61394 + remain hidden. This option is useful if you want to run identd as
61395 + a non-root user. The group you select may also be chosen at boot time
61396 + via "grsec_proc_gid=" on the kernel commandline.
61397 +
61398 +config GRKERNSEC_PROC_GID
61399 + int "GID for special group"
61400 + depends on GRKERNSEC_PROC_USERGROUP
61401 + default 1001
61402 +
61403 +config GRKERNSEC_PROC_ADD
61404 + bool "Additional restrictions"
61405 + default y if GRKERNSEC_CONFIG_AUTO
61406 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61407 + help
61408 + If you say Y here, additional restrictions will be placed on
61409 + /proc that keep normal users from viewing device information and
61410 + slabinfo information that could be useful for exploits.
61411 +
61412 +config GRKERNSEC_LINK
61413 + bool "Linking restrictions"
61414 + default y if GRKERNSEC_CONFIG_AUTO
61415 + help
61416 + If you say Y here, /tmp race exploits will be prevented, since users
61417 + will no longer be able to follow symlinks owned by other users in
61418 + world-writable +t directories (e.g. /tmp), unless the owner of the
61419 + symlink is the owner of the directory. users will also not be
61420 + able to hardlink to files they do not own. If the sysctl option is
61421 + enabled, a sysctl option with name "linking_restrictions" is created.
61422 +
61423 +config GRKERNSEC_SYMLINKOWN
61424 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61425 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61426 + help
61427 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61428 + that prevents it from being used as a security feature. As Apache
61429 + verifies the symlink by performing a stat() against the target of
61430 + the symlink before it is followed, an attacker can setup a symlink
61431 + to point to a same-owned file, then replace the symlink with one
61432 + that targets another user's file just after Apache "validates" the
61433 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61434 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61435 + will be in place for the group you specify. If the sysctl option
61436 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61437 + created.
61438 +
61439 +config GRKERNSEC_SYMLINKOWN_GID
61440 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61441 + depends on GRKERNSEC_SYMLINKOWN
61442 + default 1006
61443 + help
61444 + Setting this GID determines what group kernel-enforced
61445 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61446 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61447 +
61448 +config GRKERNSEC_FIFO
61449 + bool "FIFO restrictions"
61450 + default y if GRKERNSEC_CONFIG_AUTO
61451 + help
61452 + If you say Y here, users will not be able to write to FIFOs they don't
61453 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61454 + the FIFO is the same owner of the directory it's held in. If the sysctl
61455 + option is enabled, a sysctl option with name "fifo_restrictions" is
61456 + created.
61457 +
61458 +config GRKERNSEC_SYSFS_RESTRICT
61459 + bool "Sysfs/debugfs restriction"
61460 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61461 + depends on SYSFS
61462 + help
61463 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61464 + any filesystem normally mounted under it (e.g. debugfs) will be
61465 + mostly accessible only by root. These filesystems generally provide access
61466 + to hardware and debug information that isn't appropriate for unprivileged
61467 + users of the system. Sysfs and debugfs have also become a large source
61468 + of new vulnerabilities, ranging from infoleaks to local compromise.
61469 + There has been very little oversight with an eye toward security involved
61470 + in adding new exporters of information to these filesystems, so their
61471 + use is discouraged.
61472 + For reasons of compatibility, a few directories have been whitelisted
61473 + for access by non-root users:
61474 + /sys/fs/selinux
61475 + /sys/fs/fuse
61476 + /sys/devices/system/cpu
61477 +
61478 +config GRKERNSEC_ROFS
61479 + bool "Runtime read-only mount protection"
61480 + depends on SYSCTL
61481 + help
61482 + If you say Y here, a sysctl option with name "romount_protect" will
61483 + be created. By setting this option to 1 at runtime, filesystems
61484 + will be protected in the following ways:
61485 + * No new writable mounts will be allowed
61486 + * Existing read-only mounts won't be able to be remounted read/write
61487 + * Write operations will be denied on all block devices
61488 + This option acts independently of grsec_lock: once it is set to 1,
61489 + it cannot be turned off. Therefore, please be mindful of the resulting
61490 + behavior if this option is enabled in an init script on a read-only
61491 + filesystem. This feature is mainly intended for secure embedded systems.
61492 +
61493 +config GRKERNSEC_DEVICE_SIDECHANNEL
61494 + bool "Eliminate stat/notify-based device sidechannels"
61495 + default y if GRKERNSEC_CONFIG_AUTO
61496 + help
61497 + If you say Y here, timing analyses on block or character
61498 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61499 + will be thwarted for unprivileged users. If a process without
61500 + CAP_MKNOD stats such a device, the last access and last modify times
61501 + will match the device's create time. No access or modify events
61502 + will be triggered through inotify/dnotify/fanotify for such devices.
61503 + This feature will prevent attacks that may at a minimum
61504 + allow an attacker to determine the administrator's password length.
61505 +
61506 +config GRKERNSEC_CHROOT
61507 + bool "Chroot jail restrictions"
61508 + default y if GRKERNSEC_CONFIG_AUTO
61509 + help
61510 + If you say Y here, you will be able to choose several options that will
61511 + make breaking out of a chrooted jail much more difficult. If you
61512 + encounter no software incompatibilities with the following options, it
61513 + is recommended that you enable each one.
61514 +
61515 +config GRKERNSEC_CHROOT_MOUNT
61516 + bool "Deny mounts"
61517 + default y if GRKERNSEC_CONFIG_AUTO
61518 + depends on GRKERNSEC_CHROOT
61519 + help
61520 + If you say Y here, processes inside a chroot will not be able to
61521 + mount or remount filesystems. If the sysctl option is enabled, a
61522 + sysctl option with name "chroot_deny_mount" is created.
61523 +
61524 +config GRKERNSEC_CHROOT_DOUBLE
61525 + bool "Deny double-chroots"
61526 + default y if GRKERNSEC_CONFIG_AUTO
61527 + depends on GRKERNSEC_CHROOT
61528 + help
61529 + If you say Y here, processes inside a chroot will not be able to chroot
61530 + again outside the chroot. This is a widely used method of breaking
61531 + out of a chroot jail and should not be allowed. If the sysctl
61532 + option is enabled, a sysctl option with name
61533 + "chroot_deny_chroot" is created.
61534 +
61535 +config GRKERNSEC_CHROOT_PIVOT
61536 + bool "Deny pivot_root in chroot"
61537 + default y if GRKERNSEC_CONFIG_AUTO
61538 + depends on GRKERNSEC_CHROOT
61539 + help
61540 + If you say Y here, processes inside a chroot will not be able to use
61541 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61542 + works similar to chroot in that it changes the root filesystem. This
61543 + function could be misused in a chrooted process to attempt to break out
61544 + of the chroot, and therefore should not be allowed. If the sysctl
61545 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61546 + created.
61547 +
61548 +config GRKERNSEC_CHROOT_CHDIR
61549 + bool "Enforce chdir(\"/\") on all chroots"
61550 + default y if GRKERNSEC_CONFIG_AUTO
61551 + depends on GRKERNSEC_CHROOT
61552 + help
61553 + If you say Y here, the current working directory of all newly-chrooted
61554 + applications will be set to the the root directory of the chroot.
61555 + The man page on chroot(2) states:
61556 + Note that this call does not change the current working
61557 + directory, so that `.' can be outside the tree rooted at
61558 + `/'. In particular, the super-user can escape from a
61559 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61560 +
61561 + It is recommended that you say Y here, since it's not known to break
61562 + any software. If the sysctl option is enabled, a sysctl option with
61563 + name "chroot_enforce_chdir" is created.
61564 +
61565 +config GRKERNSEC_CHROOT_CHMOD
61566 + bool "Deny (f)chmod +s"
61567 + default y if GRKERNSEC_CONFIG_AUTO
61568 + depends on GRKERNSEC_CHROOT
61569 + help
61570 + If you say Y here, processes inside a chroot will not be able to chmod
61571 + or fchmod files to make them have suid or sgid bits. This protects
61572 + against another published method of breaking a chroot. If the sysctl
61573 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61574 + created.
61575 +
61576 +config GRKERNSEC_CHROOT_FCHDIR
61577 + bool "Deny fchdir out of chroot"
61578 + default y if GRKERNSEC_CONFIG_AUTO
61579 + depends on GRKERNSEC_CHROOT
61580 + help
61581 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61582 + to a file descriptor of the chrooting process that points to a directory
61583 + outside the filesystem will be stopped. If the sysctl option
61584 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61585 +
61586 +config GRKERNSEC_CHROOT_MKNOD
61587 + bool "Deny mknod"
61588 + default y if GRKERNSEC_CONFIG_AUTO
61589 + depends on GRKERNSEC_CHROOT
61590 + help
61591 + If you say Y here, processes inside a chroot will not be allowed to
61592 + mknod. The problem with using mknod inside a chroot is that it
61593 + would allow an attacker to create a device entry that is the same
61594 + as one on the physical root of your system, which could range from
61595 + anything from the console device to a device for your harddrive (which
61596 + they could then use to wipe the drive or steal data). It is recommended
61597 + that you say Y here, unless you run into software incompatibilities.
61598 + If the sysctl option is enabled, a sysctl option with name
61599 + "chroot_deny_mknod" is created.
61600 +
61601 +config GRKERNSEC_CHROOT_SHMAT
61602 + bool "Deny shmat() out of chroot"
61603 + default y if GRKERNSEC_CONFIG_AUTO
61604 + depends on GRKERNSEC_CHROOT
61605 + help
61606 + If you say Y here, processes inside a chroot will not be able to attach
61607 + to shared memory segments that were created outside of the chroot jail.
61608 + It is recommended that you say Y here. If the sysctl option is enabled,
61609 + a sysctl option with name "chroot_deny_shmat" is created.
61610 +
61611 +config GRKERNSEC_CHROOT_UNIX
61612 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61613 + default y if GRKERNSEC_CONFIG_AUTO
61614 + depends on GRKERNSEC_CHROOT
61615 + help
61616 + If you say Y here, processes inside a chroot will not be able to
61617 + connect to abstract (meaning not belonging to a filesystem) Unix
61618 + domain sockets that were bound outside of a chroot. It is recommended
61619 + that you say Y here. If the sysctl option is enabled, a sysctl option
61620 + with name "chroot_deny_unix" is created.
61621 +
61622 +config GRKERNSEC_CHROOT_FINDTASK
61623 + bool "Protect outside processes"
61624 + default y if GRKERNSEC_CONFIG_AUTO
61625 + depends on GRKERNSEC_CHROOT
61626 + help
61627 + If you say Y here, processes inside a chroot will not be able to
61628 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61629 + getsid, or view any process outside of the chroot. If the sysctl
61630 + option is enabled, a sysctl option with name "chroot_findtask" is
61631 + created.
61632 +
61633 +config GRKERNSEC_CHROOT_NICE
61634 + bool "Restrict priority changes"
61635 + default y if GRKERNSEC_CONFIG_AUTO
61636 + depends on GRKERNSEC_CHROOT
61637 + help
61638 + If you say Y here, processes inside a chroot will not be able to raise
61639 + the priority of processes in the chroot, or alter the priority of
61640 + processes outside the chroot. This provides more security than simply
61641 + removing CAP_SYS_NICE from the process' capability set. If the
61642 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61643 + is created.
61644 +
61645 +config GRKERNSEC_CHROOT_SYSCTL
61646 + bool "Deny sysctl writes"
61647 + default y if GRKERNSEC_CONFIG_AUTO
61648 + depends on GRKERNSEC_CHROOT
61649 + help
61650 + If you say Y here, an attacker in a chroot will not be able to
61651 + write to sysctl entries, either by sysctl(2) or through a /proc
61652 + interface. It is strongly recommended that you say Y here. If the
61653 + sysctl option is enabled, a sysctl option with name
61654 + "chroot_deny_sysctl" is created.
61655 +
61656 +config GRKERNSEC_CHROOT_CAPS
61657 + bool "Capability restrictions"
61658 + default y if GRKERNSEC_CONFIG_AUTO
61659 + depends on GRKERNSEC_CHROOT
61660 + help
61661 + If you say Y here, the capabilities on all processes within a
61662 + chroot jail will be lowered to stop module insertion, raw i/o,
61663 + system and net admin tasks, rebooting the system, modifying immutable
61664 + files, modifying IPC owned by another, and changing the system time.
61665 + This is left an option because it can break some apps. Disable this
61666 + if your chrooted apps are having problems performing those kinds of
61667 + tasks. If the sysctl option is enabled, a sysctl option with
61668 + name "chroot_caps" is created.
61669 +
61670 +config GRKERNSEC_CHROOT_INITRD
61671 + bool "Exempt initrd tasks from restrictions"
61672 + default y if GRKERNSEC_CONFIG_AUTO
61673 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
61674 + help
61675 + If you say Y here, tasks started prior to init will be exempted from
61676 + grsecurity's chroot restrictions. This option is mainly meant to
61677 + resolve Plymouth's performing privileged operations unnecessarily
61678 + in a chroot.
61679 +
61680 +endmenu
61681 +menu "Kernel Auditing"
61682 +depends on GRKERNSEC
61683 +
61684 +config GRKERNSEC_AUDIT_GROUP
61685 + bool "Single group for auditing"
61686 + help
61687 + If you say Y here, the exec and chdir logging features will only operate
61688 + on a group you specify. This option is recommended if you only want to
61689 + watch certain users instead of having a large amount of logs from the
61690 + entire system. If the sysctl option is enabled, a sysctl option with
61691 + name "audit_group" is created.
61692 +
61693 +config GRKERNSEC_AUDIT_GID
61694 + int "GID for auditing"
61695 + depends on GRKERNSEC_AUDIT_GROUP
61696 + default 1007
61697 +
61698 +config GRKERNSEC_EXECLOG
61699 + bool "Exec logging"
61700 + help
61701 + If you say Y here, all execve() calls will be logged (since the
61702 + other exec*() calls are frontends to execve(), all execution
61703 + will be logged). Useful for shell-servers that like to keep track
61704 + of their users. If the sysctl option is enabled, a sysctl option with
61705 + name "exec_logging" is created.
61706 + WARNING: This option when enabled will produce a LOT of logs, especially
61707 + on an active system.
61708 +
61709 +config GRKERNSEC_RESLOG
61710 + bool "Resource logging"
61711 + default y if GRKERNSEC_CONFIG_AUTO
61712 + help
61713 + If you say Y here, all attempts to overstep resource limits will
61714 + be logged with the resource name, the requested size, and the current
61715 + limit. It is highly recommended that you say Y here. If the sysctl
61716 + option is enabled, a sysctl option with name "resource_logging" is
61717 + created. If the RBAC system is enabled, the sysctl value is ignored.
61718 +
61719 +config GRKERNSEC_CHROOT_EXECLOG
61720 + bool "Log execs within chroot"
61721 + help
61722 + If you say Y here, all executions inside a chroot jail will be logged
61723 + to syslog. This can cause a large amount of logs if certain
61724 + applications (eg. djb's daemontools) are installed on the system, and
61725 + is therefore left as an option. If the sysctl option is enabled, a
61726 + sysctl option with name "chroot_execlog" is created.
61727 +
61728 +config GRKERNSEC_AUDIT_PTRACE
61729 + bool "Ptrace logging"
61730 + help
61731 + If you say Y here, all attempts to attach to a process via ptrace
61732 + will be logged. If the sysctl option is enabled, a sysctl option
61733 + with name "audit_ptrace" is created.
61734 +
61735 +config GRKERNSEC_AUDIT_CHDIR
61736 + bool "Chdir logging"
61737 + help
61738 + If you say Y here, all chdir() calls will be logged. If the sysctl
61739 + option is enabled, a sysctl option with name "audit_chdir" is created.
61740 +
61741 +config GRKERNSEC_AUDIT_MOUNT
61742 + bool "(Un)Mount logging"
61743 + help
61744 + If you say Y here, all mounts and unmounts will be logged. If the
61745 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61746 + created.
61747 +
61748 +config GRKERNSEC_SIGNAL
61749 + bool "Signal logging"
61750 + default y if GRKERNSEC_CONFIG_AUTO
61751 + help
61752 + If you say Y here, certain important signals will be logged, such as
61753 + SIGSEGV, which will as a result inform you of when a error in a program
61754 + occurred, which in some cases could mean a possible exploit attempt.
61755 + If the sysctl option is enabled, a sysctl option with name
61756 + "signal_logging" is created.
61757 +
61758 +config GRKERNSEC_FORKFAIL
61759 + bool "Fork failure logging"
61760 + help
61761 + If you say Y here, all failed fork() attempts will be logged.
61762 + This could suggest a fork bomb, or someone attempting to overstep
61763 + their process limit. If the sysctl option is enabled, a sysctl option
61764 + with name "forkfail_logging" is created.
61765 +
61766 +config GRKERNSEC_TIME
61767 + bool "Time change logging"
61768 + default y if GRKERNSEC_CONFIG_AUTO
61769 + help
61770 + If you say Y here, any changes of the system clock will be logged.
61771 + If the sysctl option is enabled, a sysctl option with name
61772 + "timechange_logging" is created.
61773 +
61774 +config GRKERNSEC_PROC_IPADDR
61775 + bool "/proc/<pid>/ipaddr support"
61776 + default y if GRKERNSEC_CONFIG_AUTO
61777 + help
61778 + If you say Y here, a new entry will be added to each /proc/<pid>
61779 + directory that contains the IP address of the person using the task.
61780 + The IP is carried across local TCP and AF_UNIX stream sockets.
61781 + This information can be useful for IDS/IPSes to perform remote response
61782 + to a local attack. The entry is readable by only the owner of the
61783 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61784 + the RBAC system), and thus does not create privacy concerns.
61785 +
61786 +config GRKERNSEC_RWXMAP_LOG
61787 + bool 'Denied RWX mmap/mprotect logging'
61788 + default y if GRKERNSEC_CONFIG_AUTO
61789 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61790 + help
61791 + If you say Y here, calls to mmap() and mprotect() with explicit
61792 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61793 + denied by the PAX_MPROTECT feature. This feature will also
61794 + log other problematic scenarios that can occur when PAX_MPROTECT
61795 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61796 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61797 + is created.
61798 +
61799 +endmenu
61800 +
61801 +menu "Executable Protections"
61802 +depends on GRKERNSEC
61803 +
61804 +config GRKERNSEC_DMESG
61805 + bool "Dmesg(8) restriction"
61806 + default y if GRKERNSEC_CONFIG_AUTO
61807 + help
61808 + If you say Y here, non-root users will not be able to use dmesg(8)
61809 + to view the contents of the kernel's circular log buffer.
61810 + The kernel's log buffer often contains kernel addresses and other
61811 + identifying information useful to an attacker in fingerprinting a
61812 + system for a targeted exploit.
61813 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61814 + created.
61815 +
61816 +config GRKERNSEC_HARDEN_PTRACE
61817 + bool "Deter ptrace-based process snooping"
61818 + default y if GRKERNSEC_CONFIG_AUTO
61819 + help
61820 + If you say Y here, TTY sniffers and other malicious monitoring
61821 + programs implemented through ptrace will be defeated. If you
61822 + have been using the RBAC system, this option has already been
61823 + enabled for several years for all users, with the ability to make
61824 + fine-grained exceptions.
61825 +
61826 + This option only affects the ability of non-root users to ptrace
61827 + processes that are not a descendent of the ptracing process.
61828 + This means that strace ./binary and gdb ./binary will still work,
61829 + but attaching to arbitrary processes will not. If the sysctl
61830 + option is enabled, a sysctl option with name "harden_ptrace" is
61831 + created.
61832 +
61833 +config GRKERNSEC_PTRACE_READEXEC
61834 + bool "Require read access to ptrace sensitive binaries"
61835 + default y if GRKERNSEC_CONFIG_AUTO
61836 + help
61837 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61838 + binaries. This option is useful in environments that
61839 + remove the read bits (e.g. file mode 4711) from suid binaries to
61840 + prevent infoleaking of their contents. This option adds
61841 + consistency to the use of that file mode, as the binary could normally
61842 + be read out when run without privileges while ptracing.
61843 +
61844 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61845 + is created.
61846 +
61847 +config GRKERNSEC_SETXID
61848 + bool "Enforce consistent multithreaded privileges"
61849 + default y if GRKERNSEC_CONFIG_AUTO
61850 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61851 + help
61852 + If you say Y here, a change from a root uid to a non-root uid
61853 + in a multithreaded application will cause the resulting uids,
61854 + gids, supplementary groups, and capabilities in that thread
61855 + to be propagated to the other threads of the process. In most
61856 + cases this is unnecessary, as glibc will emulate this behavior
61857 + on behalf of the application. Other libcs do not act in the
61858 + same way, allowing the other threads of the process to continue
61859 + running with root privileges. If the sysctl option is enabled,
61860 + a sysctl option with name "consistent_setxid" is created.
61861 +
61862 +config GRKERNSEC_HARDEN_IPC
61863 + bool "Disallow access to world-accessible IPC objects"
61864 + default y if GRKERNSEC_CONFIG_AUTO
61865 + depends on SYSVIPC
61866 + help
61867 + If you say Y here, access to overly-permissive IPC (shared memory,
61868 + message queues, and semaphores) will be denied for processes whose
61869 + effective user or group would not grant them permission. It's a
61870 + common error to grant too much permission to these objects, with
61871 + impact ranging from denial of service and information leaking to
61872 + privilege escalation. This feature was developed in response to
61873 + research by Tim Brown:
61874 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
61875 + who found hundreds of such insecure usages. Processes with
61876 + CAP_IPC_OWNER are still permitted to access these IPC objects.
61877 + If the sysctl option is enabled, a sysctl option with name
61878 + "harden_ipc" is created.
61879 +
61880 +config GRKERNSEC_TPE
61881 + bool "Trusted Path Execution (TPE)"
61882 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61883 + help
61884 + If you say Y here, you will be able to choose a gid to add to the
61885 + supplementary groups of users you want to mark as "untrusted."
61886 + These users will not be able to execute any files that are not in
61887 + root-owned directories writable only by root. If the sysctl option
61888 + is enabled, a sysctl option with name "tpe" is created.
61889 +
61890 +config GRKERNSEC_TPE_ALL
61891 + bool "Partially restrict all non-root users"
61892 + depends on GRKERNSEC_TPE
61893 + help
61894 + If you say Y here, all non-root users will be covered under
61895 + a weaker TPE restriction. This is separate from, and in addition to,
61896 + the main TPE options that you have selected elsewhere. Thus, if a
61897 + "trusted" GID is chosen, this restriction applies to even that GID.
61898 + Under this restriction, all non-root users will only be allowed to
61899 + execute files in directories they own that are not group or
61900 + world-writable, or in directories owned by root and writable only by
61901 + root. If the sysctl option is enabled, a sysctl option with name
61902 + "tpe_restrict_all" is created.
61903 +
61904 +config GRKERNSEC_TPE_INVERT
61905 + bool "Invert GID option"
61906 + depends on GRKERNSEC_TPE
61907 + help
61908 + If you say Y here, the group you specify in the TPE configuration will
61909 + decide what group TPE restrictions will be *disabled* for. This
61910 + option is useful if you want TPE restrictions to be applied to most
61911 + users on the system. If the sysctl option is enabled, a sysctl option
61912 + with name "tpe_invert" is created. Unlike other sysctl options, this
61913 + entry will default to on for backward-compatibility.
61914 +
61915 +config GRKERNSEC_TPE_GID
61916 + int
61917 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61918 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61919 +
61920 +config GRKERNSEC_TPE_UNTRUSTED_GID
61921 + int "GID for TPE-untrusted users"
61922 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61923 + default 1005
61924 + help
61925 + Setting this GID determines what group TPE restrictions will be
61926 + *enabled* for. If the sysctl option is enabled, a sysctl option
61927 + with name "tpe_gid" is created.
61928 +
61929 +config GRKERNSEC_TPE_TRUSTED_GID
61930 + int "GID for TPE-trusted users"
61931 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61932 + default 1005
61933 + help
61934 + Setting this GID determines what group TPE restrictions will be
61935 + *disabled* for. If the sysctl option is enabled, a sysctl option
61936 + with name "tpe_gid" is created.
61937 +
61938 +endmenu
61939 +menu "Network Protections"
61940 +depends on GRKERNSEC
61941 +
61942 +config GRKERNSEC_RANDNET
61943 + bool "Larger entropy pools"
61944 + default y if GRKERNSEC_CONFIG_AUTO
61945 + help
61946 + If you say Y here, the entropy pools used for many features of Linux
61947 + and grsecurity will be doubled in size. Since several grsecurity
61948 + features use additional randomness, it is recommended that you say Y
61949 + here. Saying Y here has a similar effect as modifying
61950 + /proc/sys/kernel/random/poolsize.
61951 +
61952 +config GRKERNSEC_BLACKHOLE
61953 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61954 + default y if GRKERNSEC_CONFIG_AUTO
61955 + depends on NET
61956 + help
61957 + If you say Y here, neither TCP resets nor ICMP
61958 + destination-unreachable packets will be sent in response to packets
61959 + sent to ports for which no associated listening process exists.
61960 + This feature supports both IPV4 and IPV6 and exempts the
61961 + loopback interface from blackholing. Enabling this feature
61962 + makes a host more resilient to DoS attacks and reduces network
61963 + visibility against scanners.
61964 +
61965 + The blackhole feature as-implemented is equivalent to the FreeBSD
61966 + blackhole feature, as it prevents RST responses to all packets, not
61967 + just SYNs. Under most application behavior this causes no
61968 + problems, but applications (like haproxy) may not close certain
61969 + connections in a way that cleanly terminates them on the remote
61970 + end, leaving the remote host in LAST_ACK state. Because of this
61971 + side-effect and to prevent intentional LAST_ACK DoSes, this
61972 + feature also adds automatic mitigation against such attacks.
61973 + The mitigation drastically reduces the amount of time a socket
61974 + can spend in LAST_ACK state. If you're using haproxy and not
61975 + all servers it connects to have this option enabled, consider
61976 + disabling this feature on the haproxy host.
61977 +
61978 + If the sysctl option is enabled, two sysctl options with names
61979 + "ip_blackhole" and "lastack_retries" will be created.
61980 + While "ip_blackhole" takes the standard zero/non-zero on/off
61981 + toggle, "lastack_retries" uses the same kinds of values as
61982 + "tcp_retries1" and "tcp_retries2". The default value of 4
61983 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61984 + state.
61985 +
61986 +config GRKERNSEC_NO_SIMULT_CONNECT
61987 + bool "Disable TCP Simultaneous Connect"
61988 + default y if GRKERNSEC_CONFIG_AUTO
61989 + depends on NET
61990 + help
61991 + If you say Y here, a feature by Willy Tarreau will be enabled that
61992 + removes a weakness in Linux's strict implementation of TCP that
61993 + allows two clients to connect to each other without either entering
61994 + a listening state. The weakness allows an attacker to easily prevent
61995 + a client from connecting to a known server provided the source port
61996 + for the connection is guessed correctly.
61997 +
61998 + As the weakness could be used to prevent an antivirus or IPS from
61999 + fetching updates, or prevent an SSL gateway from fetching a CRL,
62000 + it should be eliminated by enabling this option. Though Linux is
62001 + one of few operating systems supporting simultaneous connect, it
62002 + has no legitimate use in practice and is rarely supported by firewalls.
62003 +
62004 +config GRKERNSEC_SOCKET
62005 + bool "Socket restrictions"
62006 + depends on NET
62007 + help
62008 + If you say Y here, you will be able to choose from several options.
62009 + If you assign a GID on your system and add it to the supplementary
62010 + groups of users you want to restrict socket access to, this patch
62011 + will perform up to three things, based on the option(s) you choose.
62012 +
62013 +config GRKERNSEC_SOCKET_ALL
62014 + bool "Deny any sockets to group"
62015 + depends on GRKERNSEC_SOCKET
62016 + help
62017 + If you say Y here, you will be able to choose a GID of whose users will
62018 + be unable to connect to other hosts from your machine or run server
62019 + applications from your machine. If the sysctl option is enabled, a
62020 + sysctl option with name "socket_all" is created.
62021 +
62022 +config GRKERNSEC_SOCKET_ALL_GID
62023 + int "GID to deny all sockets for"
62024 + depends on GRKERNSEC_SOCKET_ALL
62025 + default 1004
62026 + help
62027 + Here you can choose the GID to disable socket access for. Remember to
62028 + add the users you want socket access disabled for to the GID
62029 + specified here. If the sysctl option is enabled, a sysctl option
62030 + with name "socket_all_gid" is created.
62031 +
62032 +config GRKERNSEC_SOCKET_CLIENT
62033 + bool "Deny client sockets to group"
62034 + depends on GRKERNSEC_SOCKET
62035 + help
62036 + If you say Y here, you will be able to choose a GID of whose users will
62037 + be unable to connect to other hosts from your machine, but will be
62038 + able to run servers. If this option is enabled, all users in the group
62039 + you specify will have to use passive mode when initiating ftp transfers
62040 + from the shell on your machine. If the sysctl option is enabled, a
62041 + sysctl option with name "socket_client" is created.
62042 +
62043 +config GRKERNSEC_SOCKET_CLIENT_GID
62044 + int "GID to deny client sockets for"
62045 + depends on GRKERNSEC_SOCKET_CLIENT
62046 + default 1003
62047 + help
62048 + Here you can choose the GID to disable client socket access for.
62049 + Remember to add the users you want client socket access disabled for to
62050 + the GID specified here. If the sysctl option is enabled, a sysctl
62051 + option with name "socket_client_gid" is created.
62052 +
62053 +config GRKERNSEC_SOCKET_SERVER
62054 + bool "Deny server sockets to group"
62055 + depends on GRKERNSEC_SOCKET
62056 + help
62057 + If you say Y here, you will be able to choose a GID of whose users will
62058 + be unable to run server applications from your machine. If the sysctl
62059 + option is enabled, a sysctl option with name "socket_server" is created.
62060 +
62061 +config GRKERNSEC_SOCKET_SERVER_GID
62062 + int "GID to deny server sockets for"
62063 + depends on GRKERNSEC_SOCKET_SERVER
62064 + default 1002
62065 + help
62066 + Here you can choose the GID to disable server socket access for.
62067 + Remember to add the users you want server socket access disabled for to
62068 + the GID specified here. If the sysctl option is enabled, a sysctl
62069 + option with name "socket_server_gid" is created.
62070 +
62071 +endmenu
62072 +
62073 +menu "Physical Protections"
62074 +depends on GRKERNSEC
62075 +
62076 +config GRKERNSEC_DENYUSB
62077 + bool "Deny new USB connections after toggle"
62078 + default y if GRKERNSEC_CONFIG_AUTO
62079 + depends on SYSCTL && USB_SUPPORT
62080 + help
62081 + If you say Y here, a new sysctl option with name "deny_new_usb"
62082 + will be created. Setting its value to 1 will prevent any new
62083 + USB devices from being recognized by the OS. Any attempted USB
62084 + device insertion will be logged. This option is intended to be
62085 + used against custom USB devices designed to exploit vulnerabilities
62086 + in various USB device drivers.
62087 +
62088 + For greatest effectiveness, this sysctl should be set after any
62089 + relevant init scripts. This option is safe to enable in distros
62090 + as each user can choose whether or not to toggle the sysctl.
62091 +
62092 +config GRKERNSEC_DENYUSB_FORCE
62093 + bool "Reject all USB devices not connected at boot"
62094 + select USB
62095 + depends on GRKERNSEC_DENYUSB
62096 + help
62097 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62098 + that doesn't involve a sysctl entry. This option should only be
62099 + enabled if you're sure you want to deny all new USB connections
62100 + at runtime and don't want to modify init scripts. This should not
62101 + be enabled by distros. It forces the core USB code to be built
62102 + into the kernel image so that all devices connected at boot time
62103 + can be recognized and new USB device connections can be prevented
62104 + prior to init running.
62105 +
62106 +endmenu
62107 +
62108 +menu "Sysctl Support"
62109 +depends on GRKERNSEC && SYSCTL
62110 +
62111 +config GRKERNSEC_SYSCTL
62112 + bool "Sysctl support"
62113 + default y if GRKERNSEC_CONFIG_AUTO
62114 + help
62115 + If you say Y here, you will be able to change the options that
62116 + grsecurity runs with at bootup, without having to recompile your
62117 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62118 + to enable (1) or disable (0) various features. All the sysctl entries
62119 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62120 + All features enabled in the kernel configuration are disabled at boot
62121 + if you do not say Y to the "Turn on features by default" option.
62122 + All options should be set at startup, and the grsec_lock entry should
62123 + be set to a non-zero value after all the options are set.
62124 + *THIS IS EXTREMELY IMPORTANT*
62125 +
62126 +config GRKERNSEC_SYSCTL_DISTRO
62127 + bool "Extra sysctl support for distro makers (READ HELP)"
62128 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62129 + help
62130 + If you say Y here, additional sysctl options will be created
62131 + for features that affect processes running as root. Therefore,
62132 + it is critical when using this option that the grsec_lock entry be
62133 + enabled after boot. Only distros with prebuilt kernel packages
62134 + with this option enabled that can ensure grsec_lock is enabled
62135 + after boot should use this option.
62136 + *Failure to set grsec_lock after boot makes all grsec features
62137 + this option covers useless*
62138 +
62139 + Currently this option creates the following sysctl entries:
62140 + "Disable Privileged I/O": "disable_priv_io"
62141 +
62142 +config GRKERNSEC_SYSCTL_ON
62143 + bool "Turn on features by default"
62144 + default y if GRKERNSEC_CONFIG_AUTO
62145 + depends on GRKERNSEC_SYSCTL
62146 + help
62147 + If you say Y here, instead of having all features enabled in the
62148 + kernel configuration disabled at boot time, the features will be
62149 + enabled at boot time. It is recommended you say Y here unless
62150 + there is some reason you would want all sysctl-tunable features to
62151 + be disabled by default. As mentioned elsewhere, it is important
62152 + to enable the grsec_lock entry once you have finished modifying
62153 + the sysctl entries.
62154 +
62155 +endmenu
62156 +menu "Logging Options"
62157 +depends on GRKERNSEC
62158 +
62159 +config GRKERNSEC_FLOODTIME
62160 + int "Seconds in between log messages (minimum)"
62161 + default 10
62162 + help
62163 + This option allows you to enforce the number of seconds between
62164 + grsecurity log messages. The default should be suitable for most
62165 + people, however, if you choose to change it, choose a value small enough
62166 + to allow informative logs to be produced, but large enough to
62167 + prevent flooding.
62168 +
62169 +config GRKERNSEC_FLOODBURST
62170 + int "Number of messages in a burst (maximum)"
62171 + default 6
62172 + help
62173 + This option allows you to choose the maximum number of messages allowed
62174 + within the flood time interval you chose in a separate option. The
62175 + default should be suitable for most people, however if you find that
62176 + many of your logs are being interpreted as flooding, you may want to
62177 + raise this value.
62178 +
62179 +endmenu
62180 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62181 new file mode 100644
62182 index 0000000..85beb79
62183 --- /dev/null
62184 +++ b/grsecurity/Makefile
62185 @@ -0,0 +1,43 @@
62186 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62187 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62188 +# into an RBAC system
62189 +#
62190 +# All code in this directory and various hooks inserted throughout the kernel
62191 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62192 +# under the GPL v2 or higher
62193 +
62194 +KBUILD_CFLAGS += -Werror
62195 +
62196 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62197 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62198 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62199 + grsec_usb.o grsec_ipc.o
62200 +
62201 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62202 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62203 + gracl_learn.o grsec_log.o gracl_policy.o
62204 +ifdef CONFIG_COMPAT
62205 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62206 +endif
62207 +
62208 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62209 +
62210 +ifdef CONFIG_NET
62211 +obj-y += grsec_sock.o
62212 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62213 +endif
62214 +
62215 +ifndef CONFIG_GRKERNSEC
62216 +obj-y += grsec_disabled.o
62217 +endif
62218 +
62219 +ifdef CONFIG_GRKERNSEC_HIDESYM
62220 +extra-y := grsec_hidesym.o
62221 +$(obj)/grsec_hidesym.o:
62222 + @-chmod -f 500 /boot
62223 + @-chmod -f 500 /lib/modules
62224 + @-chmod -f 500 /lib64/modules
62225 + @-chmod -f 500 /lib32/modules
62226 + @-chmod -f 700 .
62227 + @echo ' grsec: protected kernel image paths'
62228 +endif
62229 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62230 new file mode 100644
62231 index 0000000..857c960
62232 --- /dev/null
62233 +++ b/grsecurity/gracl.c
62234 @@ -0,0 +1,2623 @@
62235 +#include <linux/kernel.h>
62236 +#include <linux/module.h>
62237 +#include <linux/sched.h>
62238 +#include <linux/mm.h>
62239 +#include <linux/file.h>
62240 +#include <linux/fs.h>
62241 +#include <linux/namei.h>
62242 +#include <linux/mount.h>
62243 +#include <linux/tty.h>
62244 +#include <linux/proc_fs.h>
62245 +#include <linux/lglock.h>
62246 +#include <linux/slab.h>
62247 +#include <linux/vmalloc.h>
62248 +#include <linux/types.h>
62249 +#include <linux/sysctl.h>
62250 +#include <linux/netdevice.h>
62251 +#include <linux/ptrace.h>
62252 +#include <linux/gracl.h>
62253 +#include <linux/gralloc.h>
62254 +#include <linux/security.h>
62255 +#include <linux/grinternal.h>
62256 +#include <linux/pid_namespace.h>
62257 +#include <linux/stop_machine.h>
62258 +#include <linux/fdtable.h>
62259 +#include <linux/percpu.h>
62260 +#include <linux/lglock.h>
62261 +#include <linux/hugetlb.h>
62262 +#include <linux/posix-timers.h>
62263 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62264 +#include <linux/magic.h>
62265 +#include <linux/pagemap.h>
62266 +#include "../fs/btrfs/async-thread.h"
62267 +#include "../fs/btrfs/ctree.h"
62268 +#include "../fs/btrfs/btrfs_inode.h"
62269 +#endif
62270 +#include "../fs/mount.h"
62271 +
62272 +#include <asm/uaccess.h>
62273 +#include <asm/errno.h>
62274 +#include <asm/mman.h>
62275 +
62276 +#define FOR_EACH_ROLE_START(role) \
62277 + role = running_polstate.role_list; \
62278 + while (role) {
62279 +
62280 +#define FOR_EACH_ROLE_END(role) \
62281 + role = role->prev; \
62282 + }
62283 +
62284 +extern struct lglock vfsmount_lock;
62285 +
62286 +extern struct path gr_real_root;
62287 +
62288 +static struct gr_policy_state running_polstate;
62289 +struct gr_policy_state *polstate = &running_polstate;
62290 +extern struct gr_alloc_state *current_alloc_state;
62291 +
62292 +extern char *gr_shared_page[4];
62293 +DEFINE_RWLOCK(gr_inode_lock);
62294 +
62295 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62296 +
62297 +#ifdef CONFIG_NET
62298 +extern struct vfsmount *sock_mnt;
62299 +#endif
62300 +
62301 +extern struct vfsmount *pipe_mnt;
62302 +extern struct vfsmount *shm_mnt;
62303 +
62304 +#ifdef CONFIG_HUGETLBFS
62305 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62306 +#endif
62307 +
62308 +extern u16 acl_sp_role_value;
62309 +extern struct acl_object_label *fakefs_obj_rw;
62310 +extern struct acl_object_label *fakefs_obj_rwx;
62311 +
62312 +int gr_acl_is_enabled(void)
62313 +{
62314 + return (gr_status & GR_READY);
62315 +}
62316 +
62317 +void gr_enable_rbac_system(void)
62318 +{
62319 + pax_open_kernel();
62320 + gr_status |= GR_READY;
62321 + pax_close_kernel();
62322 +}
62323 +
62324 +int gr_rbac_disable(void *unused)
62325 +{
62326 + pax_open_kernel();
62327 + gr_status &= ~GR_READY;
62328 + pax_close_kernel();
62329 +
62330 + return 0;
62331 +}
62332 +
62333 +static inline dev_t __get_dev(const struct dentry *dentry)
62334 +{
62335 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62336 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62337 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62338 + else
62339 +#endif
62340 + return dentry->d_sb->s_dev;
62341 +}
62342 +
62343 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62344 +{
62345 + return __get_dev(dentry);
62346 +}
62347 +
62348 +static char gr_task_roletype_to_char(struct task_struct *task)
62349 +{
62350 + switch (task->role->roletype &
62351 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62352 + GR_ROLE_SPECIAL)) {
62353 + case GR_ROLE_DEFAULT:
62354 + return 'D';
62355 + case GR_ROLE_USER:
62356 + return 'U';
62357 + case GR_ROLE_GROUP:
62358 + return 'G';
62359 + case GR_ROLE_SPECIAL:
62360 + return 'S';
62361 + }
62362 +
62363 + return 'X';
62364 +}
62365 +
62366 +char gr_roletype_to_char(void)
62367 +{
62368 + return gr_task_roletype_to_char(current);
62369 +}
62370 +
62371 +__inline__ int
62372 +gr_acl_tpe_check(void)
62373 +{
62374 + if (unlikely(!(gr_status & GR_READY)))
62375 + return 0;
62376 + if (current->role->roletype & GR_ROLE_TPE)
62377 + return 1;
62378 + else
62379 + return 0;
62380 +}
62381 +
62382 +int
62383 +gr_handle_rawio(const struct inode *inode)
62384 +{
62385 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62386 + if (inode && S_ISBLK(inode->i_mode) &&
62387 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62388 + !capable(CAP_SYS_RAWIO))
62389 + return 1;
62390 +#endif
62391 + return 0;
62392 +}
62393 +
62394 +int
62395 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62396 +{
62397 + if (likely(lena != lenb))
62398 + return 0;
62399 +
62400 + return !memcmp(a, b, lena);
62401 +}
62402 +
62403 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62404 +{
62405 + *buflen -= namelen;
62406 + if (*buflen < 0)
62407 + return -ENAMETOOLONG;
62408 + *buffer -= namelen;
62409 + memcpy(*buffer, str, namelen);
62410 + return 0;
62411 +}
62412 +
62413 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62414 +{
62415 + return prepend(buffer, buflen, name->name, name->len);
62416 +}
62417 +
62418 +static int prepend_path(const struct path *path, struct path *root,
62419 + char **buffer, int *buflen)
62420 +{
62421 + struct dentry *dentry = path->dentry;
62422 + struct vfsmount *vfsmnt = path->mnt;
62423 + struct mount *mnt = real_mount(vfsmnt);
62424 + bool slash = false;
62425 + int error = 0;
62426 +
62427 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62428 + struct dentry * parent;
62429 +
62430 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62431 + /* Global root? */
62432 + if (!mnt_has_parent(mnt)) {
62433 + goto out;
62434 + }
62435 + dentry = mnt->mnt_mountpoint;
62436 + mnt = mnt->mnt_parent;
62437 + vfsmnt = &mnt->mnt;
62438 + continue;
62439 + }
62440 + parent = dentry->d_parent;
62441 + prefetch(parent);
62442 + spin_lock(&dentry->d_lock);
62443 + error = prepend_name(buffer, buflen, &dentry->d_name);
62444 + spin_unlock(&dentry->d_lock);
62445 + if (!error)
62446 + error = prepend(buffer, buflen, "/", 1);
62447 + if (error)
62448 + break;
62449 +
62450 + slash = true;
62451 + dentry = parent;
62452 + }
62453 +
62454 +out:
62455 + if (!error && !slash)
62456 + error = prepend(buffer, buflen, "/", 1);
62457 +
62458 + return error;
62459 +}
62460 +
62461 +/* this must be called with vfsmount_lock and rename_lock held */
62462 +
62463 +static char *__our_d_path(const struct path *path, struct path *root,
62464 + char *buf, int buflen)
62465 +{
62466 + char *res = buf + buflen;
62467 + int error;
62468 +
62469 + prepend(&res, &buflen, "\0", 1);
62470 + error = prepend_path(path, root, &res, &buflen);
62471 + if (error)
62472 + return ERR_PTR(error);
62473 +
62474 + return res;
62475 +}
62476 +
62477 +static char *
62478 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62479 +{
62480 + char *retval;
62481 +
62482 + retval = __our_d_path(path, root, buf, buflen);
62483 + if (unlikely(IS_ERR(retval)))
62484 + retval = strcpy(buf, "<path too long>");
62485 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62486 + retval[1] = '\0';
62487 +
62488 + return retval;
62489 +}
62490 +
62491 +static char *
62492 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62493 + char *buf, int buflen)
62494 +{
62495 + struct path path;
62496 + char *res;
62497 +
62498 + path.dentry = (struct dentry *)dentry;
62499 + path.mnt = (struct vfsmount *)vfsmnt;
62500 +
62501 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
62502 + by the RBAC system */
62503 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
62504 +
62505 + return res;
62506 +}
62507 +
62508 +static char *
62509 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62510 + char *buf, int buflen)
62511 +{
62512 + char *res;
62513 + struct path path;
62514 + struct path root;
62515 + struct task_struct *reaper = init_pid_ns.child_reaper;
62516 +
62517 + path.dentry = (struct dentry *)dentry;
62518 + path.mnt = (struct vfsmount *)vfsmnt;
62519 +
62520 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
62521 + get_fs_root(reaper->fs, &root);
62522 +
62523 + br_read_lock(&vfsmount_lock);
62524 + write_seqlock(&rename_lock);
62525 + res = gen_full_path(&path, &root, buf, buflen);
62526 + write_sequnlock(&rename_lock);
62527 + br_read_unlock(&vfsmount_lock);
62528 +
62529 + path_put(&root);
62530 + return res;
62531 +}
62532 +
62533 +char *
62534 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62535 +{
62536 + char *ret;
62537 + br_read_lock(&vfsmount_lock);
62538 + write_seqlock(&rename_lock);
62539 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62540 + PAGE_SIZE);
62541 + write_sequnlock(&rename_lock);
62542 + br_read_unlock(&vfsmount_lock);
62543 + return ret;
62544 +}
62545 +
62546 +static char *
62547 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62548 +{
62549 + char *ret;
62550 + char *buf;
62551 + int buflen;
62552 +
62553 + br_read_lock(&vfsmount_lock);
62554 + write_seqlock(&rename_lock);
62555 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62556 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62557 + buflen = (int)(ret - buf);
62558 + if (buflen >= 5)
62559 + prepend(&ret, &buflen, "/proc", 5);
62560 + else
62561 + ret = strcpy(buf, "<path too long>");
62562 + write_sequnlock(&rename_lock);
62563 + br_read_unlock(&vfsmount_lock);
62564 + return ret;
62565 +}
62566 +
62567 +char *
62568 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62569 +{
62570 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62571 + PAGE_SIZE);
62572 +}
62573 +
62574 +char *
62575 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62576 +{
62577 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62578 + PAGE_SIZE);
62579 +}
62580 +
62581 +char *
62582 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62583 +{
62584 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62585 + PAGE_SIZE);
62586 +}
62587 +
62588 +char *
62589 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62590 +{
62591 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62592 + PAGE_SIZE);
62593 +}
62594 +
62595 +char *
62596 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62597 +{
62598 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62599 + PAGE_SIZE);
62600 +}
62601 +
62602 +__inline__ __u32
62603 +to_gr_audit(const __u32 reqmode)
62604 +{
62605 + /* masks off auditable permission flags, then shifts them to create
62606 + auditing flags, and adds the special case of append auditing if
62607 + we're requesting write */
62608 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62609 +}
62610 +
62611 +struct acl_role_label *
62612 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
62613 + const gid_t gid)
62614 +{
62615 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
62616 + struct acl_role_label *match;
62617 + struct role_allowed_ip *ipp;
62618 + unsigned int x;
62619 + u32 curr_ip = task->signal->saved_ip;
62620 +
62621 + match = state->acl_role_set.r_hash[index];
62622 +
62623 + while (match) {
62624 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62625 + for (x = 0; x < match->domain_child_num; x++) {
62626 + if (match->domain_children[x] == uid)
62627 + goto found;
62628 + }
62629 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62630 + break;
62631 + match = match->next;
62632 + }
62633 +found:
62634 + if (match == NULL) {
62635 + try_group:
62636 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
62637 + match = state->acl_role_set.r_hash[index];
62638 +
62639 + while (match) {
62640 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62641 + for (x = 0; x < match->domain_child_num; x++) {
62642 + if (match->domain_children[x] == gid)
62643 + goto found2;
62644 + }
62645 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62646 + break;
62647 + match = match->next;
62648 + }
62649 +found2:
62650 + if (match == NULL)
62651 + match = state->default_role;
62652 + if (match->allowed_ips == NULL)
62653 + return match;
62654 + else {
62655 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62656 + if (likely
62657 + ((ntohl(curr_ip) & ipp->netmask) ==
62658 + (ntohl(ipp->addr) & ipp->netmask)))
62659 + return match;
62660 + }
62661 + match = state->default_role;
62662 + }
62663 + } else if (match->allowed_ips == NULL) {
62664 + return match;
62665 + } else {
62666 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62667 + if (likely
62668 + ((ntohl(curr_ip) & ipp->netmask) ==
62669 + (ntohl(ipp->addr) & ipp->netmask)))
62670 + return match;
62671 + }
62672 + goto try_group;
62673 + }
62674 +
62675 + return match;
62676 +}
62677 +
62678 +static struct acl_role_label *
62679 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62680 + const gid_t gid)
62681 +{
62682 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
62683 +}
62684 +
62685 +struct acl_subject_label *
62686 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62687 + const struct acl_role_label *role)
62688 +{
62689 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62690 + struct acl_subject_label *match;
62691 +
62692 + match = role->subj_hash[index];
62693 +
62694 + while (match && (match->inode != ino || match->device != dev ||
62695 + (match->mode & GR_DELETED))) {
62696 + match = match->next;
62697 + }
62698 +
62699 + if (match && !(match->mode & GR_DELETED))
62700 + return match;
62701 + else
62702 + return NULL;
62703 +}
62704 +
62705 +struct acl_subject_label *
62706 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62707 + const struct acl_role_label *role)
62708 +{
62709 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62710 + struct acl_subject_label *match;
62711 +
62712 + match = role->subj_hash[index];
62713 +
62714 + while (match && (match->inode != ino || match->device != dev ||
62715 + !(match->mode & GR_DELETED))) {
62716 + match = match->next;
62717 + }
62718 +
62719 + if (match && (match->mode & GR_DELETED))
62720 + return match;
62721 + else
62722 + return NULL;
62723 +}
62724 +
62725 +static struct acl_object_label *
62726 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62727 + const struct acl_subject_label *subj)
62728 +{
62729 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62730 + struct acl_object_label *match;
62731 +
62732 + match = subj->obj_hash[index];
62733 +
62734 + while (match && (match->inode != ino || match->device != dev ||
62735 + (match->mode & GR_DELETED))) {
62736 + match = match->next;
62737 + }
62738 +
62739 + if (match && !(match->mode & GR_DELETED))
62740 + return match;
62741 + else
62742 + return NULL;
62743 +}
62744 +
62745 +static struct acl_object_label *
62746 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62747 + const struct acl_subject_label *subj)
62748 +{
62749 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62750 + struct acl_object_label *match;
62751 +
62752 + match = subj->obj_hash[index];
62753 +
62754 + while (match && (match->inode != ino || match->device != dev ||
62755 + !(match->mode & GR_DELETED))) {
62756 + match = match->next;
62757 + }
62758 +
62759 + if (match && (match->mode & GR_DELETED))
62760 + return match;
62761 +
62762 + match = subj->obj_hash[index];
62763 +
62764 + while (match && (match->inode != ino || match->device != dev ||
62765 + (match->mode & GR_DELETED))) {
62766 + match = match->next;
62767 + }
62768 +
62769 + if (match && !(match->mode & GR_DELETED))
62770 + return match;
62771 + else
62772 + return NULL;
62773 +}
62774 +
62775 +struct name_entry *
62776 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
62777 +{
62778 + unsigned int len = strlen(name);
62779 + unsigned int key = full_name_hash(name, len);
62780 + unsigned int index = key % state->name_set.n_size;
62781 + struct name_entry *match;
62782 +
62783 + match = state->name_set.n_hash[index];
62784 +
62785 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62786 + match = match->next;
62787 +
62788 + return match;
62789 +}
62790 +
62791 +static struct name_entry *
62792 +lookup_name_entry(const char *name)
62793 +{
62794 + return __lookup_name_entry(&running_polstate, name);
62795 +}
62796 +
62797 +static struct name_entry *
62798 +lookup_name_entry_create(const char *name)
62799 +{
62800 + unsigned int len = strlen(name);
62801 + unsigned int key = full_name_hash(name, len);
62802 + unsigned int index = key % running_polstate.name_set.n_size;
62803 + struct name_entry *match;
62804 +
62805 + match = running_polstate.name_set.n_hash[index];
62806 +
62807 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62808 + !match->deleted))
62809 + match = match->next;
62810 +
62811 + if (match && match->deleted)
62812 + return match;
62813 +
62814 + match = running_polstate.name_set.n_hash[index];
62815 +
62816 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62817 + match->deleted))
62818 + match = match->next;
62819 +
62820 + if (match && !match->deleted)
62821 + return match;
62822 + else
62823 + return NULL;
62824 +}
62825 +
62826 +static struct inodev_entry *
62827 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62828 +{
62829 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
62830 + struct inodev_entry *match;
62831 +
62832 + match = running_polstate.inodev_set.i_hash[index];
62833 +
62834 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
62835 + match = match->next;
62836 +
62837 + return match;
62838 +}
62839 +
62840 +void
62841 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
62842 +{
62843 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
62844 + state->inodev_set.i_size);
62845 + struct inodev_entry **curr;
62846 +
62847 + entry->prev = NULL;
62848 +
62849 + curr = &state->inodev_set.i_hash[index];
62850 + if (*curr != NULL)
62851 + (*curr)->prev = entry;
62852 +
62853 + entry->next = *curr;
62854 + *curr = entry;
62855 +
62856 + return;
62857 +}
62858 +
62859 +static void
62860 +insert_inodev_entry(struct inodev_entry *entry)
62861 +{
62862 + __insert_inodev_entry(&running_polstate, entry);
62863 +}
62864 +
62865 +void
62866 +insert_acl_obj_label(struct acl_object_label *obj,
62867 + struct acl_subject_label *subj)
62868 +{
62869 + unsigned int index =
62870 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
62871 + struct acl_object_label **curr;
62872 +
62873 + obj->prev = NULL;
62874 +
62875 + curr = &subj->obj_hash[index];
62876 + if (*curr != NULL)
62877 + (*curr)->prev = obj;
62878 +
62879 + obj->next = *curr;
62880 + *curr = obj;
62881 +
62882 + return;
62883 +}
62884 +
62885 +void
62886 +insert_acl_subj_label(struct acl_subject_label *obj,
62887 + struct acl_role_label *role)
62888 +{
62889 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
62890 + struct acl_subject_label **curr;
62891 +
62892 + obj->prev = NULL;
62893 +
62894 + curr = &role->subj_hash[index];
62895 + if (*curr != NULL)
62896 + (*curr)->prev = obj;
62897 +
62898 + obj->next = *curr;
62899 + *curr = obj;
62900 +
62901 + return;
62902 +}
62903 +
62904 +/* derived from glibc fnmatch() 0: match, 1: no match*/
62905 +
62906 +static int
62907 +glob_match(const char *p, const char *n)
62908 +{
62909 + char c;
62910 +
62911 + while ((c = *p++) != '\0') {
62912 + switch (c) {
62913 + case '?':
62914 + if (*n == '\0')
62915 + return 1;
62916 + else if (*n == '/')
62917 + return 1;
62918 + break;
62919 + case '\\':
62920 + if (*n != c)
62921 + return 1;
62922 + break;
62923 + case '*':
62924 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
62925 + if (*n == '/')
62926 + return 1;
62927 + else if (c == '?') {
62928 + if (*n == '\0')
62929 + return 1;
62930 + else
62931 + ++n;
62932 + }
62933 + }
62934 + if (c == '\0') {
62935 + return 0;
62936 + } else {
62937 + const char *endp;
62938 +
62939 + if ((endp = strchr(n, '/')) == NULL)
62940 + endp = n + strlen(n);
62941 +
62942 + if (c == '[') {
62943 + for (--p; n < endp; ++n)
62944 + if (!glob_match(p, n))
62945 + return 0;
62946 + } else if (c == '/') {
62947 + while (*n != '\0' && *n != '/')
62948 + ++n;
62949 + if (*n == '/' && !glob_match(p, n + 1))
62950 + return 0;
62951 + } else {
62952 + for (--p; n < endp; ++n)
62953 + if (*n == c && !glob_match(p, n))
62954 + return 0;
62955 + }
62956 +
62957 + return 1;
62958 + }
62959 + case '[':
62960 + {
62961 + int not;
62962 + char cold;
62963 +
62964 + if (*n == '\0' || *n == '/')
62965 + return 1;
62966 +
62967 + not = (*p == '!' || *p == '^');
62968 + if (not)
62969 + ++p;
62970 +
62971 + c = *p++;
62972 + for (;;) {
62973 + unsigned char fn = (unsigned char)*n;
62974 +
62975 + if (c == '\0')
62976 + return 1;
62977 + else {
62978 + if (c == fn)
62979 + goto matched;
62980 + cold = c;
62981 + c = *p++;
62982 +
62983 + if (c == '-' && *p != ']') {
62984 + unsigned char cend = *p++;
62985 +
62986 + if (cend == '\0')
62987 + return 1;
62988 +
62989 + if (cold <= fn && fn <= cend)
62990 + goto matched;
62991 +
62992 + c = *p++;
62993 + }
62994 + }
62995 +
62996 + if (c == ']')
62997 + break;
62998 + }
62999 + if (!not)
63000 + return 1;
63001 + break;
63002 + matched:
63003 + while (c != ']') {
63004 + if (c == '\0')
63005 + return 1;
63006 +
63007 + c = *p++;
63008 + }
63009 + if (not)
63010 + return 1;
63011 + }
63012 + break;
63013 + default:
63014 + if (c != *n)
63015 + return 1;
63016 + }
63017 +
63018 + ++n;
63019 + }
63020 +
63021 + if (*n == '\0')
63022 + return 0;
63023 +
63024 + if (*n == '/')
63025 + return 0;
63026 +
63027 + return 1;
63028 +}
63029 +
63030 +static struct acl_object_label *
63031 +chk_glob_label(struct acl_object_label *globbed,
63032 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
63033 +{
63034 + struct acl_object_label *tmp;
63035 +
63036 + if (*path == NULL)
63037 + *path = gr_to_filename_nolock(dentry, mnt);
63038 +
63039 + tmp = globbed;
63040 +
63041 + while (tmp) {
63042 + if (!glob_match(tmp->filename, *path))
63043 + return tmp;
63044 + tmp = tmp->next;
63045 + }
63046 +
63047 + return NULL;
63048 +}
63049 +
63050 +static struct acl_object_label *
63051 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63052 + const ino_t curr_ino, const dev_t curr_dev,
63053 + const struct acl_subject_label *subj, char **path, const int checkglob)
63054 +{
63055 + struct acl_subject_label *tmpsubj;
63056 + struct acl_object_label *retval;
63057 + struct acl_object_label *retval2;
63058 +
63059 + tmpsubj = (struct acl_subject_label *) subj;
63060 + read_lock(&gr_inode_lock);
63061 + do {
63062 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
63063 + if (retval) {
63064 + if (checkglob && retval->globbed) {
63065 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
63066 + if (retval2)
63067 + retval = retval2;
63068 + }
63069 + break;
63070 + }
63071 + } while ((tmpsubj = tmpsubj->parent_subject));
63072 + read_unlock(&gr_inode_lock);
63073 +
63074 + return retval;
63075 +}
63076 +
63077 +static __inline__ struct acl_object_label *
63078 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63079 + struct dentry *curr_dentry,
63080 + const struct acl_subject_label *subj, char **path, const int checkglob)
63081 +{
63082 + int newglob = checkglob;
63083 + ino_t inode;
63084 + dev_t device;
63085 +
63086 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
63087 + as we don't want a / * rule to match instead of the / object
63088 + don't do this for create lookups that call this function though, since they're looking up
63089 + on the parent and thus need globbing checks on all paths
63090 + */
63091 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
63092 + newglob = GR_NO_GLOB;
63093 +
63094 + spin_lock(&curr_dentry->d_lock);
63095 + inode = curr_dentry->d_inode->i_ino;
63096 + device = __get_dev(curr_dentry);
63097 + spin_unlock(&curr_dentry->d_lock);
63098 +
63099 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
63100 +}
63101 +
63102 +#ifdef CONFIG_HUGETLBFS
63103 +static inline bool
63104 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
63105 +{
63106 + int i;
63107 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
63108 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
63109 + return true;
63110 + }
63111 +
63112 + return false;
63113 +}
63114 +#endif
63115 +
63116 +static struct acl_object_label *
63117 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63118 + const struct acl_subject_label *subj, char *path, const int checkglob)
63119 +{
63120 + struct dentry *dentry = (struct dentry *) l_dentry;
63121 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63122 + struct mount *real_mnt = real_mount(mnt);
63123 + struct acl_object_label *retval;
63124 + struct dentry *parent;
63125 +
63126 + br_read_lock(&vfsmount_lock);
63127 + write_seqlock(&rename_lock);
63128 +
63129 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
63130 +#ifdef CONFIG_NET
63131 + mnt == sock_mnt ||
63132 +#endif
63133 +#ifdef CONFIG_HUGETLBFS
63134 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
63135 +#endif
63136 + /* ignore Eric Biederman */
63137 + IS_PRIVATE(l_dentry->d_inode))) {
63138 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
63139 + goto out;
63140 + }
63141 +
63142 + for (;;) {
63143 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63144 + break;
63145 +
63146 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63147 + if (!mnt_has_parent(real_mnt))
63148 + break;
63149 +
63150 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63151 + if (retval != NULL)
63152 + goto out;
63153 +
63154 + dentry = real_mnt->mnt_mountpoint;
63155 + real_mnt = real_mnt->mnt_parent;
63156 + mnt = &real_mnt->mnt;
63157 + continue;
63158 + }
63159 +
63160 + parent = dentry->d_parent;
63161 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63162 + if (retval != NULL)
63163 + goto out;
63164 +
63165 + dentry = parent;
63166 + }
63167 +
63168 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63169 +
63170 + /* gr_real_root is pinned so we don't have to hold a reference */
63171 + if (retval == NULL)
63172 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
63173 +out:
63174 + write_sequnlock(&rename_lock);
63175 + br_read_unlock(&vfsmount_lock);
63176 +
63177 + BUG_ON(retval == NULL);
63178 +
63179 + return retval;
63180 +}
63181 +
63182 +static __inline__ struct acl_object_label *
63183 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63184 + const struct acl_subject_label *subj)
63185 +{
63186 + char *path = NULL;
63187 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
63188 +}
63189 +
63190 +static __inline__ struct acl_object_label *
63191 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63192 + const struct acl_subject_label *subj)
63193 +{
63194 + char *path = NULL;
63195 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
63196 +}
63197 +
63198 +static __inline__ struct acl_object_label *
63199 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63200 + const struct acl_subject_label *subj, char *path)
63201 +{
63202 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
63203 +}
63204 +
63205 +struct acl_subject_label *
63206 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63207 + const struct acl_role_label *role)
63208 +{
63209 + struct dentry *dentry = (struct dentry *) l_dentry;
63210 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63211 + struct mount *real_mnt = real_mount(mnt);
63212 + struct acl_subject_label *retval;
63213 + struct dentry *parent;
63214 +
63215 + br_read_lock(&vfsmount_lock);
63216 + write_seqlock(&rename_lock);
63217 +
63218 + for (;;) {
63219 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63220 + break;
63221 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63222 + if (!mnt_has_parent(real_mnt))
63223 + break;
63224 +
63225 + spin_lock(&dentry->d_lock);
63226 + read_lock(&gr_inode_lock);
63227 + retval =
63228 + lookup_acl_subj_label(dentry->d_inode->i_ino,
63229 + __get_dev(dentry), role);
63230 + read_unlock(&gr_inode_lock);
63231 + spin_unlock(&dentry->d_lock);
63232 + if (retval != NULL)
63233 + goto out;
63234 +
63235 + dentry = real_mnt->mnt_mountpoint;
63236 + real_mnt = real_mnt->mnt_parent;
63237 + mnt = &real_mnt->mnt;
63238 + continue;
63239 + }
63240 +
63241 + spin_lock(&dentry->d_lock);
63242 + read_lock(&gr_inode_lock);
63243 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63244 + __get_dev(dentry), role);
63245 + read_unlock(&gr_inode_lock);
63246 + parent = dentry->d_parent;
63247 + spin_unlock(&dentry->d_lock);
63248 +
63249 + if (retval != NULL)
63250 + goto out;
63251 +
63252 + dentry = parent;
63253 + }
63254 +
63255 + spin_lock(&dentry->d_lock);
63256 + read_lock(&gr_inode_lock);
63257 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63258 + __get_dev(dentry), role);
63259 + read_unlock(&gr_inode_lock);
63260 + spin_unlock(&dentry->d_lock);
63261 +
63262 + if (unlikely(retval == NULL)) {
63263 + /* gr_real_root is pinned, we don't need to hold a reference */
63264 + read_lock(&gr_inode_lock);
63265 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
63266 + __get_dev(gr_real_root.dentry), role);
63267 + read_unlock(&gr_inode_lock);
63268 + }
63269 +out:
63270 + write_sequnlock(&rename_lock);
63271 + br_read_unlock(&vfsmount_lock);
63272 +
63273 + BUG_ON(retval == NULL);
63274 +
63275 + return retval;
63276 +}
63277 +
63278 +void
63279 +assign_special_role(const char *rolename)
63280 +{
63281 + struct acl_object_label *obj;
63282 + struct acl_role_label *r;
63283 + struct acl_role_label *assigned = NULL;
63284 + struct task_struct *tsk;
63285 + struct file *filp;
63286 +
63287 + FOR_EACH_ROLE_START(r)
63288 + if (!strcmp(rolename, r->rolename) &&
63289 + (r->roletype & GR_ROLE_SPECIAL)) {
63290 + assigned = r;
63291 + break;
63292 + }
63293 + FOR_EACH_ROLE_END(r)
63294 +
63295 + if (!assigned)
63296 + return;
63297 +
63298 + read_lock(&tasklist_lock);
63299 + read_lock(&grsec_exec_file_lock);
63300 +
63301 + tsk = current->real_parent;
63302 + if (tsk == NULL)
63303 + goto out_unlock;
63304 +
63305 + filp = tsk->exec_file;
63306 + if (filp == NULL)
63307 + goto out_unlock;
63308 +
63309 + tsk->is_writable = 0;
63310 + tsk->inherited = 0;
63311 +
63312 + tsk->acl_sp_role = 1;
63313 + tsk->acl_role_id = ++acl_sp_role_value;
63314 + tsk->role = assigned;
63315 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
63316 +
63317 + /* ignore additional mmap checks for processes that are writable
63318 + by the default ACL */
63319 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
63320 + if (unlikely(obj->mode & GR_WRITE))
63321 + tsk->is_writable = 1;
63322 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
63323 + if (unlikely(obj->mode & GR_WRITE))
63324 + tsk->is_writable = 1;
63325 +
63326 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63327 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
63328 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
63329 +#endif
63330 +
63331 +out_unlock:
63332 + read_unlock(&grsec_exec_file_lock);
63333 + read_unlock(&tasklist_lock);
63334 + return;
63335 +}
63336 +
63337 +
63338 +static void
63339 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
63340 +{
63341 + struct task_struct *task = current;
63342 + const struct cred *cred = current_cred();
63343 +
63344 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
63345 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63346 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63347 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
63348 +
63349 + return;
63350 +}
63351 +
63352 +static void
63353 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
63354 +{
63355 + struct task_struct *task = current;
63356 + const struct cred *cred = current_cred();
63357 +
63358 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63359 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63360 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63361 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
63362 +
63363 + return;
63364 +}
63365 +
63366 +static void
63367 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
63368 +{
63369 + struct task_struct *task = current;
63370 + const struct cred *cred = current_cred();
63371 +
63372 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63373 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63374 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63375 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
63376 +
63377 + return;
63378 +}
63379 +
63380 +static void
63381 +gr_set_proc_res(struct task_struct *task)
63382 +{
63383 + struct acl_subject_label *proc;
63384 + unsigned short i;
63385 +
63386 + proc = task->acl;
63387 +
63388 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
63389 + return;
63390 +
63391 + for (i = 0; i < RLIM_NLIMITS; i++) {
63392 + if (!(proc->resmask & (1U << i)))
63393 + continue;
63394 +
63395 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
63396 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
63397 +
63398 + if (i == RLIMIT_CPU)
63399 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
63400 + }
63401 +
63402 + return;
63403 +}
63404 +
63405 +/* both of the below must be called with
63406 + rcu_read_lock();
63407 + read_lock(&tasklist_lock);
63408 + read_lock(&grsec_exec_file_lock);
63409 +*/
63410 +
63411 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
63412 +{
63413 + struct acl_object_label *obj;
63414 + struct file *filp;
63415 +
63416 + filp = task->exec_file;
63417 +
63418 + task->acl = subj;
63419 + task->is_writable = 0;
63420 + /* ignore additional mmap checks for processes that are writable
63421 + by the default ACL */
63422 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
63423 + if (unlikely(obj->mode & GR_WRITE))
63424 + task->is_writable = 1;
63425 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
63426 + if (unlikely(obj->mode & GR_WRITE))
63427 + task->is_writable = 1;
63428 +
63429 + gr_set_proc_res(task);
63430 +
63431 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63432 + 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);
63433 +#endif
63434 +}
63435 +
63436 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
63437 +{
63438 + __gr_apply_subject_to_task(&running_polstate, task, subj);
63439 +}
63440 +
63441 +__u32
63442 +gr_search_file(const struct dentry * dentry, const __u32 mode,
63443 + const struct vfsmount * mnt)
63444 +{
63445 + __u32 retval = mode;
63446 + struct acl_subject_label *curracl;
63447 + struct acl_object_label *currobj;
63448 +
63449 + if (unlikely(!(gr_status & GR_READY)))
63450 + return (mode & ~GR_AUDITS);
63451 +
63452 + curracl = current->acl;
63453 +
63454 + currobj = chk_obj_label(dentry, mnt, curracl);
63455 + retval = currobj->mode & mode;
63456 +
63457 + /* if we're opening a specified transfer file for writing
63458 + (e.g. /dev/initctl), then transfer our role to init
63459 + */
63460 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
63461 + current->role->roletype & GR_ROLE_PERSIST)) {
63462 + struct task_struct *task = init_pid_ns.child_reaper;
63463 +
63464 + if (task->role != current->role) {
63465 + task->acl_sp_role = 0;
63466 + task->acl_role_id = current->acl_role_id;
63467 + task->role = current->role;
63468 + rcu_read_lock();
63469 + read_lock(&grsec_exec_file_lock);
63470 + gr_apply_subject_to_task(task, NULL);
63471 + read_unlock(&grsec_exec_file_lock);
63472 + rcu_read_unlock();
63473 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
63474 + }
63475 + }
63476 +
63477 + if (unlikely
63478 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
63479 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
63480 + __u32 new_mode = mode;
63481 +
63482 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
63483 +
63484 + retval = new_mode;
63485 +
63486 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
63487 + new_mode |= GR_INHERIT;
63488 +
63489 + if (!(mode & GR_NOLEARN))
63490 + gr_log_learn(dentry, mnt, new_mode);
63491 + }
63492 +
63493 + return retval;
63494 +}
63495 +
63496 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
63497 + const struct dentry *parent,
63498 + const struct vfsmount *mnt)
63499 +{
63500 + struct name_entry *match;
63501 + struct acl_object_label *matchpo;
63502 + struct acl_subject_label *curracl;
63503 + char *path;
63504 +
63505 + if (unlikely(!(gr_status & GR_READY)))
63506 + return NULL;
63507 +
63508 + preempt_disable();
63509 + path = gr_to_filename_rbac(new_dentry, mnt);
63510 + match = lookup_name_entry_create(path);
63511 +
63512 + curracl = current->acl;
63513 +
63514 + if (match) {
63515 + read_lock(&gr_inode_lock);
63516 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
63517 + read_unlock(&gr_inode_lock);
63518 +
63519 + if (matchpo) {
63520 + preempt_enable();
63521 + return matchpo;
63522 + }
63523 + }
63524 +
63525 + // lookup parent
63526 +
63527 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
63528 +
63529 + preempt_enable();
63530 + return matchpo;
63531 +}
63532 +
63533 +__u32
63534 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
63535 + const struct vfsmount * mnt, const __u32 mode)
63536 +{
63537 + struct acl_object_label *matchpo;
63538 + __u32 retval;
63539 +
63540 + if (unlikely(!(gr_status & GR_READY)))
63541 + return (mode & ~GR_AUDITS);
63542 +
63543 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
63544 +
63545 + retval = matchpo->mode & mode;
63546 +
63547 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
63548 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
63549 + __u32 new_mode = mode;
63550 +
63551 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
63552 +
63553 + gr_log_learn(new_dentry, mnt, new_mode);
63554 + return new_mode;
63555 + }
63556 +
63557 + return retval;
63558 +}
63559 +
63560 +__u32
63561 +gr_check_link(const struct dentry * new_dentry,
63562 + const struct dentry * parent_dentry,
63563 + const struct vfsmount * parent_mnt,
63564 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
63565 +{
63566 + struct acl_object_label *obj;
63567 + __u32 oldmode, newmode;
63568 + __u32 needmode;
63569 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
63570 + GR_DELETE | GR_INHERIT;
63571 +
63572 + if (unlikely(!(gr_status & GR_READY)))
63573 + return (GR_CREATE | GR_LINK);
63574 +
63575 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
63576 + oldmode = obj->mode;
63577 +
63578 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
63579 + newmode = obj->mode;
63580 +
63581 + needmode = newmode & checkmodes;
63582 +
63583 + // old name for hardlink must have at least the permissions of the new name
63584 + if ((oldmode & needmode) != needmode)
63585 + goto bad;
63586 +
63587 + // if old name had restrictions/auditing, make sure the new name does as well
63588 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
63589 +
63590 + // don't allow hardlinking of suid/sgid/fcapped files without permission
63591 + if (is_privileged_binary(old_dentry))
63592 + needmode |= GR_SETID;
63593 +
63594 + if ((newmode & needmode) != needmode)
63595 + goto bad;
63596 +
63597 + // enforce minimum permissions
63598 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
63599 + return newmode;
63600 +bad:
63601 + needmode = oldmode;
63602 + if (is_privileged_binary(old_dentry))
63603 + needmode |= GR_SETID;
63604 +
63605 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
63606 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
63607 + return (GR_CREATE | GR_LINK);
63608 + } else if (newmode & GR_SUPPRESS)
63609 + return GR_SUPPRESS;
63610 + else
63611 + return 0;
63612 +}
63613 +
63614 +int
63615 +gr_check_hidden_task(const struct task_struct *task)
63616 +{
63617 + if (unlikely(!(gr_status & GR_READY)))
63618 + return 0;
63619 +
63620 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
63621 + return 1;
63622 +
63623 + return 0;
63624 +}
63625 +
63626 +int
63627 +gr_check_protected_task(const struct task_struct *task)
63628 +{
63629 + if (unlikely(!(gr_status & GR_READY) || !task))
63630 + return 0;
63631 +
63632 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
63633 + task->acl != current->acl)
63634 + return 1;
63635 +
63636 + return 0;
63637 +}
63638 +
63639 +int
63640 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63641 +{
63642 + struct task_struct *p;
63643 + int ret = 0;
63644 +
63645 + if (unlikely(!(gr_status & GR_READY) || !pid))
63646 + return ret;
63647 +
63648 + read_lock(&tasklist_lock);
63649 + do_each_pid_task(pid, type, p) {
63650 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
63651 + p->acl != current->acl) {
63652 + ret = 1;
63653 + goto out;
63654 + }
63655 + } while_each_pid_task(pid, type, p);
63656 +out:
63657 + read_unlock(&tasklist_lock);
63658 +
63659 + return ret;
63660 +}
63661 +
63662 +void
63663 +gr_copy_label(struct task_struct *tsk)
63664 +{
63665 + struct task_struct *p = current;
63666 +
63667 + tsk->inherited = p->inherited;
63668 + tsk->acl_sp_role = 0;
63669 + tsk->acl_role_id = p->acl_role_id;
63670 + tsk->acl = p->acl;
63671 + tsk->role = p->role;
63672 + tsk->signal->used_accept = 0;
63673 + tsk->signal->curr_ip = p->signal->curr_ip;
63674 + tsk->signal->saved_ip = p->signal->saved_ip;
63675 + if (p->exec_file)
63676 + get_file(p->exec_file);
63677 + tsk->exec_file = p->exec_file;
63678 + tsk->is_writable = p->is_writable;
63679 + if (unlikely(p->signal->used_accept)) {
63680 + p->signal->curr_ip = 0;
63681 + p->signal->saved_ip = 0;
63682 + }
63683 +
63684 + return;
63685 +}
63686 +
63687 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
63688 +
63689 +int
63690 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
63691 +{
63692 + unsigned int i;
63693 + __u16 num;
63694 + uid_t *uidlist;
63695 + uid_t curuid;
63696 + int realok = 0;
63697 + int effectiveok = 0;
63698 + int fsok = 0;
63699 + uid_t globalreal, globaleffective, globalfs;
63700 +
63701 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
63702 + struct user_struct *user;
63703 +
63704 + if (!uid_valid(real))
63705 + goto skipit;
63706 +
63707 + /* find user based on global namespace */
63708 +
63709 + globalreal = GR_GLOBAL_UID(real);
63710 +
63711 + user = find_user(make_kuid(&init_user_ns, globalreal));
63712 + if (user == NULL)
63713 + goto skipit;
63714 +
63715 + if (gr_process_kernel_setuid_ban(user)) {
63716 + /* for find_user */
63717 + free_uid(user);
63718 + return 1;
63719 + }
63720 +
63721 + /* for find_user */
63722 + free_uid(user);
63723 +
63724 +skipit:
63725 +#endif
63726 +
63727 + if (unlikely(!(gr_status & GR_READY)))
63728 + return 0;
63729 +
63730 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
63731 + gr_log_learn_uid_change(real, effective, fs);
63732 +
63733 + num = current->acl->user_trans_num;
63734 + uidlist = current->acl->user_transitions;
63735 +
63736 + if (uidlist == NULL)
63737 + return 0;
63738 +
63739 + if (!uid_valid(real)) {
63740 + realok = 1;
63741 + globalreal = (uid_t)-1;
63742 + } else {
63743 + globalreal = GR_GLOBAL_UID(real);
63744 + }
63745 + if (!uid_valid(effective)) {
63746 + effectiveok = 1;
63747 + globaleffective = (uid_t)-1;
63748 + } else {
63749 + globaleffective = GR_GLOBAL_UID(effective);
63750 + }
63751 + if (!uid_valid(fs)) {
63752 + fsok = 1;
63753 + globalfs = (uid_t)-1;
63754 + } else {
63755 + globalfs = GR_GLOBAL_UID(fs);
63756 + }
63757 +
63758 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
63759 + for (i = 0; i < num; i++) {
63760 + curuid = uidlist[i];
63761 + if (globalreal == curuid)
63762 + realok = 1;
63763 + if (globaleffective == curuid)
63764 + effectiveok = 1;
63765 + if (globalfs == curuid)
63766 + fsok = 1;
63767 + }
63768 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
63769 + for (i = 0; i < num; i++) {
63770 + curuid = uidlist[i];
63771 + if (globalreal == curuid)
63772 + break;
63773 + if (globaleffective == curuid)
63774 + break;
63775 + if (globalfs == curuid)
63776 + break;
63777 + }
63778 + /* not in deny list */
63779 + if (i == num) {
63780 + realok = 1;
63781 + effectiveok = 1;
63782 + fsok = 1;
63783 + }
63784 + }
63785 +
63786 + if (realok && effectiveok && fsok)
63787 + return 0;
63788 + else {
63789 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
63790 + return 1;
63791 + }
63792 +}
63793 +
63794 +int
63795 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63796 +{
63797 + unsigned int i;
63798 + __u16 num;
63799 + gid_t *gidlist;
63800 + gid_t curgid;
63801 + int realok = 0;
63802 + int effectiveok = 0;
63803 + int fsok = 0;
63804 + gid_t globalreal, globaleffective, globalfs;
63805 +
63806 + if (unlikely(!(gr_status & GR_READY)))
63807 + return 0;
63808 +
63809 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
63810 + gr_log_learn_gid_change(real, effective, fs);
63811 +
63812 + num = current->acl->group_trans_num;
63813 + gidlist = current->acl->group_transitions;
63814 +
63815 + if (gidlist == NULL)
63816 + return 0;
63817 +
63818 + if (!gid_valid(real)) {
63819 + realok = 1;
63820 + globalreal = (gid_t)-1;
63821 + } else {
63822 + globalreal = GR_GLOBAL_GID(real);
63823 + }
63824 + if (!gid_valid(effective)) {
63825 + effectiveok = 1;
63826 + globaleffective = (gid_t)-1;
63827 + } else {
63828 + globaleffective = GR_GLOBAL_GID(effective);
63829 + }
63830 + if (!gid_valid(fs)) {
63831 + fsok = 1;
63832 + globalfs = (gid_t)-1;
63833 + } else {
63834 + globalfs = GR_GLOBAL_GID(fs);
63835 + }
63836 +
63837 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
63838 + for (i = 0; i < num; i++) {
63839 + curgid = gidlist[i];
63840 + if (globalreal == curgid)
63841 + realok = 1;
63842 + if (globaleffective == curgid)
63843 + effectiveok = 1;
63844 + if (globalfs == curgid)
63845 + fsok = 1;
63846 + }
63847 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
63848 + for (i = 0; i < num; i++) {
63849 + curgid = gidlist[i];
63850 + if (globalreal == curgid)
63851 + break;
63852 + if (globaleffective == curgid)
63853 + break;
63854 + if (globalfs == curgid)
63855 + break;
63856 + }
63857 + /* not in deny list */
63858 + if (i == num) {
63859 + realok = 1;
63860 + effectiveok = 1;
63861 + fsok = 1;
63862 + }
63863 + }
63864 +
63865 + if (realok && effectiveok && fsok)
63866 + return 0;
63867 + else {
63868 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
63869 + return 1;
63870 + }
63871 +}
63872 +
63873 +extern int gr_acl_is_capable(const int cap);
63874 +
63875 +void
63876 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
63877 +{
63878 + struct acl_role_label *role = task->role;
63879 + struct acl_subject_label *subj = NULL;
63880 + struct acl_object_label *obj;
63881 + struct file *filp;
63882 + uid_t uid;
63883 + gid_t gid;
63884 +
63885 + if (unlikely(!(gr_status & GR_READY)))
63886 + return;
63887 +
63888 + uid = GR_GLOBAL_UID(kuid);
63889 + gid = GR_GLOBAL_GID(kgid);
63890 +
63891 + filp = task->exec_file;
63892 +
63893 + /* kernel process, we'll give them the kernel role */
63894 + if (unlikely(!filp)) {
63895 + task->role = running_polstate.kernel_role;
63896 + task->acl = running_polstate.kernel_role->root_label;
63897 + return;
63898 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
63899 + /* save the current ip at time of role lookup so that the proper
63900 + IP will be learned for role_allowed_ip */
63901 + task->signal->saved_ip = task->signal->curr_ip;
63902 + role = lookup_acl_role_label(task, uid, gid);
63903 + }
63904 +
63905 + /* don't change the role if we're not a privileged process */
63906 + if (role && task->role != role &&
63907 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
63908 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
63909 + return;
63910 +
63911 + /* perform subject lookup in possibly new role
63912 + we can use this result below in the case where role == task->role
63913 + */
63914 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
63915 +
63916 + /* if we changed uid/gid, but result in the same role
63917 + and are using inheritance, don't lose the inherited subject
63918 + if current subject is other than what normal lookup
63919 + would result in, we arrived via inheritance, don't
63920 + lose subject
63921 + */
63922 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
63923 + (subj == task->acl)))
63924 + task->acl = subj;
63925 +
63926 + /* leave task->inherited unaffected */
63927 +
63928 + task->role = role;
63929 +
63930 + task->is_writable = 0;
63931 +
63932 + /* ignore additional mmap checks for processes that are writable
63933 + by the default ACL */
63934 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
63935 + if (unlikely(obj->mode & GR_WRITE))
63936 + task->is_writable = 1;
63937 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
63938 + if (unlikely(obj->mode & GR_WRITE))
63939 + task->is_writable = 1;
63940 +
63941 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63942 + 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);
63943 +#endif
63944 +
63945 + gr_set_proc_res(task);
63946 +
63947 + return;
63948 +}
63949 +
63950 +int
63951 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63952 + const int unsafe_flags)
63953 +{
63954 + struct task_struct *task = current;
63955 + struct acl_subject_label *newacl;
63956 + struct acl_object_label *obj;
63957 + __u32 retmode;
63958 +
63959 + if (unlikely(!(gr_status & GR_READY)))
63960 + return 0;
63961 +
63962 + newacl = chk_subj_label(dentry, mnt, task->role);
63963 +
63964 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
63965 + did an exec
63966 + */
63967 + rcu_read_lock();
63968 + read_lock(&tasklist_lock);
63969 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
63970 + (task->parent->acl->mode & GR_POVERRIDE))) {
63971 + read_unlock(&tasklist_lock);
63972 + rcu_read_unlock();
63973 + goto skip_check;
63974 + }
63975 + read_unlock(&tasklist_lock);
63976 + rcu_read_unlock();
63977 +
63978 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
63979 + !(task->role->roletype & GR_ROLE_GOD) &&
63980 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
63981 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
63982 + if (unsafe_flags & LSM_UNSAFE_SHARE)
63983 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
63984 + else
63985 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
63986 + return -EACCES;
63987 + }
63988 +
63989 +skip_check:
63990 +
63991 + obj = chk_obj_label(dentry, mnt, task->acl);
63992 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
63993 +
63994 + if (!(task->acl->mode & GR_INHERITLEARN) &&
63995 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
63996 + if (obj->nested)
63997 + task->acl = obj->nested;
63998 + else
63999 + task->acl = newacl;
64000 + task->inherited = 0;
64001 + } else {
64002 + task->inherited = 1;
64003 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64004 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64005 + }
64006 +
64007 + task->is_writable = 0;
64008 +
64009 + /* ignore additional mmap checks for processes that are writable
64010 + by the default ACL */
64011 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
64012 + if (unlikely(obj->mode & GR_WRITE))
64013 + task->is_writable = 1;
64014 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64015 + if (unlikely(obj->mode & GR_WRITE))
64016 + task->is_writable = 1;
64017 +
64018 + gr_set_proc_res(task);
64019 +
64020 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64021 + 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);
64022 +#endif
64023 + return 0;
64024 +}
64025 +
64026 +/* always called with valid inodev ptr */
64027 +static void
64028 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64029 +{
64030 + struct acl_object_label *matchpo;
64031 + struct acl_subject_label *matchps;
64032 + struct acl_subject_label *subj;
64033 + struct acl_role_label *role;
64034 + unsigned int x;
64035 +
64036 + FOR_EACH_ROLE_START(role)
64037 + FOR_EACH_SUBJECT_START(role, subj, x)
64038 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64039 + matchpo->mode |= GR_DELETED;
64040 + FOR_EACH_SUBJECT_END(subj,x)
64041 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64042 + /* nested subjects aren't in the role's subj_hash table */
64043 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64044 + matchpo->mode |= GR_DELETED;
64045 + FOR_EACH_NESTED_SUBJECT_END(subj)
64046 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64047 + matchps->mode |= GR_DELETED;
64048 + FOR_EACH_ROLE_END(role)
64049 +
64050 + inodev->nentry->deleted = 1;
64051 +
64052 + return;
64053 +}
64054 +
64055 +void
64056 +gr_handle_delete(const ino_t ino, const dev_t dev)
64057 +{
64058 + struct inodev_entry *inodev;
64059 +
64060 + if (unlikely(!(gr_status & GR_READY)))
64061 + return;
64062 +
64063 + write_lock(&gr_inode_lock);
64064 + inodev = lookup_inodev_entry(ino, dev);
64065 + if (inodev != NULL)
64066 + do_handle_delete(inodev, ino, dev);
64067 + write_unlock(&gr_inode_lock);
64068 +
64069 + return;
64070 +}
64071 +
64072 +static void
64073 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64074 + const ino_t newinode, const dev_t newdevice,
64075 + struct acl_subject_label *subj)
64076 +{
64077 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64078 + struct acl_object_label *match;
64079 +
64080 + match = subj->obj_hash[index];
64081 +
64082 + while (match && (match->inode != oldinode ||
64083 + match->device != olddevice ||
64084 + !(match->mode & GR_DELETED)))
64085 + match = match->next;
64086 +
64087 + if (match && (match->inode == oldinode)
64088 + && (match->device == olddevice)
64089 + && (match->mode & GR_DELETED)) {
64090 + if (match->prev == NULL) {
64091 + subj->obj_hash[index] = match->next;
64092 + if (match->next != NULL)
64093 + match->next->prev = NULL;
64094 + } else {
64095 + match->prev->next = match->next;
64096 + if (match->next != NULL)
64097 + match->next->prev = match->prev;
64098 + }
64099 + match->prev = NULL;
64100 + match->next = NULL;
64101 + match->inode = newinode;
64102 + match->device = newdevice;
64103 + match->mode &= ~GR_DELETED;
64104 +
64105 + insert_acl_obj_label(match, subj);
64106 + }
64107 +
64108 + return;
64109 +}
64110 +
64111 +static void
64112 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
64113 + const ino_t newinode, const dev_t newdevice,
64114 + struct acl_role_label *role)
64115 +{
64116 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
64117 + struct acl_subject_label *match;
64118 +
64119 + match = role->subj_hash[index];
64120 +
64121 + while (match && (match->inode != oldinode ||
64122 + match->device != olddevice ||
64123 + !(match->mode & GR_DELETED)))
64124 + match = match->next;
64125 +
64126 + if (match && (match->inode == oldinode)
64127 + && (match->device == olddevice)
64128 + && (match->mode & GR_DELETED)) {
64129 + if (match->prev == NULL) {
64130 + role->subj_hash[index] = match->next;
64131 + if (match->next != NULL)
64132 + match->next->prev = NULL;
64133 + } else {
64134 + match->prev->next = match->next;
64135 + if (match->next != NULL)
64136 + match->next->prev = match->prev;
64137 + }
64138 + match->prev = NULL;
64139 + match->next = NULL;
64140 + match->inode = newinode;
64141 + match->device = newdevice;
64142 + match->mode &= ~GR_DELETED;
64143 +
64144 + insert_acl_subj_label(match, role);
64145 + }
64146 +
64147 + return;
64148 +}
64149 +
64150 +static void
64151 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
64152 + const ino_t newinode, const dev_t newdevice)
64153 +{
64154 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
64155 + struct inodev_entry *match;
64156 +
64157 + match = running_polstate.inodev_set.i_hash[index];
64158 +
64159 + while (match && (match->nentry->inode != oldinode ||
64160 + match->nentry->device != olddevice || !match->nentry->deleted))
64161 + match = match->next;
64162 +
64163 + if (match && (match->nentry->inode == oldinode)
64164 + && (match->nentry->device == olddevice) &&
64165 + match->nentry->deleted) {
64166 + if (match->prev == NULL) {
64167 + running_polstate.inodev_set.i_hash[index] = match->next;
64168 + if (match->next != NULL)
64169 + match->next->prev = NULL;
64170 + } else {
64171 + match->prev->next = match->next;
64172 + if (match->next != NULL)
64173 + match->next->prev = match->prev;
64174 + }
64175 + match->prev = NULL;
64176 + match->next = NULL;
64177 + match->nentry->inode = newinode;
64178 + match->nentry->device = newdevice;
64179 + match->nentry->deleted = 0;
64180 +
64181 + insert_inodev_entry(match);
64182 + }
64183 +
64184 + return;
64185 +}
64186 +
64187 +static void
64188 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
64189 +{
64190 + struct acl_subject_label *subj;
64191 + struct acl_role_label *role;
64192 + unsigned int x;
64193 +
64194 + FOR_EACH_ROLE_START(role)
64195 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
64196 +
64197 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64198 + if ((subj->inode == ino) && (subj->device == dev)) {
64199 + subj->inode = ino;
64200 + subj->device = dev;
64201 + }
64202 + /* nested subjects aren't in the role's subj_hash table */
64203 + update_acl_obj_label(matchn->inode, matchn->device,
64204 + ino, dev, subj);
64205 + FOR_EACH_NESTED_SUBJECT_END(subj)
64206 + FOR_EACH_SUBJECT_START(role, subj, x)
64207 + update_acl_obj_label(matchn->inode, matchn->device,
64208 + ino, dev, subj);
64209 + FOR_EACH_SUBJECT_END(subj,x)
64210 + FOR_EACH_ROLE_END(role)
64211 +
64212 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
64213 +
64214 + return;
64215 +}
64216 +
64217 +static void
64218 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
64219 + const struct vfsmount *mnt)
64220 +{
64221 + ino_t ino = dentry->d_inode->i_ino;
64222 + dev_t dev = __get_dev(dentry);
64223 +
64224 + __do_handle_create(matchn, ino, dev);
64225 +
64226 + return;
64227 +}
64228 +
64229 +void
64230 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64231 +{
64232 + struct name_entry *matchn;
64233 +
64234 + if (unlikely(!(gr_status & GR_READY)))
64235 + return;
64236 +
64237 + preempt_disable();
64238 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
64239 +
64240 + if (unlikely((unsigned long)matchn)) {
64241 + write_lock(&gr_inode_lock);
64242 + do_handle_create(matchn, dentry, mnt);
64243 + write_unlock(&gr_inode_lock);
64244 + }
64245 + preempt_enable();
64246 +
64247 + return;
64248 +}
64249 +
64250 +void
64251 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64252 +{
64253 + struct name_entry *matchn;
64254 +
64255 + if (unlikely(!(gr_status & GR_READY)))
64256 + return;
64257 +
64258 + preempt_disable();
64259 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
64260 +
64261 + if (unlikely((unsigned long)matchn)) {
64262 + write_lock(&gr_inode_lock);
64263 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
64264 + write_unlock(&gr_inode_lock);
64265 + }
64266 + preempt_enable();
64267 +
64268 + return;
64269 +}
64270 +
64271 +void
64272 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64273 + struct dentry *old_dentry,
64274 + struct dentry *new_dentry,
64275 + struct vfsmount *mnt, const __u8 replace)
64276 +{
64277 + struct name_entry *matchn;
64278 + struct inodev_entry *inodev;
64279 + struct inode *inode = new_dentry->d_inode;
64280 + ino_t old_ino = old_dentry->d_inode->i_ino;
64281 + dev_t old_dev = __get_dev(old_dentry);
64282 +
64283 + /* vfs_rename swaps the name and parent link for old_dentry and
64284 + new_dentry
64285 + at this point, old_dentry has the new name, parent link, and inode
64286 + for the renamed file
64287 + if a file is being replaced by a rename, new_dentry has the inode
64288 + and name for the replaced file
64289 + */
64290 +
64291 + if (unlikely(!(gr_status & GR_READY)))
64292 + return;
64293 +
64294 + preempt_disable();
64295 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
64296 +
64297 + /* we wouldn't have to check d_inode if it weren't for
64298 + NFS silly-renaming
64299 + */
64300 +
64301 + write_lock(&gr_inode_lock);
64302 + if (unlikely(replace && inode)) {
64303 + ino_t new_ino = inode->i_ino;
64304 + dev_t new_dev = __get_dev(new_dentry);
64305 +
64306 + inodev = lookup_inodev_entry(new_ino, new_dev);
64307 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
64308 + do_handle_delete(inodev, new_ino, new_dev);
64309 + }
64310 +
64311 + inodev = lookup_inodev_entry(old_ino, old_dev);
64312 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
64313 + do_handle_delete(inodev, old_ino, old_dev);
64314 +
64315 + if (unlikely((unsigned long)matchn))
64316 + do_handle_create(matchn, old_dentry, mnt);
64317 +
64318 + write_unlock(&gr_inode_lock);
64319 + preempt_enable();
64320 +
64321 + return;
64322 +}
64323 +
64324 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
64325 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
64326 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
64327 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
64328 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
64329 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
64330 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
64331 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
64332 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
64333 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
64334 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
64335 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
64336 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
64337 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
64338 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
64339 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
64340 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
64341 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
64342 +};
64343 +
64344 +void
64345 +gr_learn_resource(const struct task_struct *task,
64346 + const int res, const unsigned long wanted, const int gt)
64347 +{
64348 + struct acl_subject_label *acl;
64349 + const struct cred *cred;
64350 +
64351 + if (unlikely((gr_status & GR_READY) &&
64352 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
64353 + goto skip_reslog;
64354 +
64355 + gr_log_resource(task, res, wanted, gt);
64356 +skip_reslog:
64357 +
64358 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
64359 + return;
64360 +
64361 + acl = task->acl;
64362 +
64363 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
64364 + !(acl->resmask & (1U << (unsigned short) res))))
64365 + return;
64366 +
64367 + if (wanted >= acl->res[res].rlim_cur) {
64368 + unsigned long res_add;
64369 +
64370 + res_add = wanted + res_learn_bumps[res];
64371 +
64372 + acl->res[res].rlim_cur = res_add;
64373 +
64374 + if (wanted > acl->res[res].rlim_max)
64375 + acl->res[res].rlim_max = res_add;
64376 +
64377 + /* only log the subject filename, since resource logging is supported for
64378 + single-subject learning only */
64379 + rcu_read_lock();
64380 + cred = __task_cred(task);
64381 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
64382 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
64383 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
64384 + "", (unsigned long) res, &task->signal->saved_ip);
64385 + rcu_read_unlock();
64386 + }
64387 +
64388 + return;
64389 +}
64390 +EXPORT_SYMBOL(gr_learn_resource);
64391 +#endif
64392 +
64393 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
64394 +void
64395 +pax_set_initial_flags(struct linux_binprm *bprm)
64396 +{
64397 + struct task_struct *task = current;
64398 + struct acl_subject_label *proc;
64399 + unsigned long flags;
64400 +
64401 + if (unlikely(!(gr_status & GR_READY)))
64402 + return;
64403 +
64404 + flags = pax_get_flags(task);
64405 +
64406 + proc = task->acl;
64407 +
64408 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
64409 + flags &= ~MF_PAX_PAGEEXEC;
64410 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
64411 + flags &= ~MF_PAX_SEGMEXEC;
64412 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
64413 + flags &= ~MF_PAX_RANDMMAP;
64414 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
64415 + flags &= ~MF_PAX_EMUTRAMP;
64416 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
64417 + flags &= ~MF_PAX_MPROTECT;
64418 +
64419 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
64420 + flags |= MF_PAX_PAGEEXEC;
64421 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
64422 + flags |= MF_PAX_SEGMEXEC;
64423 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
64424 + flags |= MF_PAX_RANDMMAP;
64425 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
64426 + flags |= MF_PAX_EMUTRAMP;
64427 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
64428 + flags |= MF_PAX_MPROTECT;
64429 +
64430 + pax_set_flags(task, flags);
64431 +
64432 + return;
64433 +}
64434 +#endif
64435 +
64436 +int
64437 +gr_handle_proc_ptrace(struct task_struct *task)
64438 +{
64439 + struct file *filp;
64440 + struct task_struct *tmp = task;
64441 + struct task_struct *curtemp = current;
64442 + __u32 retmode;
64443 +
64444 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64445 + if (unlikely(!(gr_status & GR_READY)))
64446 + return 0;
64447 +#endif
64448 +
64449 + read_lock(&tasklist_lock);
64450 + read_lock(&grsec_exec_file_lock);
64451 + filp = task->exec_file;
64452 +
64453 + while (task_pid_nr(tmp) > 0) {
64454 + if (tmp == curtemp)
64455 + break;
64456 + tmp = tmp->real_parent;
64457 + }
64458 +
64459 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64460 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
64461 + read_unlock(&grsec_exec_file_lock);
64462 + read_unlock(&tasklist_lock);
64463 + return 1;
64464 + }
64465 +
64466 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64467 + if (!(gr_status & GR_READY)) {
64468 + read_unlock(&grsec_exec_file_lock);
64469 + read_unlock(&tasklist_lock);
64470 + return 0;
64471 + }
64472 +#endif
64473 +
64474 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
64475 + read_unlock(&grsec_exec_file_lock);
64476 + read_unlock(&tasklist_lock);
64477 +
64478 + if (retmode & GR_NOPTRACE)
64479 + return 1;
64480 +
64481 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
64482 + && (current->acl != task->acl || (current->acl != current->role->root_label
64483 + && task_pid_nr(current) != task_pid_nr(task))))
64484 + return 1;
64485 +
64486 + return 0;
64487 +}
64488 +
64489 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
64490 +{
64491 + if (unlikely(!(gr_status & GR_READY)))
64492 + return;
64493 +
64494 + if (!(current->role->roletype & GR_ROLE_GOD))
64495 + return;
64496 +
64497 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
64498 + p->role->rolename, gr_task_roletype_to_char(p),
64499 + p->acl->filename);
64500 +}
64501 +
64502 +int
64503 +gr_handle_ptrace(struct task_struct *task, const long request)
64504 +{
64505 + struct task_struct *tmp = task;
64506 + struct task_struct *curtemp = current;
64507 + __u32 retmode;
64508 +
64509 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64510 + if (unlikely(!(gr_status & GR_READY)))
64511 + return 0;
64512 +#endif
64513 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
64514 + read_lock(&tasklist_lock);
64515 + while (task_pid_nr(tmp) > 0) {
64516 + if (tmp == curtemp)
64517 + break;
64518 + tmp = tmp->real_parent;
64519 + }
64520 +
64521 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64522 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
64523 + read_unlock(&tasklist_lock);
64524 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64525 + return 1;
64526 + }
64527 + read_unlock(&tasklist_lock);
64528 + }
64529 +
64530 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64531 + if (!(gr_status & GR_READY))
64532 + return 0;
64533 +#endif
64534 +
64535 + read_lock(&grsec_exec_file_lock);
64536 + if (unlikely(!task->exec_file)) {
64537 + read_unlock(&grsec_exec_file_lock);
64538 + return 0;
64539 + }
64540 +
64541 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
64542 + read_unlock(&grsec_exec_file_lock);
64543 +
64544 + if (retmode & GR_NOPTRACE) {
64545 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64546 + return 1;
64547 + }
64548 +
64549 + if (retmode & GR_PTRACERD) {
64550 + switch (request) {
64551 + case PTRACE_SEIZE:
64552 + case PTRACE_POKETEXT:
64553 + case PTRACE_POKEDATA:
64554 + case PTRACE_POKEUSR:
64555 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
64556 + case PTRACE_SETREGS:
64557 + case PTRACE_SETFPREGS:
64558 +#endif
64559 +#ifdef CONFIG_X86
64560 + case PTRACE_SETFPXREGS:
64561 +#endif
64562 +#ifdef CONFIG_ALTIVEC
64563 + case PTRACE_SETVRREGS:
64564 +#endif
64565 + return 1;
64566 + default:
64567 + return 0;
64568 + }
64569 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
64570 + !(current->role->roletype & GR_ROLE_GOD) &&
64571 + (current->acl != task->acl)) {
64572 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64573 + return 1;
64574 + }
64575 +
64576 + return 0;
64577 +}
64578 +
64579 +static int is_writable_mmap(const struct file *filp)
64580 +{
64581 + struct task_struct *task = current;
64582 + struct acl_object_label *obj, *obj2;
64583 +
64584 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
64585 + !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))) {
64586 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64587 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
64588 + task->role->root_label);
64589 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
64590 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
64591 + return 1;
64592 + }
64593 + }
64594 + return 0;
64595 +}
64596 +
64597 +int
64598 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
64599 +{
64600 + __u32 mode;
64601 +
64602 + if (unlikely(!file || !(prot & PROT_EXEC)))
64603 + return 1;
64604 +
64605 + if (is_writable_mmap(file))
64606 + return 0;
64607 +
64608 + mode =
64609 + gr_search_file(file->f_path.dentry,
64610 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
64611 + file->f_path.mnt);
64612 +
64613 + if (!gr_tpe_allow(file))
64614 + return 0;
64615 +
64616 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
64617 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64618 + return 0;
64619 + } else if (unlikely(!(mode & GR_EXEC))) {
64620 + return 0;
64621 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
64622 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64623 + return 1;
64624 + }
64625 +
64626 + return 1;
64627 +}
64628 +
64629 +int
64630 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64631 +{
64632 + __u32 mode;
64633 +
64634 + if (unlikely(!file || !(prot & PROT_EXEC)))
64635 + return 1;
64636 +
64637 + if (is_writable_mmap(file))
64638 + return 0;
64639 +
64640 + mode =
64641 + gr_search_file(file->f_path.dentry,
64642 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
64643 + file->f_path.mnt);
64644 +
64645 + if (!gr_tpe_allow(file))
64646 + return 0;
64647 +
64648 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
64649 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64650 + return 0;
64651 + } else if (unlikely(!(mode & GR_EXEC))) {
64652 + return 0;
64653 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
64654 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64655 + return 1;
64656 + }
64657 +
64658 + return 1;
64659 +}
64660 +
64661 +void
64662 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64663 +{
64664 + unsigned long runtime;
64665 + unsigned long cputime;
64666 + unsigned int wday, cday;
64667 + __u8 whr, chr;
64668 + __u8 wmin, cmin;
64669 + __u8 wsec, csec;
64670 + struct timespec timeval;
64671 +
64672 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
64673 + !(task->acl->mode & GR_PROCACCT)))
64674 + return;
64675 +
64676 + do_posix_clock_monotonic_gettime(&timeval);
64677 + runtime = timeval.tv_sec - task->start_time.tv_sec;
64678 + wday = runtime / (3600 * 24);
64679 + runtime -= wday * (3600 * 24);
64680 + whr = runtime / 3600;
64681 + runtime -= whr * 3600;
64682 + wmin = runtime / 60;
64683 + runtime -= wmin * 60;
64684 + wsec = runtime;
64685 +
64686 + cputime = (task->utime + task->stime) / HZ;
64687 + cday = cputime / (3600 * 24);
64688 + cputime -= cday * (3600 * 24);
64689 + chr = cputime / 3600;
64690 + cputime -= chr * 3600;
64691 + cmin = cputime / 60;
64692 + cputime -= cmin * 60;
64693 + csec = cputime;
64694 +
64695 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
64696 +
64697 + return;
64698 +}
64699 +
64700 +#ifdef CONFIG_TASKSTATS
64701 +int gr_is_taskstats_denied(int pid)
64702 +{
64703 + struct task_struct *task;
64704 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64705 + const struct cred *cred;
64706 +#endif
64707 + int ret = 0;
64708 +
64709 + /* restrict taskstats viewing to un-chrooted root users
64710 + who have the 'view' subject flag if the RBAC system is enabled
64711 + */
64712 +
64713 + rcu_read_lock();
64714 + read_lock(&tasklist_lock);
64715 + task = find_task_by_vpid(pid);
64716 + if (task) {
64717 +#ifdef CONFIG_GRKERNSEC_CHROOT
64718 + if (proc_is_chrooted(task))
64719 + ret = -EACCES;
64720 +#endif
64721 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64722 + cred = __task_cred(task);
64723 +#ifdef CONFIG_GRKERNSEC_PROC_USER
64724 + if (gr_is_global_nonroot(cred->uid))
64725 + ret = -EACCES;
64726 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64727 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
64728 + ret = -EACCES;
64729 +#endif
64730 +#endif
64731 + if (gr_status & GR_READY) {
64732 + if (!(task->acl->mode & GR_VIEW))
64733 + ret = -EACCES;
64734 + }
64735 + } else
64736 + ret = -ENOENT;
64737 +
64738 + read_unlock(&tasklist_lock);
64739 + rcu_read_unlock();
64740 +
64741 + return ret;
64742 +}
64743 +#endif
64744 +
64745 +/* AUXV entries are filled via a descendant of search_binary_handler
64746 + after we've already applied the subject for the target
64747 +*/
64748 +int gr_acl_enable_at_secure(void)
64749 +{
64750 + if (unlikely(!(gr_status & GR_READY)))
64751 + return 0;
64752 +
64753 + if (current->acl->mode & GR_ATSECURE)
64754 + return 1;
64755 +
64756 + return 0;
64757 +}
64758 +
64759 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
64760 +{
64761 + struct task_struct *task = current;
64762 + struct dentry *dentry = file->f_path.dentry;
64763 + struct vfsmount *mnt = file->f_path.mnt;
64764 + struct acl_object_label *obj, *tmp;
64765 + struct acl_subject_label *subj;
64766 + unsigned int bufsize;
64767 + int is_not_root;
64768 + char *path;
64769 + dev_t dev = __get_dev(dentry);
64770 +
64771 + if (unlikely(!(gr_status & GR_READY)))
64772 + return 1;
64773 +
64774 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64775 + return 1;
64776 +
64777 + /* ignore Eric Biederman */
64778 + if (IS_PRIVATE(dentry->d_inode))
64779 + return 1;
64780 +
64781 + subj = task->acl;
64782 + read_lock(&gr_inode_lock);
64783 + do {
64784 + obj = lookup_acl_obj_label(ino, dev, subj);
64785 + if (obj != NULL) {
64786 + read_unlock(&gr_inode_lock);
64787 + return (obj->mode & GR_FIND) ? 1 : 0;
64788 + }
64789 + } while ((subj = subj->parent_subject));
64790 + read_unlock(&gr_inode_lock);
64791 +
64792 + /* this is purely an optimization since we're looking for an object
64793 + for the directory we're doing a readdir on
64794 + if it's possible for any globbed object to match the entry we're
64795 + filling into the directory, then the object we find here will be
64796 + an anchor point with attached globbed objects
64797 + */
64798 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
64799 + if (obj->globbed == NULL)
64800 + return (obj->mode & GR_FIND) ? 1 : 0;
64801 +
64802 + is_not_root = ((obj->filename[0] == '/') &&
64803 + (obj->filename[1] == '\0')) ? 0 : 1;
64804 + bufsize = PAGE_SIZE - namelen - is_not_root;
64805 +
64806 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
64807 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
64808 + return 1;
64809 +
64810 + preempt_disable();
64811 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
64812 + bufsize);
64813 +
64814 + bufsize = strlen(path);
64815 +
64816 + /* if base is "/", don't append an additional slash */
64817 + if (is_not_root)
64818 + *(path + bufsize) = '/';
64819 + memcpy(path + bufsize + is_not_root, name, namelen);
64820 + *(path + bufsize + namelen + is_not_root) = '\0';
64821 +
64822 + tmp = obj->globbed;
64823 + while (tmp) {
64824 + if (!glob_match(tmp->filename, path)) {
64825 + preempt_enable();
64826 + return (tmp->mode & GR_FIND) ? 1 : 0;
64827 + }
64828 + tmp = tmp->next;
64829 + }
64830 + preempt_enable();
64831 + return (obj->mode & GR_FIND) ? 1 : 0;
64832 +}
64833 +
64834 +void gr_put_exec_file(struct task_struct *task)
64835 +{
64836 + struct file *filp;
64837 +
64838 + write_lock(&grsec_exec_file_lock);
64839 + filp = task->exec_file;
64840 + task->exec_file = NULL;
64841 + write_unlock(&grsec_exec_file_lock);
64842 +
64843 + if (filp)
64844 + fput(filp);
64845 +
64846 + return;
64847 +}
64848 +
64849 +
64850 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
64851 +EXPORT_SYMBOL(gr_acl_is_enabled);
64852 +#endif
64853 +#ifdef CONFIG_SECURITY
64854 +EXPORT_SYMBOL(gr_check_user_change);
64855 +EXPORT_SYMBOL(gr_check_group_change);
64856 +#endif
64857 +
64858 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
64859 new file mode 100644
64860 index 0000000..18ffbbd
64861 --- /dev/null
64862 +++ b/grsecurity/gracl_alloc.c
64863 @@ -0,0 +1,105 @@
64864 +#include <linux/kernel.h>
64865 +#include <linux/mm.h>
64866 +#include <linux/slab.h>
64867 +#include <linux/vmalloc.h>
64868 +#include <linux/gracl.h>
64869 +#include <linux/grsecurity.h>
64870 +
64871 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
64872 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
64873 +
64874 +static __inline__ int
64875 +alloc_pop(void)
64876 +{
64877 + if (current_alloc_state->alloc_stack_next == 1)
64878 + return 0;
64879 +
64880 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
64881 +
64882 + current_alloc_state->alloc_stack_next--;
64883 +
64884 + return 1;
64885 +}
64886 +
64887 +static __inline__ int
64888 +alloc_push(void *buf)
64889 +{
64890 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
64891 + return 1;
64892 +
64893 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
64894 +
64895 + current_alloc_state->alloc_stack_next++;
64896 +
64897 + return 0;
64898 +}
64899 +
64900 +void *
64901 +acl_alloc(unsigned long len)
64902 +{
64903 + void *ret = NULL;
64904 +
64905 + if (!len || len > PAGE_SIZE)
64906 + goto out;
64907 +
64908 + ret = kmalloc(len, GFP_KERNEL);
64909 +
64910 + if (ret) {
64911 + if (alloc_push(ret)) {
64912 + kfree(ret);
64913 + ret = NULL;
64914 + }
64915 + }
64916 +
64917 +out:
64918 + return ret;
64919 +}
64920 +
64921 +void *
64922 +acl_alloc_num(unsigned long num, unsigned long len)
64923 +{
64924 + if (!len || (num > (PAGE_SIZE / len)))
64925 + return NULL;
64926 +
64927 + return acl_alloc(num * len);
64928 +}
64929 +
64930 +void
64931 +acl_free_all(void)
64932 +{
64933 + if (!current_alloc_state->alloc_stack)
64934 + return;
64935 +
64936 + while (alloc_pop()) ;
64937 +
64938 + if (current_alloc_state->alloc_stack) {
64939 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
64940 + kfree(current_alloc_state->alloc_stack);
64941 + else
64942 + vfree(current_alloc_state->alloc_stack);
64943 + }
64944 +
64945 + current_alloc_state->alloc_stack = NULL;
64946 + current_alloc_state->alloc_stack_size = 1;
64947 + current_alloc_state->alloc_stack_next = 1;
64948 +
64949 + return;
64950 +}
64951 +
64952 +int
64953 +acl_alloc_stack_init(unsigned long size)
64954 +{
64955 + if ((size * sizeof (void *)) <= PAGE_SIZE)
64956 + current_alloc_state->alloc_stack =
64957 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
64958 + else
64959 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
64960 +
64961 + current_alloc_state->alloc_stack_size = size;
64962 + current_alloc_state->alloc_stack_next = 1;
64963 +
64964 + if (!current_alloc_state->alloc_stack)
64965 + return 0;
64966 + else
64967 + return 1;
64968 +}
64969 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
64970 new file mode 100644
64971 index 0000000..bdd51ea
64972 --- /dev/null
64973 +++ b/grsecurity/gracl_cap.c
64974 @@ -0,0 +1,110 @@
64975 +#include <linux/kernel.h>
64976 +#include <linux/module.h>
64977 +#include <linux/sched.h>
64978 +#include <linux/gracl.h>
64979 +#include <linux/grsecurity.h>
64980 +#include <linux/grinternal.h>
64981 +
64982 +extern const char *captab_log[];
64983 +extern int captab_log_entries;
64984 +
64985 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64986 +{
64987 + struct acl_subject_label *curracl;
64988 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
64989 + kernel_cap_t cap_audit = __cap_empty_set;
64990 +
64991 + if (!gr_acl_is_enabled())
64992 + return 1;
64993 +
64994 + curracl = task->acl;
64995 +
64996 + cap_drop = curracl->cap_lower;
64997 + cap_mask = curracl->cap_mask;
64998 + cap_audit = curracl->cap_invert_audit;
64999 +
65000 + while ((curracl = curracl->parent_subject)) {
65001 + /* if the cap isn't specified in the current computed mask but is specified in the
65002 + current level subject, and is lowered in the current level subject, then add
65003 + it to the set of dropped capabilities
65004 + otherwise, add the current level subject's mask to the current computed mask
65005 + */
65006 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65007 + cap_raise(cap_mask, cap);
65008 + if (cap_raised(curracl->cap_lower, cap))
65009 + cap_raise(cap_drop, cap);
65010 + if (cap_raised(curracl->cap_invert_audit, cap))
65011 + cap_raise(cap_audit, cap);
65012 + }
65013 + }
65014 +
65015 + if (!cap_raised(cap_drop, cap)) {
65016 + if (cap_raised(cap_audit, cap))
65017 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
65018 + return 1;
65019 + }
65020 +
65021 + curracl = task->acl;
65022 +
65023 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
65024 + && cap_raised(cred->cap_effective, cap)) {
65025 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65026 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
65027 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
65028 + gr_to_filename(task->exec_file->f_path.dentry,
65029 + task->exec_file->f_path.mnt) : curracl->filename,
65030 + curracl->filename, 0UL,
65031 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
65032 + return 1;
65033 + }
65034 +
65035 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
65036 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
65037 +
65038 + return 0;
65039 +}
65040 +
65041 +int
65042 +gr_acl_is_capable(const int cap)
65043 +{
65044 + return gr_task_acl_is_capable(current, current_cred(), cap);
65045 +}
65046 +
65047 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
65048 +{
65049 + struct acl_subject_label *curracl;
65050 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65051 +
65052 + if (!gr_acl_is_enabled())
65053 + return 1;
65054 +
65055 + curracl = task->acl;
65056 +
65057 + cap_drop = curracl->cap_lower;
65058 + cap_mask = curracl->cap_mask;
65059 +
65060 + while ((curracl = curracl->parent_subject)) {
65061 + /* if the cap isn't specified in the current computed mask but is specified in the
65062 + current level subject, and is lowered in the current level subject, then add
65063 + it to the set of dropped capabilities
65064 + otherwise, add the current level subject's mask to the current computed mask
65065 + */
65066 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65067 + cap_raise(cap_mask, cap);
65068 + if (cap_raised(curracl->cap_lower, cap))
65069 + cap_raise(cap_drop, cap);
65070 + }
65071 + }
65072 +
65073 + if (!cap_raised(cap_drop, cap))
65074 + return 1;
65075 +
65076 + return 0;
65077 +}
65078 +
65079 +int
65080 +gr_acl_is_capable_nolog(const int cap)
65081 +{
65082 + return gr_task_acl_is_capable_nolog(current, cap);
65083 +}
65084 +
65085 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
65086 new file mode 100644
65087 index 0000000..ca25605
65088 --- /dev/null
65089 +++ b/grsecurity/gracl_compat.c
65090 @@ -0,0 +1,270 @@
65091 +#include <linux/kernel.h>
65092 +#include <linux/gracl.h>
65093 +#include <linux/compat.h>
65094 +#include <linux/gracl_compat.h>
65095 +
65096 +#include <asm/uaccess.h>
65097 +
65098 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
65099 +{
65100 + struct gr_arg_wrapper_compat uwrapcompat;
65101 +
65102 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
65103 + return -EFAULT;
65104 +
65105 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
65106 + (uwrapcompat.version != 0x2901)) ||
65107 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
65108 + return -EINVAL;
65109 +
65110 + uwrap->arg = compat_ptr(uwrapcompat.arg);
65111 + uwrap->version = uwrapcompat.version;
65112 + uwrap->size = sizeof(struct gr_arg);
65113 +
65114 + return 0;
65115 +}
65116 +
65117 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
65118 +{
65119 + struct gr_arg_compat argcompat;
65120 +
65121 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
65122 + return -EFAULT;
65123 +
65124 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
65125 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
65126 + arg->role_db.num_roles = argcompat.role_db.num_roles;
65127 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
65128 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
65129 + arg->role_db.num_objects = argcompat.role_db.num_objects;
65130 +
65131 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
65132 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
65133 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
65134 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
65135 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
65136 + arg->segv_device = argcompat.segv_device;
65137 + arg->segv_inode = argcompat.segv_inode;
65138 + arg->segv_uid = argcompat.segv_uid;
65139 + arg->num_sprole_pws = argcompat.num_sprole_pws;
65140 + arg->mode = argcompat.mode;
65141 +
65142 + return 0;
65143 +}
65144 +
65145 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
65146 +{
65147 + struct acl_object_label_compat objcompat;
65148 +
65149 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
65150 + return -EFAULT;
65151 +
65152 + obj->filename = compat_ptr(objcompat.filename);
65153 + obj->inode = objcompat.inode;
65154 + obj->device = objcompat.device;
65155 + obj->mode = objcompat.mode;
65156 +
65157 + obj->nested = compat_ptr(objcompat.nested);
65158 + obj->globbed = compat_ptr(objcompat.globbed);
65159 +
65160 + obj->prev = compat_ptr(objcompat.prev);
65161 + obj->next = compat_ptr(objcompat.next);
65162 +
65163 + return 0;
65164 +}
65165 +
65166 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
65167 +{
65168 + unsigned int i;
65169 + struct acl_subject_label_compat subjcompat;
65170 +
65171 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
65172 + return -EFAULT;
65173 +
65174 + subj->filename = compat_ptr(subjcompat.filename);
65175 + subj->inode = subjcompat.inode;
65176 + subj->device = subjcompat.device;
65177 + subj->mode = subjcompat.mode;
65178 + subj->cap_mask = subjcompat.cap_mask;
65179 + subj->cap_lower = subjcompat.cap_lower;
65180 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
65181 +
65182 + for (i = 0; i < GR_NLIMITS; i++) {
65183 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
65184 + subj->res[i].rlim_cur = RLIM_INFINITY;
65185 + else
65186 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
65187 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
65188 + subj->res[i].rlim_max = RLIM_INFINITY;
65189 + else
65190 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
65191 + }
65192 + subj->resmask = subjcompat.resmask;
65193 +
65194 + subj->user_trans_type = subjcompat.user_trans_type;
65195 + subj->group_trans_type = subjcompat.group_trans_type;
65196 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
65197 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
65198 + subj->user_trans_num = subjcompat.user_trans_num;
65199 + subj->group_trans_num = subjcompat.group_trans_num;
65200 +
65201 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
65202 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
65203 + subj->ip_type = subjcompat.ip_type;
65204 + subj->ips = compat_ptr(subjcompat.ips);
65205 + subj->ip_num = subjcompat.ip_num;
65206 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
65207 +
65208 + subj->crashes = subjcompat.crashes;
65209 + subj->expires = subjcompat.expires;
65210 +
65211 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
65212 + subj->hash = compat_ptr(subjcompat.hash);
65213 + subj->prev = compat_ptr(subjcompat.prev);
65214 + subj->next = compat_ptr(subjcompat.next);
65215 +
65216 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
65217 + subj->obj_hash_size = subjcompat.obj_hash_size;
65218 + subj->pax_flags = subjcompat.pax_flags;
65219 +
65220 + return 0;
65221 +}
65222 +
65223 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
65224 +{
65225 + struct acl_role_label_compat rolecompat;
65226 +
65227 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
65228 + return -EFAULT;
65229 +
65230 + role->rolename = compat_ptr(rolecompat.rolename);
65231 + role->uidgid = rolecompat.uidgid;
65232 + role->roletype = rolecompat.roletype;
65233 +
65234 + role->auth_attempts = rolecompat.auth_attempts;
65235 + role->expires = rolecompat.expires;
65236 +
65237 + role->root_label = compat_ptr(rolecompat.root_label);
65238 + role->hash = compat_ptr(rolecompat.hash);
65239 +
65240 + role->prev = compat_ptr(rolecompat.prev);
65241 + role->next = compat_ptr(rolecompat.next);
65242 +
65243 + role->transitions = compat_ptr(rolecompat.transitions);
65244 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
65245 + role->domain_children = compat_ptr(rolecompat.domain_children);
65246 + role->domain_child_num = rolecompat.domain_child_num;
65247 +
65248 + role->umask = rolecompat.umask;
65249 +
65250 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
65251 + role->subj_hash_size = rolecompat.subj_hash_size;
65252 +
65253 + return 0;
65254 +}
65255 +
65256 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
65257 +{
65258 + struct role_allowed_ip_compat roleip_compat;
65259 +
65260 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
65261 + return -EFAULT;
65262 +
65263 + roleip->addr = roleip_compat.addr;
65264 + roleip->netmask = roleip_compat.netmask;
65265 +
65266 + roleip->prev = compat_ptr(roleip_compat.prev);
65267 + roleip->next = compat_ptr(roleip_compat.next);
65268 +
65269 + return 0;
65270 +}
65271 +
65272 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
65273 +{
65274 + struct role_transition_compat trans_compat;
65275 +
65276 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
65277 + return -EFAULT;
65278 +
65279 + trans->rolename = compat_ptr(trans_compat.rolename);
65280 +
65281 + trans->prev = compat_ptr(trans_compat.prev);
65282 + trans->next = compat_ptr(trans_compat.next);
65283 +
65284 + return 0;
65285 +
65286 +}
65287 +
65288 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
65289 +{
65290 + struct gr_hash_struct_compat hash_compat;
65291 +
65292 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
65293 + return -EFAULT;
65294 +
65295 + hash->table = compat_ptr(hash_compat.table);
65296 + hash->nametable = compat_ptr(hash_compat.nametable);
65297 + hash->first = compat_ptr(hash_compat.first);
65298 +
65299 + hash->table_size = hash_compat.table_size;
65300 + hash->used_size = hash_compat.used_size;
65301 +
65302 + hash->type = hash_compat.type;
65303 +
65304 + return 0;
65305 +}
65306 +
65307 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
65308 +{
65309 + compat_uptr_t ptrcompat;
65310 +
65311 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
65312 + return -EFAULT;
65313 +
65314 + *(void **)ptr = compat_ptr(ptrcompat);
65315 +
65316 + return 0;
65317 +}
65318 +
65319 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
65320 +{
65321 + struct acl_ip_label_compat ip_compat;
65322 +
65323 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
65324 + return -EFAULT;
65325 +
65326 + ip->iface = compat_ptr(ip_compat.iface);
65327 + ip->addr = ip_compat.addr;
65328 + ip->netmask = ip_compat.netmask;
65329 + ip->low = ip_compat.low;
65330 + ip->high = ip_compat.high;
65331 + ip->mode = ip_compat.mode;
65332 + ip->type = ip_compat.type;
65333 +
65334 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
65335 +
65336 + ip->prev = compat_ptr(ip_compat.prev);
65337 + ip->next = compat_ptr(ip_compat.next);
65338 +
65339 + return 0;
65340 +}
65341 +
65342 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
65343 +{
65344 + struct sprole_pw_compat pw_compat;
65345 +
65346 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
65347 + return -EFAULT;
65348 +
65349 + pw->rolename = compat_ptr(pw_compat.rolename);
65350 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
65351 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
65352 +
65353 + return 0;
65354 +}
65355 +
65356 +size_t get_gr_arg_wrapper_size_compat(void)
65357 +{
65358 + return sizeof(struct gr_arg_wrapper_compat);
65359 +}
65360 +
65361 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
65362 new file mode 100644
65363 index 0000000..a340c17
65364 --- /dev/null
65365 +++ b/grsecurity/gracl_fs.c
65366 @@ -0,0 +1,431 @@
65367 +#include <linux/kernel.h>
65368 +#include <linux/sched.h>
65369 +#include <linux/types.h>
65370 +#include <linux/fs.h>
65371 +#include <linux/file.h>
65372 +#include <linux/stat.h>
65373 +#include <linux/grsecurity.h>
65374 +#include <linux/grinternal.h>
65375 +#include <linux/gracl.h>
65376 +
65377 +umode_t
65378 +gr_acl_umask(void)
65379 +{
65380 + if (unlikely(!gr_acl_is_enabled()))
65381 + return 0;
65382 +
65383 + return current->role->umask;
65384 +}
65385 +
65386 +__u32
65387 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65388 + const struct vfsmount * mnt)
65389 +{
65390 + __u32 mode;
65391 +
65392 + if (unlikely(!dentry->d_inode))
65393 + return GR_FIND;
65394 +
65395 + mode =
65396 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
65397 +
65398 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
65399 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65400 + return mode;
65401 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
65402 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65403 + return 0;
65404 + } else if (unlikely(!(mode & GR_FIND)))
65405 + return 0;
65406 +
65407 + return GR_FIND;
65408 +}
65409 +
65410 +__u32
65411 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65412 + int acc_mode)
65413 +{
65414 + __u32 reqmode = GR_FIND;
65415 + __u32 mode;
65416 +
65417 + if (unlikely(!dentry->d_inode))
65418 + return reqmode;
65419 +
65420 + if (acc_mode & MAY_APPEND)
65421 + reqmode |= GR_APPEND;
65422 + else if (acc_mode & MAY_WRITE)
65423 + reqmode |= GR_WRITE;
65424 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
65425 + reqmode |= GR_READ;
65426 +
65427 + mode =
65428 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65429 + mnt);
65430 +
65431 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65432 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65433 + reqmode & GR_READ ? " reading" : "",
65434 + reqmode & GR_WRITE ? " writing" : reqmode &
65435 + GR_APPEND ? " appending" : "");
65436 + return reqmode;
65437 + } else
65438 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65439 + {
65440 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65441 + reqmode & GR_READ ? " reading" : "",
65442 + reqmode & GR_WRITE ? " writing" : reqmode &
65443 + GR_APPEND ? " appending" : "");
65444 + return 0;
65445 + } else if (unlikely((mode & reqmode) != reqmode))
65446 + return 0;
65447 +
65448 + return reqmode;
65449 +}
65450 +
65451 +__u32
65452 +gr_acl_handle_creat(const struct dentry * dentry,
65453 + const struct dentry * p_dentry,
65454 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65455 + const int imode)
65456 +{
65457 + __u32 reqmode = GR_WRITE | GR_CREATE;
65458 + __u32 mode;
65459 +
65460 + if (acc_mode & MAY_APPEND)
65461 + reqmode |= GR_APPEND;
65462 + // if a directory was required or the directory already exists, then
65463 + // don't count this open as a read
65464 + if ((acc_mode & MAY_READ) &&
65465 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
65466 + reqmode |= GR_READ;
65467 + if ((open_flags & O_CREAT) &&
65468 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
65469 + reqmode |= GR_SETID;
65470 +
65471 + mode =
65472 + gr_check_create(dentry, p_dentry, p_mnt,
65473 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
65474 +
65475 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65476 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65477 + reqmode & GR_READ ? " reading" : "",
65478 + reqmode & GR_WRITE ? " writing" : reqmode &
65479 + GR_APPEND ? " appending" : "");
65480 + return reqmode;
65481 + } else
65482 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65483 + {
65484 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65485 + reqmode & GR_READ ? " reading" : "",
65486 + reqmode & GR_WRITE ? " writing" : reqmode &
65487 + GR_APPEND ? " appending" : "");
65488 + return 0;
65489 + } else if (unlikely((mode & reqmode) != reqmode))
65490 + return 0;
65491 +
65492 + return reqmode;
65493 +}
65494 +
65495 +__u32
65496 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
65497 + const int fmode)
65498 +{
65499 + __u32 mode, reqmode = GR_FIND;
65500 +
65501 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
65502 + reqmode |= GR_EXEC;
65503 + if (fmode & S_IWOTH)
65504 + reqmode |= GR_WRITE;
65505 + if (fmode & S_IROTH)
65506 + reqmode |= GR_READ;
65507 +
65508 + mode =
65509 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65510 + mnt);
65511 +
65512 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65513 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
65514 + reqmode & GR_READ ? " reading" : "",
65515 + reqmode & GR_WRITE ? " writing" : "",
65516 + reqmode & GR_EXEC ? " executing" : "");
65517 + return reqmode;
65518 + } else
65519 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65520 + {
65521 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
65522 + reqmode & GR_READ ? " reading" : "",
65523 + reqmode & GR_WRITE ? " writing" : "",
65524 + reqmode & GR_EXEC ? " executing" : "");
65525 + return 0;
65526 + } else if (unlikely((mode & reqmode) != reqmode))
65527 + return 0;
65528 +
65529 + return reqmode;
65530 +}
65531 +
65532 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
65533 +{
65534 + __u32 mode;
65535 +
65536 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
65537 +
65538 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
65539 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
65540 + return mode;
65541 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
65542 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
65543 + return 0;
65544 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
65545 + return 0;
65546 +
65547 + return (reqmode);
65548 +}
65549 +
65550 +__u32
65551 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
65552 +{
65553 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
65554 +}
65555 +
65556 +__u32
65557 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
65558 +{
65559 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
65560 +}
65561 +
65562 +__u32
65563 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
65564 +{
65565 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
65566 +}
65567 +
65568 +__u32
65569 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
65570 +{
65571 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
65572 +}
65573 +
65574 +__u32
65575 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
65576 + umode_t *modeptr)
65577 +{
65578 + umode_t mode;
65579 +
65580 + *modeptr &= ~gr_acl_umask();
65581 + mode = *modeptr;
65582 +
65583 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
65584 + return 1;
65585 +
65586 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
65587 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
65588 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
65589 + GR_CHMOD_ACL_MSG);
65590 + } else {
65591 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
65592 + }
65593 +}
65594 +
65595 +__u32
65596 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
65597 +{
65598 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
65599 +}
65600 +
65601 +__u32
65602 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
65603 +{
65604 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
65605 +}
65606 +
65607 +__u32
65608 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
65609 +{
65610 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
65611 +}
65612 +
65613 +__u32
65614 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
65615 +{
65616 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
65617 + GR_UNIXCONNECT_ACL_MSG);
65618 +}
65619 +
65620 +/* hardlinks require at minimum create and link permission,
65621 + any additional privilege required is based on the
65622 + privilege of the file being linked to
65623 +*/
65624 +__u32
65625 +gr_acl_handle_link(const struct dentry * new_dentry,
65626 + const struct dentry * parent_dentry,
65627 + const struct vfsmount * parent_mnt,
65628 + const struct dentry * old_dentry,
65629 + const struct vfsmount * old_mnt, const struct filename *to)
65630 +{
65631 + __u32 mode;
65632 + __u32 needmode = GR_CREATE | GR_LINK;
65633 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
65634 +
65635 + mode =
65636 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
65637 + old_mnt);
65638 +
65639 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
65640 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
65641 + return mode;
65642 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
65643 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
65644 + return 0;
65645 + } else if (unlikely((mode & needmode) != needmode))
65646 + return 0;
65647 +
65648 + return 1;
65649 +}
65650 +
65651 +__u32
65652 +gr_acl_handle_symlink(const struct dentry * new_dentry,
65653 + const struct dentry * parent_dentry,
65654 + const struct vfsmount * parent_mnt, const struct filename *from)
65655 +{
65656 + __u32 needmode = GR_WRITE | GR_CREATE;
65657 + __u32 mode;
65658 +
65659 + mode =
65660 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
65661 + GR_CREATE | GR_AUDIT_CREATE |
65662 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
65663 +
65664 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
65665 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
65666 + return mode;
65667 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
65668 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
65669 + return 0;
65670 + } else if (unlikely((mode & needmode) != needmode))
65671 + return 0;
65672 +
65673 + return (GR_WRITE | GR_CREATE);
65674 +}
65675 +
65676 +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)
65677 +{
65678 + __u32 mode;
65679 +
65680 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
65681 +
65682 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
65683 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
65684 + return mode;
65685 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
65686 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
65687 + return 0;
65688 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
65689 + return 0;
65690 +
65691 + return (reqmode);
65692 +}
65693 +
65694 +__u32
65695 +gr_acl_handle_mknod(const struct dentry * new_dentry,
65696 + const struct dentry * parent_dentry,
65697 + const struct vfsmount * parent_mnt,
65698 + const int mode)
65699 +{
65700 + __u32 reqmode = GR_WRITE | GR_CREATE;
65701 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
65702 + reqmode |= GR_SETID;
65703 +
65704 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
65705 + reqmode, GR_MKNOD_ACL_MSG);
65706 +}
65707 +
65708 +__u32
65709 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
65710 + const struct dentry *parent_dentry,
65711 + const struct vfsmount *parent_mnt)
65712 +{
65713 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
65714 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
65715 +}
65716 +
65717 +#define RENAME_CHECK_SUCCESS(old, new) \
65718 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
65719 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
65720 +
65721 +int
65722 +gr_acl_handle_rename(struct dentry *new_dentry,
65723 + struct dentry *parent_dentry,
65724 + const struct vfsmount *parent_mnt,
65725 + struct dentry *old_dentry,
65726 + struct inode *old_parent_inode,
65727 + struct vfsmount *old_mnt, const struct filename *newname)
65728 +{
65729 + __u32 comp1, comp2;
65730 + int error = 0;
65731 +
65732 + if (unlikely(!gr_acl_is_enabled()))
65733 + return 0;
65734 +
65735 + if (!new_dentry->d_inode) {
65736 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
65737 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
65738 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
65739 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
65740 + GR_DELETE | GR_AUDIT_DELETE |
65741 + GR_AUDIT_READ | GR_AUDIT_WRITE |
65742 + GR_SUPPRESS, old_mnt);
65743 + } else {
65744 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
65745 + GR_CREATE | GR_DELETE |
65746 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
65747 + GR_AUDIT_READ | GR_AUDIT_WRITE |
65748 + GR_SUPPRESS, parent_mnt);
65749 + comp2 =
65750 + gr_search_file(old_dentry,
65751 + GR_READ | GR_WRITE | GR_AUDIT_READ |
65752 + GR_DELETE | GR_AUDIT_DELETE |
65753 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
65754 + }
65755 +
65756 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
65757 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
65758 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
65759 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
65760 + && !(comp2 & GR_SUPPRESS)) {
65761 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
65762 + error = -EACCES;
65763 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
65764 + error = -EACCES;
65765 +
65766 + return error;
65767 +}
65768 +
65769 +void
65770 +gr_acl_handle_exit(void)
65771 +{
65772 + u16 id;
65773 + char *rolename;
65774 +
65775 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
65776 + !(current->role->roletype & GR_ROLE_PERSIST))) {
65777 + id = current->acl_role_id;
65778 + rolename = current->role->rolename;
65779 + gr_set_acls(1);
65780 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
65781 + }
65782 +
65783 + gr_put_exec_file(current);
65784 + return;
65785 +}
65786 +
65787 +int
65788 +gr_acl_handle_procpidmem(const struct task_struct *task)
65789 +{
65790 + if (unlikely(!gr_acl_is_enabled()))
65791 + return 0;
65792 +
65793 + if (task != current && task->acl->mode & GR_PROTPROCFD)
65794 + return -EACCES;
65795 +
65796 + return 0;
65797 +}
65798 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
65799 new file mode 100644
65800 index 0000000..f056b81
65801 --- /dev/null
65802 +++ b/grsecurity/gracl_ip.c
65803 @@ -0,0 +1,386 @@
65804 +#include <linux/kernel.h>
65805 +#include <asm/uaccess.h>
65806 +#include <asm/errno.h>
65807 +#include <net/sock.h>
65808 +#include <linux/file.h>
65809 +#include <linux/fs.h>
65810 +#include <linux/net.h>
65811 +#include <linux/in.h>
65812 +#include <linux/skbuff.h>
65813 +#include <linux/ip.h>
65814 +#include <linux/udp.h>
65815 +#include <linux/types.h>
65816 +#include <linux/sched.h>
65817 +#include <linux/netdevice.h>
65818 +#include <linux/inetdevice.h>
65819 +#include <linux/gracl.h>
65820 +#include <linux/grsecurity.h>
65821 +#include <linux/grinternal.h>
65822 +
65823 +#define GR_BIND 0x01
65824 +#define GR_CONNECT 0x02
65825 +#define GR_INVERT 0x04
65826 +#define GR_BINDOVERRIDE 0x08
65827 +#define GR_CONNECTOVERRIDE 0x10
65828 +#define GR_SOCK_FAMILY 0x20
65829 +
65830 +static const char * gr_protocols[IPPROTO_MAX] = {
65831 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
65832 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
65833 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
65834 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
65835 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
65836 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
65837 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
65838 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
65839 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
65840 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
65841 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
65842 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
65843 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
65844 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
65845 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
65846 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
65847 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
65848 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
65849 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
65850 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
65851 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
65852 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
65853 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
65854 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
65855 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
65856 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
65857 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
65858 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
65859 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
65860 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
65861 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
65862 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
65863 + };
65864 +
65865 +static const char * gr_socktypes[SOCK_MAX] = {
65866 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
65867 + "unknown:7", "unknown:8", "unknown:9", "packet"
65868 + };
65869 +
65870 +static const char * gr_sockfamilies[AF_MAX+1] = {
65871 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
65872 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
65873 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
65874 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
65875 + };
65876 +
65877 +const char *
65878 +gr_proto_to_name(unsigned char proto)
65879 +{
65880 + return gr_protocols[proto];
65881 +}
65882 +
65883 +const char *
65884 +gr_socktype_to_name(unsigned char type)
65885 +{
65886 + return gr_socktypes[type];
65887 +}
65888 +
65889 +const char *
65890 +gr_sockfamily_to_name(unsigned char family)
65891 +{
65892 + return gr_sockfamilies[family];
65893 +}
65894 +
65895 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
65896 +
65897 +int
65898 +gr_search_socket(const int domain, const int type, const int protocol)
65899 +{
65900 + struct acl_subject_label *curr;
65901 + const struct cred *cred = current_cred();
65902 +
65903 + if (unlikely(!gr_acl_is_enabled()))
65904 + goto exit;
65905 +
65906 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
65907 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
65908 + goto exit; // let the kernel handle it
65909 +
65910 + curr = current->acl;
65911 +
65912 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
65913 + /* the family is allowed, if this is PF_INET allow it only if
65914 + the extra sock type/protocol checks pass */
65915 + if (domain == PF_INET)
65916 + goto inet_check;
65917 + goto exit;
65918 + } else {
65919 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
65920 + __u32 fakeip = 0;
65921 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65922 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65923 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65924 + gr_to_filename(current->exec_file->f_path.dentry,
65925 + current->exec_file->f_path.mnt) :
65926 + curr->filename, curr->filename,
65927 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
65928 + &current->signal->saved_ip);
65929 + goto exit;
65930 + }
65931 + goto exit_fail;
65932 + }
65933 +
65934 +inet_check:
65935 + /* the rest of this checking is for IPv4 only */
65936 + if (!curr->ips)
65937 + goto exit;
65938 +
65939 + if ((curr->ip_type & (1U << type)) &&
65940 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
65941 + goto exit;
65942 +
65943 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
65944 + /* we don't place acls on raw sockets , and sometimes
65945 + dgram/ip sockets are opened for ioctl and not
65946 + bind/connect, so we'll fake a bind learn log */
65947 + if (type == SOCK_RAW || type == SOCK_PACKET) {
65948 + __u32 fakeip = 0;
65949 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65950 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65951 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65952 + gr_to_filename(current->exec_file->f_path.dentry,
65953 + current->exec_file->f_path.mnt) :
65954 + curr->filename, curr->filename,
65955 + &fakeip, 0, type,
65956 + protocol, GR_CONNECT, &current->signal->saved_ip);
65957 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
65958 + __u32 fakeip = 0;
65959 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65960 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65961 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65962 + gr_to_filename(current->exec_file->f_path.dentry,
65963 + current->exec_file->f_path.mnt) :
65964 + curr->filename, curr->filename,
65965 + &fakeip, 0, type,
65966 + protocol, GR_BIND, &current->signal->saved_ip);
65967 + }
65968 + /* we'll log when they use connect or bind */
65969 + goto exit;
65970 + }
65971 +
65972 +exit_fail:
65973 + if (domain == PF_INET)
65974 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
65975 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
65976 + else if (rcu_access_pointer(net_families[domain]) != NULL)
65977 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
65978 + gr_socktype_to_name(type), protocol);
65979 +
65980 + return 0;
65981 +exit:
65982 + return 1;
65983 +}
65984 +
65985 +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)
65986 +{
65987 + if ((ip->mode & mode) &&
65988 + (ip_port >= ip->low) &&
65989 + (ip_port <= ip->high) &&
65990 + ((ntohl(ip_addr) & our_netmask) ==
65991 + (ntohl(our_addr) & our_netmask))
65992 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
65993 + && (ip->type & (1U << type))) {
65994 + if (ip->mode & GR_INVERT)
65995 + return 2; // specifically denied
65996 + else
65997 + return 1; // allowed
65998 + }
65999 +
66000 + return 0; // not specifically allowed, may continue parsing
66001 +}
66002 +
66003 +static int
66004 +gr_search_connectbind(const int full_mode, struct sock *sk,
66005 + struct sockaddr_in *addr, const int type)
66006 +{
66007 + char iface[IFNAMSIZ] = {0};
66008 + struct acl_subject_label *curr;
66009 + struct acl_ip_label *ip;
66010 + struct inet_sock *isk;
66011 + struct net_device *dev;
66012 + struct in_device *idev;
66013 + unsigned long i;
66014 + int ret;
66015 + int mode = full_mode & (GR_BIND | GR_CONNECT);
66016 + __u32 ip_addr = 0;
66017 + __u32 our_addr;
66018 + __u32 our_netmask;
66019 + char *p;
66020 + __u16 ip_port = 0;
66021 + const struct cred *cred = current_cred();
66022 +
66023 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
66024 + return 0;
66025 +
66026 + curr = current->acl;
66027 + isk = inet_sk(sk);
66028 +
66029 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
66030 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
66031 + addr->sin_addr.s_addr = curr->inaddr_any_override;
66032 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
66033 + struct sockaddr_in saddr;
66034 + int err;
66035 +
66036 + saddr.sin_family = AF_INET;
66037 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
66038 + saddr.sin_port = isk->inet_sport;
66039 +
66040 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66041 + if (err)
66042 + return err;
66043 +
66044 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66045 + if (err)
66046 + return err;
66047 + }
66048 +
66049 + if (!curr->ips)
66050 + return 0;
66051 +
66052 + ip_addr = addr->sin_addr.s_addr;
66053 + ip_port = ntohs(addr->sin_port);
66054 +
66055 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66056 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66057 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66058 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66059 + gr_to_filename(current->exec_file->f_path.dentry,
66060 + current->exec_file->f_path.mnt) :
66061 + curr->filename, curr->filename,
66062 + &ip_addr, ip_port, type,
66063 + sk->sk_protocol, mode, &current->signal->saved_ip);
66064 + return 0;
66065 + }
66066 +
66067 + for (i = 0; i < curr->ip_num; i++) {
66068 + ip = *(curr->ips + i);
66069 + if (ip->iface != NULL) {
66070 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
66071 + p = strchr(iface, ':');
66072 + if (p != NULL)
66073 + *p = '\0';
66074 + dev = dev_get_by_name(sock_net(sk), iface);
66075 + if (dev == NULL)
66076 + continue;
66077 + idev = in_dev_get(dev);
66078 + if (idev == NULL) {
66079 + dev_put(dev);
66080 + continue;
66081 + }
66082 + rcu_read_lock();
66083 + for_ifa(idev) {
66084 + if (!strcmp(ip->iface, ifa->ifa_label)) {
66085 + our_addr = ifa->ifa_address;
66086 + our_netmask = 0xffffffff;
66087 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66088 + if (ret == 1) {
66089 + rcu_read_unlock();
66090 + in_dev_put(idev);
66091 + dev_put(dev);
66092 + return 0;
66093 + } else if (ret == 2) {
66094 + rcu_read_unlock();
66095 + in_dev_put(idev);
66096 + dev_put(dev);
66097 + goto denied;
66098 + }
66099 + }
66100 + } endfor_ifa(idev);
66101 + rcu_read_unlock();
66102 + in_dev_put(idev);
66103 + dev_put(dev);
66104 + } else {
66105 + our_addr = ip->addr;
66106 + our_netmask = ip->netmask;
66107 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66108 + if (ret == 1)
66109 + return 0;
66110 + else if (ret == 2)
66111 + goto denied;
66112 + }
66113 + }
66114 +
66115 +denied:
66116 + if (mode == GR_BIND)
66117 + 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));
66118 + else if (mode == GR_CONNECT)
66119 + 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));
66120 +
66121 + return -EACCES;
66122 +}
66123 +
66124 +int
66125 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
66126 +{
66127 + /* always allow disconnection of dgram sockets with connect */
66128 + if (addr->sin_family == AF_UNSPEC)
66129 + return 0;
66130 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
66131 +}
66132 +
66133 +int
66134 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
66135 +{
66136 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
66137 +}
66138 +
66139 +int gr_search_listen(struct socket *sock)
66140 +{
66141 + struct sock *sk = sock->sk;
66142 + struct sockaddr_in addr;
66143 +
66144 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66145 + addr.sin_port = inet_sk(sk)->inet_sport;
66146 +
66147 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66148 +}
66149 +
66150 +int gr_search_accept(struct socket *sock)
66151 +{
66152 + struct sock *sk = sock->sk;
66153 + struct sockaddr_in addr;
66154 +
66155 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66156 + addr.sin_port = inet_sk(sk)->inet_sport;
66157 +
66158 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66159 +}
66160 +
66161 +int
66162 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
66163 +{
66164 + if (addr)
66165 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
66166 + else {
66167 + struct sockaddr_in sin;
66168 + const struct inet_sock *inet = inet_sk(sk);
66169 +
66170 + sin.sin_addr.s_addr = inet->inet_daddr;
66171 + sin.sin_port = inet->inet_dport;
66172 +
66173 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66174 + }
66175 +}
66176 +
66177 +int
66178 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
66179 +{
66180 + struct sockaddr_in sin;
66181 +
66182 + if (unlikely(skb->len < sizeof (struct udphdr)))
66183 + return 0; // skip this packet
66184 +
66185 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
66186 + sin.sin_port = udp_hdr(skb)->source;
66187 +
66188 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66189 +}
66190 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
66191 new file mode 100644
66192 index 0000000..25f54ef
66193 --- /dev/null
66194 +++ b/grsecurity/gracl_learn.c
66195 @@ -0,0 +1,207 @@
66196 +#include <linux/kernel.h>
66197 +#include <linux/mm.h>
66198 +#include <linux/sched.h>
66199 +#include <linux/poll.h>
66200 +#include <linux/string.h>
66201 +#include <linux/file.h>
66202 +#include <linux/types.h>
66203 +#include <linux/vmalloc.h>
66204 +#include <linux/grinternal.h>
66205 +
66206 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
66207 + size_t count, loff_t *ppos);
66208 +extern int gr_acl_is_enabled(void);
66209 +
66210 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
66211 +static int gr_learn_attached;
66212 +
66213 +/* use a 512k buffer */
66214 +#define LEARN_BUFFER_SIZE (512 * 1024)
66215 +
66216 +static DEFINE_SPINLOCK(gr_learn_lock);
66217 +static DEFINE_MUTEX(gr_learn_user_mutex);
66218 +
66219 +/* we need to maintain two buffers, so that the kernel context of grlearn
66220 + uses a semaphore around the userspace copying, and the other kernel contexts
66221 + use a spinlock when copying into the buffer, since they cannot sleep
66222 +*/
66223 +static char *learn_buffer;
66224 +static char *learn_buffer_user;
66225 +static int learn_buffer_len;
66226 +static int learn_buffer_user_len;
66227 +
66228 +static ssize_t
66229 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
66230 +{
66231 + DECLARE_WAITQUEUE(wait, current);
66232 + ssize_t retval = 0;
66233 +
66234 + add_wait_queue(&learn_wait, &wait);
66235 + set_current_state(TASK_INTERRUPTIBLE);
66236 + do {
66237 + mutex_lock(&gr_learn_user_mutex);
66238 + spin_lock(&gr_learn_lock);
66239 + if (learn_buffer_len)
66240 + break;
66241 + spin_unlock(&gr_learn_lock);
66242 + mutex_unlock(&gr_learn_user_mutex);
66243 + if (file->f_flags & O_NONBLOCK) {
66244 + retval = -EAGAIN;
66245 + goto out;
66246 + }
66247 + if (signal_pending(current)) {
66248 + retval = -ERESTARTSYS;
66249 + goto out;
66250 + }
66251 +
66252 + schedule();
66253 + } while (1);
66254 +
66255 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
66256 + learn_buffer_user_len = learn_buffer_len;
66257 + retval = learn_buffer_len;
66258 + learn_buffer_len = 0;
66259 +
66260 + spin_unlock(&gr_learn_lock);
66261 +
66262 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
66263 + retval = -EFAULT;
66264 +
66265 + mutex_unlock(&gr_learn_user_mutex);
66266 +out:
66267 + set_current_state(TASK_RUNNING);
66268 + remove_wait_queue(&learn_wait, &wait);
66269 + return retval;
66270 +}
66271 +
66272 +static unsigned int
66273 +poll_learn(struct file * file, poll_table * wait)
66274 +{
66275 + poll_wait(file, &learn_wait, wait);
66276 +
66277 + if (learn_buffer_len)
66278 + return (POLLIN | POLLRDNORM);
66279 +
66280 + return 0;
66281 +}
66282 +
66283 +void
66284 +gr_clear_learn_entries(void)
66285 +{
66286 + char *tmp;
66287 +
66288 + mutex_lock(&gr_learn_user_mutex);
66289 + spin_lock(&gr_learn_lock);
66290 + tmp = learn_buffer;
66291 + learn_buffer = NULL;
66292 + spin_unlock(&gr_learn_lock);
66293 + if (tmp)
66294 + vfree(tmp);
66295 + if (learn_buffer_user != NULL) {
66296 + vfree(learn_buffer_user);
66297 + learn_buffer_user = NULL;
66298 + }
66299 + learn_buffer_len = 0;
66300 + mutex_unlock(&gr_learn_user_mutex);
66301 +
66302 + return;
66303 +}
66304 +
66305 +void
66306 +gr_add_learn_entry(const char *fmt, ...)
66307 +{
66308 + va_list args;
66309 + unsigned int len;
66310 +
66311 + if (!gr_learn_attached)
66312 + return;
66313 +
66314 + spin_lock(&gr_learn_lock);
66315 +
66316 + /* leave a gap at the end so we know when it's "full" but don't have to
66317 + compute the exact length of the string we're trying to append
66318 + */
66319 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
66320 + spin_unlock(&gr_learn_lock);
66321 + wake_up_interruptible(&learn_wait);
66322 + return;
66323 + }
66324 + if (learn_buffer == NULL) {
66325 + spin_unlock(&gr_learn_lock);
66326 + return;
66327 + }
66328 +
66329 + va_start(args, fmt);
66330 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
66331 + va_end(args);
66332 +
66333 + learn_buffer_len += len + 1;
66334 +
66335 + spin_unlock(&gr_learn_lock);
66336 + wake_up_interruptible(&learn_wait);
66337 +
66338 + return;
66339 +}
66340 +
66341 +static int
66342 +open_learn(struct inode *inode, struct file *file)
66343 +{
66344 + if (file->f_mode & FMODE_READ && gr_learn_attached)
66345 + return -EBUSY;
66346 + if (file->f_mode & FMODE_READ) {
66347 + int retval = 0;
66348 + mutex_lock(&gr_learn_user_mutex);
66349 + if (learn_buffer == NULL)
66350 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
66351 + if (learn_buffer_user == NULL)
66352 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
66353 + if (learn_buffer == NULL) {
66354 + retval = -ENOMEM;
66355 + goto out_error;
66356 + }
66357 + if (learn_buffer_user == NULL) {
66358 + retval = -ENOMEM;
66359 + goto out_error;
66360 + }
66361 + learn_buffer_len = 0;
66362 + learn_buffer_user_len = 0;
66363 + gr_learn_attached = 1;
66364 +out_error:
66365 + mutex_unlock(&gr_learn_user_mutex);
66366 + return retval;
66367 + }
66368 + return 0;
66369 +}
66370 +
66371 +static int
66372 +close_learn(struct inode *inode, struct file *file)
66373 +{
66374 + if (file->f_mode & FMODE_READ) {
66375 + char *tmp = NULL;
66376 + mutex_lock(&gr_learn_user_mutex);
66377 + spin_lock(&gr_learn_lock);
66378 + tmp = learn_buffer;
66379 + learn_buffer = NULL;
66380 + spin_unlock(&gr_learn_lock);
66381 + if (tmp)
66382 + vfree(tmp);
66383 + if (learn_buffer_user != NULL) {
66384 + vfree(learn_buffer_user);
66385 + learn_buffer_user = NULL;
66386 + }
66387 + learn_buffer_len = 0;
66388 + learn_buffer_user_len = 0;
66389 + gr_learn_attached = 0;
66390 + mutex_unlock(&gr_learn_user_mutex);
66391 + }
66392 +
66393 + return 0;
66394 +}
66395 +
66396 +const struct file_operations grsec_fops = {
66397 + .read = read_learn,
66398 + .write = write_grsec_handler,
66399 + .open = open_learn,
66400 + .release = close_learn,
66401 + .poll = poll_learn,
66402 +};
66403 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
66404 new file mode 100644
66405 index 0000000..d409f33
66406 --- /dev/null
66407 +++ b/grsecurity/gracl_policy.c
66408 @@ -0,0 +1,1825 @@
66409 +#include <linux/kernel.h>
66410 +#include <linux/module.h>
66411 +#include <linux/sched.h>
66412 +#include <linux/mm.h>
66413 +#include <linux/file.h>
66414 +#include <linux/fs.h>
66415 +#include <linux/namei.h>
66416 +#include <linux/mount.h>
66417 +#include <linux/tty.h>
66418 +#include <linux/proc_fs.h>
66419 +#include <linux/lglock.h>
66420 +#include <linux/slab.h>
66421 +#include <linux/vmalloc.h>
66422 +#include <linux/types.h>
66423 +#include <linux/sysctl.h>
66424 +#include <linux/netdevice.h>
66425 +#include <linux/ptrace.h>
66426 +#include <linux/gracl.h>
66427 +#include <linux/gralloc.h>
66428 +#include <linux/security.h>
66429 +#include <linux/grinternal.h>
66430 +#include <linux/pid_namespace.h>
66431 +#include <linux/stop_machine.h>
66432 +#include <linux/fdtable.h>
66433 +#include <linux/percpu.h>
66434 +#include <linux/lglock.h>
66435 +#include <linux/hugetlb.h>
66436 +#include <linux/posix-timers.h>
66437 +#include "../fs/mount.h"
66438 +
66439 +#include <asm/uaccess.h>
66440 +#include <asm/errno.h>
66441 +#include <asm/mman.h>
66442 +
66443 +extern struct gr_policy_state *polstate;
66444 +
66445 +#define FOR_EACH_ROLE_START(role) \
66446 + role = polstate->role_list; \
66447 + while (role) {
66448 +
66449 +#define FOR_EACH_ROLE_END(role) \
66450 + role = role->prev; \
66451 + }
66452 +
66453 +struct path gr_real_root;
66454 +
66455 +extern struct gr_alloc_state *current_alloc_state;
66456 +
66457 +u16 acl_sp_role_value;
66458 +
66459 +static DEFINE_MUTEX(gr_dev_mutex);
66460 +
66461 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
66462 +extern void gr_clear_learn_entries(void);
66463 +
66464 +static struct gr_arg gr_usermode;
66465 +static unsigned char gr_system_salt[GR_SALT_LEN];
66466 +static unsigned char gr_system_sum[GR_SHA_LEN];
66467 +
66468 +static unsigned int gr_auth_attempts = 0;
66469 +static unsigned long gr_auth_expires = 0UL;
66470 +
66471 +struct acl_object_label *fakefs_obj_rw;
66472 +struct acl_object_label *fakefs_obj_rwx;
66473 +
66474 +extern int gr_init_uidset(void);
66475 +extern void gr_free_uidset(void);
66476 +extern void gr_remove_uid(uid_t uid);
66477 +extern int gr_find_uid(uid_t uid);
66478 +
66479 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
66480 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
66481 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
66482 +extern struct acl_role_label *__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid, const gid_t gid);
66483 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
66484 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
66485 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
66486 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
66487 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
66488 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
66489 +extern void assign_special_role(const char *rolename);
66490 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
66491 +extern int gr_rbac_disable(void *unused);
66492 +extern void gr_enable_rbac_system(void);
66493 +
66494 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
66495 +{
66496 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
66497 + return -EFAULT;
66498 +
66499 + return 0;
66500 +}
66501 +
66502 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66503 +{
66504 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
66505 + return -EFAULT;
66506 +
66507 + return 0;
66508 +}
66509 +
66510 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66511 +{
66512 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
66513 + return -EFAULT;
66514 +
66515 + return 0;
66516 +}
66517 +
66518 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
66519 +{
66520 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
66521 + return -EFAULT;
66522 +
66523 + return 0;
66524 +}
66525 +
66526 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66527 +{
66528 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
66529 + return -EFAULT;
66530 +
66531 + return 0;
66532 +}
66533 +
66534 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66535 +{
66536 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
66537 + return -EFAULT;
66538 +
66539 + return 0;
66540 +}
66541 +
66542 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66543 +{
66544 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
66545 + return -EFAULT;
66546 +
66547 + return 0;
66548 +}
66549 +
66550 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
66551 +{
66552 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
66553 + return -EFAULT;
66554 +
66555 + return 0;
66556 +}
66557 +
66558 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
66559 +{
66560 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
66561 + return -EFAULT;
66562 +
66563 + return 0;
66564 +}
66565 +
66566 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
66567 +{
66568 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
66569 + return -EFAULT;
66570 +
66571 + if (((uwrap->version != GRSECURITY_VERSION) &&
66572 + (uwrap->version != 0x2901)) ||
66573 + (uwrap->size != sizeof(struct gr_arg)))
66574 + return -EINVAL;
66575 +
66576 + return 0;
66577 +}
66578 +
66579 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
66580 +{
66581 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
66582 + return -EFAULT;
66583 +
66584 + return 0;
66585 +}
66586 +
66587 +static size_t get_gr_arg_wrapper_size_normal(void)
66588 +{
66589 + return sizeof(struct gr_arg_wrapper);
66590 +}
66591 +
66592 +#ifdef CONFIG_COMPAT
66593 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
66594 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
66595 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
66596 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
66597 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
66598 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
66599 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
66600 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
66601 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
66602 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
66603 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
66604 +extern size_t get_gr_arg_wrapper_size_compat(void);
66605 +
66606 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
66607 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
66608 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
66609 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
66610 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
66611 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
66612 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
66613 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
66614 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
66615 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
66616 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
66617 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
66618 +
66619 +#else
66620 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
66621 +#define copy_gr_arg copy_gr_arg_normal
66622 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
66623 +#define copy_acl_object_label copy_acl_object_label_normal
66624 +#define copy_acl_subject_label copy_acl_subject_label_normal
66625 +#define copy_acl_role_label copy_acl_role_label_normal
66626 +#define copy_acl_ip_label copy_acl_ip_label_normal
66627 +#define copy_pointer_from_array copy_pointer_from_array_normal
66628 +#define copy_sprole_pw copy_sprole_pw_normal
66629 +#define copy_role_transition copy_role_transition_normal
66630 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
66631 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
66632 +#endif
66633 +
66634 +static struct acl_subject_label *
66635 +lookup_subject_map(const struct acl_subject_label *userp)
66636 +{
66637 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
66638 + struct subject_map *match;
66639 +
66640 + match = polstate->subj_map_set.s_hash[index];
66641 +
66642 + while (match && match->user != userp)
66643 + match = match->next;
66644 +
66645 + if (match != NULL)
66646 + return match->kernel;
66647 + else
66648 + return NULL;
66649 +}
66650 +
66651 +static void
66652 +insert_subj_map_entry(struct subject_map *subjmap)
66653 +{
66654 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
66655 + struct subject_map **curr;
66656 +
66657 + subjmap->prev = NULL;
66658 +
66659 + curr = &polstate->subj_map_set.s_hash[index];
66660 + if (*curr != NULL)
66661 + (*curr)->prev = subjmap;
66662 +
66663 + subjmap->next = *curr;
66664 + *curr = subjmap;
66665 +
66666 + return;
66667 +}
66668 +
66669 +static void
66670 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
66671 +{
66672 + unsigned int index =
66673 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
66674 + struct acl_role_label **curr;
66675 + struct acl_role_label *tmp, *tmp2;
66676 +
66677 + curr = &polstate->acl_role_set.r_hash[index];
66678 +
66679 + /* simple case, slot is empty, just set it to our role */
66680 + if (*curr == NULL) {
66681 + *curr = role;
66682 + } else {
66683 + /* example:
66684 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
66685 + 2 -> 3
66686 + */
66687 + /* first check to see if we can already be reached via this slot */
66688 + tmp = *curr;
66689 + while (tmp && tmp != role)
66690 + tmp = tmp->next;
66691 + if (tmp == role) {
66692 + /* we don't need to add ourselves to this slot's chain */
66693 + return;
66694 + }
66695 + /* we need to add ourselves to this chain, two cases */
66696 + if (role->next == NULL) {
66697 + /* simple case, append the current chain to our role */
66698 + role->next = *curr;
66699 + *curr = role;
66700 + } else {
66701 + /* 1 -> 2 -> 3 -> 4
66702 + 2 -> 3 -> 4
66703 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
66704 + */
66705 + /* trickier case: walk our role's chain until we find
66706 + the role for the start of the current slot's chain */
66707 + tmp = role;
66708 + tmp2 = *curr;
66709 + while (tmp->next && tmp->next != tmp2)
66710 + tmp = tmp->next;
66711 + if (tmp->next == tmp2) {
66712 + /* from example above, we found 3, so just
66713 + replace this slot's chain with ours */
66714 + *curr = role;
66715 + } else {
66716 + /* we didn't find a subset of our role's chain
66717 + in the current slot's chain, so append their
66718 + chain to ours, and set us as the first role in
66719 + the slot's chain
66720 +
66721 + we could fold this case with the case above,
66722 + but making it explicit for clarity
66723 + */
66724 + tmp->next = tmp2;
66725 + *curr = role;
66726 + }
66727 + }
66728 + }
66729 +
66730 + return;
66731 +}
66732 +
66733 +static void
66734 +insert_acl_role_label(struct acl_role_label *role)
66735 +{
66736 + int i;
66737 +
66738 + if (polstate->role_list == NULL) {
66739 + polstate->role_list = role;
66740 + role->prev = NULL;
66741 + } else {
66742 + role->prev = polstate->role_list;
66743 + polstate->role_list = role;
66744 + }
66745 +
66746 + /* used for hash chains */
66747 + role->next = NULL;
66748 +
66749 + if (role->roletype & GR_ROLE_DOMAIN) {
66750 + for (i = 0; i < role->domain_child_num; i++)
66751 + __insert_acl_role_label(role, role->domain_children[i]);
66752 + } else
66753 + __insert_acl_role_label(role, role->uidgid);
66754 +}
66755 +
66756 +static int
66757 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
66758 +{
66759 + struct name_entry **curr, *nentry;
66760 + struct inodev_entry *ientry;
66761 + unsigned int len = strlen(name);
66762 + unsigned int key = full_name_hash(name, len);
66763 + unsigned int index = key % polstate->name_set.n_size;
66764 +
66765 + curr = &polstate->name_set.n_hash[index];
66766 +
66767 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
66768 + curr = &((*curr)->next);
66769 +
66770 + if (*curr != NULL)
66771 + return 1;
66772 +
66773 + nentry = acl_alloc(sizeof (struct name_entry));
66774 + if (nentry == NULL)
66775 + return 0;
66776 + ientry = acl_alloc(sizeof (struct inodev_entry));
66777 + if (ientry == NULL)
66778 + return 0;
66779 + ientry->nentry = nentry;
66780 +
66781 + nentry->key = key;
66782 + nentry->name = name;
66783 + nentry->inode = inode;
66784 + nentry->device = device;
66785 + nentry->len = len;
66786 + nentry->deleted = deleted;
66787 +
66788 + nentry->prev = NULL;
66789 + curr = &polstate->name_set.n_hash[index];
66790 + if (*curr != NULL)
66791 + (*curr)->prev = nentry;
66792 + nentry->next = *curr;
66793 + *curr = nentry;
66794 +
66795 + /* insert us into the table searchable by inode/dev */
66796 + __insert_inodev_entry(polstate, ientry);
66797 +
66798 + return 1;
66799 +}
66800 +
66801 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
66802 +
66803 +static void *
66804 +create_table(__u32 * len, int elementsize)
66805 +{
66806 + unsigned int table_sizes[] = {
66807 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
66808 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
66809 + 4194301, 8388593, 16777213, 33554393, 67108859
66810 + };
66811 + void *newtable = NULL;
66812 + unsigned int pwr = 0;
66813 +
66814 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
66815 + table_sizes[pwr] <= *len)
66816 + pwr++;
66817 +
66818 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
66819 + return newtable;
66820 +
66821 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
66822 + newtable =
66823 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
66824 + else
66825 + newtable = vmalloc(table_sizes[pwr] * elementsize);
66826 +
66827 + *len = table_sizes[pwr];
66828 +
66829 + return newtable;
66830 +}
66831 +
66832 +static int
66833 +init_variables(const struct gr_arg *arg, bool reload)
66834 +{
66835 + struct task_struct *reaper = init_pid_ns.child_reaper;
66836 + unsigned int stacksize;
66837 +
66838 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
66839 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
66840 + polstate->name_set.n_size = arg->role_db.num_objects;
66841 + polstate->inodev_set.i_size = arg->role_db.num_objects;
66842 +
66843 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
66844 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
66845 + return 1;
66846 +
66847 + if (!reload) {
66848 + if (!gr_init_uidset())
66849 + return 1;
66850 + }
66851 +
66852 + /* set up the stack that holds allocation info */
66853 +
66854 + stacksize = arg->role_db.num_pointers + 5;
66855 +
66856 + if (!acl_alloc_stack_init(stacksize))
66857 + return 1;
66858 +
66859 + if (!reload) {
66860 + /* grab reference for the real root dentry and vfsmount */
66861 + get_fs_root(reaper->fs, &gr_real_root);
66862 +
66863 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66864 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(gr_real_root.dentry), gr_real_root.dentry->d_inode->i_ino);
66865 +#endif
66866 +
66867 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
66868 + if (fakefs_obj_rw == NULL)
66869 + return 1;
66870 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
66871 +
66872 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
66873 + if (fakefs_obj_rwx == NULL)
66874 + return 1;
66875 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
66876 + }
66877 +
66878 + polstate->subj_map_set.s_hash =
66879 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
66880 + polstate->acl_role_set.r_hash =
66881 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
66882 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
66883 + polstate->inodev_set.i_hash =
66884 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
66885 +
66886 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
66887 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
66888 + return 1;
66889 +
66890 + memset(polstate->subj_map_set.s_hash, 0,
66891 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
66892 + memset(polstate->acl_role_set.r_hash, 0,
66893 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
66894 + memset(polstate->name_set.n_hash, 0,
66895 + sizeof (struct name_entry *) * polstate->name_set.n_size);
66896 + memset(polstate->inodev_set.i_hash, 0,
66897 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
66898 +
66899 + return 0;
66900 +}
66901 +
66902 +/* free information not needed after startup
66903 + currently contains user->kernel pointer mappings for subjects
66904 +*/
66905 +
66906 +static void
66907 +free_init_variables(void)
66908 +{
66909 + __u32 i;
66910 +
66911 + if (polstate->subj_map_set.s_hash) {
66912 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
66913 + if (polstate->subj_map_set.s_hash[i]) {
66914 + kfree(polstate->subj_map_set.s_hash[i]);
66915 + polstate->subj_map_set.s_hash[i] = NULL;
66916 + }
66917 + }
66918 +
66919 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
66920 + PAGE_SIZE)
66921 + kfree(polstate->subj_map_set.s_hash);
66922 + else
66923 + vfree(polstate->subj_map_set.s_hash);
66924 + }
66925 +
66926 + return;
66927 +}
66928 +
66929 +static void
66930 +free_variables(bool reload)
66931 +{
66932 + struct acl_subject_label *s;
66933 + struct acl_role_label *r;
66934 + struct task_struct *task, *task2;
66935 + unsigned int x;
66936 +
66937 + if (!reload) {
66938 + gr_clear_learn_entries();
66939 +
66940 + read_lock(&tasklist_lock);
66941 + do_each_thread(task2, task) {
66942 + task->acl_sp_role = 0;
66943 + task->acl_role_id = 0;
66944 + task->inherited = 0;
66945 + task->acl = NULL;
66946 + task->role = NULL;
66947 + } while_each_thread(task2, task);
66948 + read_unlock(&tasklist_lock);
66949 +
66950 + /* release the reference to the real root dentry and vfsmount */
66951 + path_put(&gr_real_root);
66952 + memset(&gr_real_root, 0, sizeof(gr_real_root));
66953 + }
66954 +
66955 + /* free all object hash tables */
66956 +
66957 + FOR_EACH_ROLE_START(r)
66958 + if (r->subj_hash == NULL)
66959 + goto next_role;
66960 + FOR_EACH_SUBJECT_START(r, s, x)
66961 + if (s->obj_hash == NULL)
66962 + break;
66963 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
66964 + kfree(s->obj_hash);
66965 + else
66966 + vfree(s->obj_hash);
66967 + FOR_EACH_SUBJECT_END(s, x)
66968 + FOR_EACH_NESTED_SUBJECT_START(r, s)
66969 + if (s->obj_hash == NULL)
66970 + break;
66971 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
66972 + kfree(s->obj_hash);
66973 + else
66974 + vfree(s->obj_hash);
66975 + FOR_EACH_NESTED_SUBJECT_END(s)
66976 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
66977 + kfree(r->subj_hash);
66978 + else
66979 + vfree(r->subj_hash);
66980 + r->subj_hash = NULL;
66981 +next_role:
66982 + FOR_EACH_ROLE_END(r)
66983 +
66984 + acl_free_all();
66985 +
66986 + if (polstate->acl_role_set.r_hash) {
66987 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
66988 + PAGE_SIZE)
66989 + kfree(polstate->acl_role_set.r_hash);
66990 + else
66991 + vfree(polstate->acl_role_set.r_hash);
66992 + }
66993 + if (polstate->name_set.n_hash) {
66994 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
66995 + PAGE_SIZE)
66996 + kfree(polstate->name_set.n_hash);
66997 + else
66998 + vfree(polstate->name_set.n_hash);
66999 + }
67000 +
67001 + if (polstate->inodev_set.i_hash) {
67002 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
67003 + PAGE_SIZE)
67004 + kfree(polstate->inodev_set.i_hash);
67005 + else
67006 + vfree(polstate->inodev_set.i_hash);
67007 + }
67008 +
67009 + if (!reload)
67010 + gr_free_uidset();
67011 +
67012 + memset(&polstate->name_set, 0, sizeof (struct name_db));
67013 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
67014 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
67015 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
67016 +
67017 + polstate->default_role = NULL;
67018 + polstate->kernel_role = NULL;
67019 + polstate->role_list = NULL;
67020 +
67021 + return;
67022 +}
67023 +
67024 +static struct acl_subject_label *
67025 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
67026 +
67027 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
67028 +{
67029 + unsigned int len = strnlen_user(*name, maxlen);
67030 + char *tmp;
67031 +
67032 + if (!len || len >= maxlen)
67033 + return -EINVAL;
67034 +
67035 + if ((tmp = (char *) acl_alloc(len)) == NULL)
67036 + return -ENOMEM;
67037 +
67038 + if (copy_from_user(tmp, *name, len))
67039 + return -EFAULT;
67040 +
67041 + tmp[len-1] = '\0';
67042 + *name = tmp;
67043 +
67044 + return 0;
67045 +}
67046 +
67047 +static int
67048 +copy_user_glob(struct acl_object_label *obj)
67049 +{
67050 + struct acl_object_label *g_tmp, **guser;
67051 + int error;
67052 +
67053 + if (obj->globbed == NULL)
67054 + return 0;
67055 +
67056 + guser = &obj->globbed;
67057 + while (*guser) {
67058 + g_tmp = (struct acl_object_label *)
67059 + acl_alloc(sizeof (struct acl_object_label));
67060 + if (g_tmp == NULL)
67061 + return -ENOMEM;
67062 +
67063 + if (copy_acl_object_label(g_tmp, *guser))
67064 + return -EFAULT;
67065 +
67066 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
67067 + if (error)
67068 + return error;
67069 +
67070 + *guser = g_tmp;
67071 + guser = &(g_tmp->next);
67072 + }
67073 +
67074 + return 0;
67075 +}
67076 +
67077 +static int
67078 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
67079 + struct acl_role_label *role)
67080 +{
67081 + struct acl_object_label *o_tmp;
67082 + int ret;
67083 +
67084 + while (userp) {
67085 + if ((o_tmp = (struct acl_object_label *)
67086 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
67087 + return -ENOMEM;
67088 +
67089 + if (copy_acl_object_label(o_tmp, userp))
67090 + return -EFAULT;
67091 +
67092 + userp = o_tmp->prev;
67093 +
67094 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
67095 + if (ret)
67096 + return ret;
67097 +
67098 + insert_acl_obj_label(o_tmp, subj);
67099 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
67100 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
67101 + return -ENOMEM;
67102 +
67103 + ret = copy_user_glob(o_tmp);
67104 + if (ret)
67105 + return ret;
67106 +
67107 + if (o_tmp->nested) {
67108 + int already_copied;
67109 +
67110 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
67111 + if (IS_ERR(o_tmp->nested))
67112 + return PTR_ERR(o_tmp->nested);
67113 +
67114 + /* insert into nested subject list if we haven't copied this one yet
67115 + to prevent duplicate entries */
67116 + if (!already_copied) {
67117 + o_tmp->nested->next = role->hash->first;
67118 + role->hash->first = o_tmp->nested;
67119 + }
67120 + }
67121 + }
67122 +
67123 + return 0;
67124 +}
67125 +
67126 +static __u32
67127 +count_user_subjs(struct acl_subject_label *userp)
67128 +{
67129 + struct acl_subject_label s_tmp;
67130 + __u32 num = 0;
67131 +
67132 + while (userp) {
67133 + if (copy_acl_subject_label(&s_tmp, userp))
67134 + break;
67135 +
67136 + userp = s_tmp.prev;
67137 + }
67138 +
67139 + return num;
67140 +}
67141 +
67142 +static int
67143 +copy_user_allowedips(struct acl_role_label *rolep)
67144 +{
67145 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
67146 +
67147 + ruserip = rolep->allowed_ips;
67148 +
67149 + while (ruserip) {
67150 + rlast = rtmp;
67151 +
67152 + if ((rtmp = (struct role_allowed_ip *)
67153 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
67154 + return -ENOMEM;
67155 +
67156 + if (copy_role_allowed_ip(rtmp, ruserip))
67157 + return -EFAULT;
67158 +
67159 + ruserip = rtmp->prev;
67160 +
67161 + if (!rlast) {
67162 + rtmp->prev = NULL;
67163 + rolep->allowed_ips = rtmp;
67164 + } else {
67165 + rlast->next = rtmp;
67166 + rtmp->prev = rlast;
67167 + }
67168 +
67169 + if (!ruserip)
67170 + rtmp->next = NULL;
67171 + }
67172 +
67173 + return 0;
67174 +}
67175 +
67176 +static int
67177 +copy_user_transitions(struct acl_role_label *rolep)
67178 +{
67179 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
67180 + int error;
67181 +
67182 + rusertp = rolep->transitions;
67183 +
67184 + while (rusertp) {
67185 + rlast = rtmp;
67186 +
67187 + if ((rtmp = (struct role_transition *)
67188 + acl_alloc(sizeof (struct role_transition))) == NULL)
67189 + return -ENOMEM;
67190 +
67191 + if (copy_role_transition(rtmp, rusertp))
67192 + return -EFAULT;
67193 +
67194 + rusertp = rtmp->prev;
67195 +
67196 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
67197 + if (error)
67198 + return error;
67199 +
67200 + if (!rlast) {
67201 + rtmp->prev = NULL;
67202 + rolep->transitions = rtmp;
67203 + } else {
67204 + rlast->next = rtmp;
67205 + rtmp->prev = rlast;
67206 + }
67207 +
67208 + if (!rusertp)
67209 + rtmp->next = NULL;
67210 + }
67211 +
67212 + return 0;
67213 +}
67214 +
67215 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
67216 +{
67217 + struct acl_object_label o_tmp;
67218 + __u32 num = 0;
67219 +
67220 + while (userp) {
67221 + if (copy_acl_object_label(&o_tmp, userp))
67222 + break;
67223 +
67224 + userp = o_tmp.prev;
67225 + num++;
67226 + }
67227 +
67228 + return num;
67229 +}
67230 +
67231 +static struct acl_subject_label *
67232 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
67233 +{
67234 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
67235 + __u32 num_objs;
67236 + struct acl_ip_label **i_tmp, *i_utmp2;
67237 + struct gr_hash_struct ghash;
67238 + struct subject_map *subjmap;
67239 + unsigned int i_num;
67240 + int err;
67241 +
67242 + if (already_copied != NULL)
67243 + *already_copied = 0;
67244 +
67245 + s_tmp = lookup_subject_map(userp);
67246 +
67247 + /* we've already copied this subject into the kernel, just return
67248 + the reference to it, and don't copy it over again
67249 + */
67250 + if (s_tmp) {
67251 + if (already_copied != NULL)
67252 + *already_copied = 1;
67253 + return(s_tmp);
67254 + }
67255 +
67256 + if ((s_tmp = (struct acl_subject_label *)
67257 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
67258 + return ERR_PTR(-ENOMEM);
67259 +
67260 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
67261 + if (subjmap == NULL)
67262 + return ERR_PTR(-ENOMEM);
67263 +
67264 + subjmap->user = userp;
67265 + subjmap->kernel = s_tmp;
67266 + insert_subj_map_entry(subjmap);
67267 +
67268 + if (copy_acl_subject_label(s_tmp, userp))
67269 + return ERR_PTR(-EFAULT);
67270 +
67271 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
67272 + if (err)
67273 + return ERR_PTR(err);
67274 +
67275 + if (!strcmp(s_tmp->filename, "/"))
67276 + role->root_label = s_tmp;
67277 +
67278 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
67279 + return ERR_PTR(-EFAULT);
67280 +
67281 + /* copy user and group transition tables */
67282 +
67283 + if (s_tmp->user_trans_num) {
67284 + uid_t *uidlist;
67285 +
67286 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
67287 + if (uidlist == NULL)
67288 + return ERR_PTR(-ENOMEM);
67289 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
67290 + return ERR_PTR(-EFAULT);
67291 +
67292 + s_tmp->user_transitions = uidlist;
67293 + }
67294 +
67295 + if (s_tmp->group_trans_num) {
67296 + gid_t *gidlist;
67297 +
67298 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
67299 + if (gidlist == NULL)
67300 + return ERR_PTR(-ENOMEM);
67301 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
67302 + return ERR_PTR(-EFAULT);
67303 +
67304 + s_tmp->group_transitions = gidlist;
67305 + }
67306 +
67307 + /* set up object hash table */
67308 + num_objs = count_user_objs(ghash.first);
67309 +
67310 + s_tmp->obj_hash_size = num_objs;
67311 + s_tmp->obj_hash =
67312 + (struct acl_object_label **)
67313 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
67314 +
67315 + if (!s_tmp->obj_hash)
67316 + return ERR_PTR(-ENOMEM);
67317 +
67318 + memset(s_tmp->obj_hash, 0,
67319 + s_tmp->obj_hash_size *
67320 + sizeof (struct acl_object_label *));
67321 +
67322 + /* add in objects */
67323 + err = copy_user_objs(ghash.first, s_tmp, role);
67324 +
67325 + if (err)
67326 + return ERR_PTR(err);
67327 +
67328 + /* set pointer for parent subject */
67329 + if (s_tmp->parent_subject) {
67330 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
67331 +
67332 + if (IS_ERR(s_tmp2))
67333 + return s_tmp2;
67334 +
67335 + s_tmp->parent_subject = s_tmp2;
67336 + }
67337 +
67338 + /* add in ip acls */
67339 +
67340 + if (!s_tmp->ip_num) {
67341 + s_tmp->ips = NULL;
67342 + goto insert;
67343 + }
67344 +
67345 + i_tmp =
67346 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
67347 + sizeof (struct acl_ip_label *));
67348 +
67349 + if (!i_tmp)
67350 + return ERR_PTR(-ENOMEM);
67351 +
67352 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
67353 + *(i_tmp + i_num) =
67354 + (struct acl_ip_label *)
67355 + acl_alloc(sizeof (struct acl_ip_label));
67356 + if (!*(i_tmp + i_num))
67357 + return ERR_PTR(-ENOMEM);
67358 +
67359 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
67360 + return ERR_PTR(-EFAULT);
67361 +
67362 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
67363 + return ERR_PTR(-EFAULT);
67364 +
67365 + if ((*(i_tmp + i_num))->iface == NULL)
67366 + continue;
67367 +
67368 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
67369 + if (err)
67370 + return ERR_PTR(err);
67371 + }
67372 +
67373 + s_tmp->ips = i_tmp;
67374 +
67375 +insert:
67376 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
67377 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
67378 + return ERR_PTR(-ENOMEM);
67379 +
67380 + return s_tmp;
67381 +}
67382 +
67383 +static int
67384 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
67385 +{
67386 + struct acl_subject_label s_pre;
67387 + struct acl_subject_label * ret;
67388 + int err;
67389 +
67390 + while (userp) {
67391 + if (copy_acl_subject_label(&s_pre, userp))
67392 + return -EFAULT;
67393 +
67394 + ret = do_copy_user_subj(userp, role, NULL);
67395 +
67396 + err = PTR_ERR(ret);
67397 + if (IS_ERR(ret))
67398 + return err;
67399 +
67400 + insert_acl_subj_label(ret, role);
67401 +
67402 + userp = s_pre.prev;
67403 + }
67404 +
67405 + return 0;
67406 +}
67407 +
67408 +static int
67409 +copy_user_acl(struct gr_arg *arg)
67410 +{
67411 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
67412 + struct acl_subject_label *subj_list;
67413 + struct sprole_pw *sptmp;
67414 + struct gr_hash_struct *ghash;
67415 + uid_t *domainlist;
67416 + unsigned int r_num;
67417 + int err = 0;
67418 + __u16 i;
67419 + __u32 num_subjs;
67420 +
67421 + /* we need a default and kernel role */
67422 + if (arg->role_db.num_roles < 2)
67423 + return -EINVAL;
67424 +
67425 + /* copy special role authentication info from userspace */
67426 +
67427 + polstate->num_sprole_pws = arg->num_sprole_pws;
67428 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
67429 +
67430 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
67431 + return -ENOMEM;
67432 +
67433 + for (i = 0; i < polstate->num_sprole_pws; i++) {
67434 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
67435 + if (!sptmp)
67436 + return -ENOMEM;
67437 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
67438 + return -EFAULT;
67439 +
67440 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
67441 + if (err)
67442 + return err;
67443 +
67444 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67445 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
67446 +#endif
67447 +
67448 + polstate->acl_special_roles[i] = sptmp;
67449 + }
67450 +
67451 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
67452 +
67453 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
67454 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
67455 +
67456 + if (!r_tmp)
67457 + return -ENOMEM;
67458 +
67459 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
67460 + return -EFAULT;
67461 +
67462 + if (copy_acl_role_label(r_tmp, r_utmp2))
67463 + return -EFAULT;
67464 +
67465 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
67466 + if (err)
67467 + return err;
67468 +
67469 + if (!strcmp(r_tmp->rolename, "default")
67470 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
67471 + polstate->default_role = r_tmp;
67472 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
67473 + polstate->kernel_role = r_tmp;
67474 + }
67475 +
67476 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
67477 + return -ENOMEM;
67478 +
67479 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
67480 + return -EFAULT;
67481 +
67482 + r_tmp->hash = ghash;
67483 +
67484 + num_subjs = count_user_subjs(r_tmp->hash->first);
67485 +
67486 + r_tmp->subj_hash_size = num_subjs;
67487 + r_tmp->subj_hash =
67488 + (struct acl_subject_label **)
67489 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
67490 +
67491 + if (!r_tmp->subj_hash)
67492 + return -ENOMEM;
67493 +
67494 + err = copy_user_allowedips(r_tmp);
67495 + if (err)
67496 + return err;
67497 +
67498 + /* copy domain info */
67499 + if (r_tmp->domain_children != NULL) {
67500 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
67501 + if (domainlist == NULL)
67502 + return -ENOMEM;
67503 +
67504 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
67505 + return -EFAULT;
67506 +
67507 + r_tmp->domain_children = domainlist;
67508 + }
67509 +
67510 + err = copy_user_transitions(r_tmp);
67511 + if (err)
67512 + return err;
67513 +
67514 + memset(r_tmp->subj_hash, 0,
67515 + r_tmp->subj_hash_size *
67516 + sizeof (struct acl_subject_label *));
67517 +
67518 + /* acquire the list of subjects, then NULL out
67519 + the list prior to parsing the subjects for this role,
67520 + as during this parsing the list is replaced with a list
67521 + of *nested* subjects for the role
67522 + */
67523 + subj_list = r_tmp->hash->first;
67524 +
67525 + /* set nested subject list to null */
67526 + r_tmp->hash->first = NULL;
67527 +
67528 + err = copy_user_subjs(subj_list, r_tmp);
67529 +
67530 + if (err)
67531 + return err;
67532 +
67533 + insert_acl_role_label(r_tmp);
67534 + }
67535 +
67536 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
67537 + return -EINVAL;
67538 +
67539 + return err;
67540 +}
67541 +
67542 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
67543 +{
67544 + char *tmpname;
67545 + struct acl_subject_label *tmpsubj;
67546 + struct file *filp;
67547 + struct name_entry *nmatch;
67548 +
67549 + filp = task->exec_file;
67550 + if (filp == NULL)
67551 + return NULL;
67552 +
67553 + /* the following is to apply the correct subject
67554 + on binaries running when the RBAC system
67555 + is enabled, when the binaries have been
67556 + replaced or deleted since their execution
67557 + -----
67558 + when the RBAC system starts, the inode/dev
67559 + from exec_file will be one the RBAC system
67560 + is unaware of. It only knows the inode/dev
67561 + of the present file on disk, or the absence
67562 + of it.
67563 + */
67564 +
67565 + if (filename)
67566 + nmatch = __lookup_name_entry(polstate, filename);
67567 + else {
67568 + preempt_disable();
67569 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
67570 +
67571 + nmatch = __lookup_name_entry(polstate, tmpname);
67572 + preempt_enable();
67573 + }
67574 + tmpsubj = NULL;
67575 + if (nmatch) {
67576 + if (nmatch->deleted)
67577 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
67578 + else
67579 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
67580 + }
67581 + /* this also works for the reload case -- if we don't match a potentially inherited subject
67582 + then we fall back to a normal lookup based on the binary's ino/dev
67583 + */
67584 + if (tmpsubj == NULL)
67585 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
67586 + task->role);
67587 +
67588 + return tmpsubj;
67589 +}
67590 +
67591 +static int gracl_reload_apply_policies(void *reload)
67592 +{
67593 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
67594 + struct task_struct *task, *task2;
67595 + struct acl_role_label *role, *rtmp;
67596 + struct acl_subject_label *subj;
67597 + const struct cred *cred;
67598 + int role_applied;
67599 + int ret = 0;
67600 +
67601 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_reload_state));
67602 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
67603 +
67604 + /* first make sure we'll be able to apply the new policy cleanly */
67605 + do_each_thread(task2, task) {
67606 + if (task->exec_file == NULL)
67607 + continue;
67608 + role_applied = 0;
67609 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
67610 + /* preserve special roles */
67611 + FOR_EACH_ROLE_START(role)
67612 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
67613 + rtmp = task->role;
67614 + task->role = role;
67615 + role_applied = 1;
67616 + break;
67617 + }
67618 + FOR_EACH_ROLE_END(role)
67619 + }
67620 + if (!role_applied) {
67621 + cred = __task_cred(task);
67622 + rtmp = task->role;
67623 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
67624 + }
67625 + /* this handles non-nested inherited subjects, nested subjects will still
67626 + be dropped currently */
67627 + subj = gr_get_subject_for_task(task, task->acl->filename);
67628 + task->tmpacl = gr_get_subject_for_task(task, NULL);
67629 + /* change the role back so that we've made no modifications to the policy */
67630 + task->role = rtmp;
67631 +
67632 + if (subj == NULL || task->tmpacl == NULL) {
67633 + ret = -EINVAL;
67634 + goto out;
67635 + }
67636 + } while_each_thread(task2, task);
67637 +
67638 + /* now actually apply the policy */
67639 +
67640 + do_each_thread(task2, task) {
67641 + if (task->exec_file) {
67642 + role_applied = 0;
67643 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
67644 + /* preserve special roles */
67645 + FOR_EACH_ROLE_START(role)
67646 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
67647 + task->role = role;
67648 + role_applied = 1;
67649 + break;
67650 + }
67651 + FOR_EACH_ROLE_END(role)
67652 + }
67653 + if (!role_applied) {
67654 + cred = __task_cred(task);
67655 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
67656 + }
67657 + /* this handles non-nested inherited subjects, nested subjects will still
67658 + be dropped currently */
67659 + if (!reload_state->oldmode && task->inherited)
67660 + subj = gr_get_subject_for_task(task, task->acl->filename);
67661 + else {
67662 + /* looked up and tagged to the task previously */
67663 + subj = task->tmpacl;
67664 + }
67665 + /* subj will be non-null */
67666 + __gr_apply_subject_to_task(polstate, task, subj);
67667 + if (reload_state->oldmode) {
67668 + task->acl_role_id = 0;
67669 + task->acl_sp_role = 0;
67670 + task->inherited = 0;
67671 + }
67672 + } else {
67673 + // it's a kernel process
67674 + task->role = polstate->kernel_role;
67675 + task->acl = polstate->kernel_role->root_label;
67676 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
67677 + task->acl->mode &= ~GR_PROCFIND;
67678 +#endif
67679 + }
67680 + } while_each_thread(task2, task);
67681 +
67682 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
67683 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
67684 +
67685 +out:
67686 +
67687 + return ret;
67688 +}
67689 +
67690 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
67691 +{
67692 + struct gr_reload_state new_reload_state = { };
67693 + int err;
67694 +
67695 + new_reload_state.oldpolicy_ptr = polstate;
67696 + new_reload_state.oldalloc_ptr = current_alloc_state;
67697 + new_reload_state.oldmode = oldmode;
67698 +
67699 + current_alloc_state = &new_reload_state.newalloc;
67700 + polstate = &new_reload_state.newpolicy;
67701 +
67702 + /* everything relevant is now saved off, copy in the new policy */
67703 + if (init_variables(args, true)) {
67704 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
67705 + err = -ENOMEM;
67706 + goto error;
67707 + }
67708 +
67709 + err = copy_user_acl(args);
67710 + free_init_variables();
67711 + if (err)
67712 + goto error;
67713 + /* the new policy is copied in, with the old policy available via saved_state
67714 + first go through applying roles, making sure to preserve special roles
67715 + then apply new subjects, making sure to preserve inherited and nested subjects,
67716 + though currently only inherited subjects will be preserved
67717 + */
67718 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
67719 + if (err)
67720 + goto error;
67721 +
67722 + /* we've now applied the new policy, so restore the old policy state to free it */
67723 + polstate = &new_reload_state.oldpolicy;
67724 + current_alloc_state = &new_reload_state.oldalloc;
67725 + free_variables(true);
67726 +
67727 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
67728 + to running_polstate/current_alloc_state inside stop_machine
67729 + */
67730 + err = 0;
67731 + goto out;
67732 +error:
67733 + /* on error of loading the new policy, we'll just keep the previous
67734 + policy set around
67735 + */
67736 + free_variables(true);
67737 +
67738 + /* doesn't affect runtime, but maintains consistent state */
67739 +out:
67740 + polstate = new_reload_state.oldpolicy_ptr;
67741 + current_alloc_state = new_reload_state.oldalloc_ptr;
67742 +
67743 + return err;
67744 +}
67745 +
67746 +static int
67747 +gracl_init(struct gr_arg *args)
67748 +{
67749 + int error = 0;
67750 +
67751 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
67752 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
67753 +
67754 + if (init_variables(args, false)) {
67755 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
67756 + error = -ENOMEM;
67757 + goto out;
67758 + }
67759 +
67760 + error = copy_user_acl(args);
67761 + free_init_variables();
67762 + if (error)
67763 + goto out;
67764 +
67765 + error = gr_set_acls(0);
67766 + if (error)
67767 + goto out;
67768 +
67769 + gr_enable_rbac_system();
67770 +
67771 + return 0;
67772 +
67773 +out:
67774 + free_variables(false);
67775 + return error;
67776 +}
67777 +
67778 +static int
67779 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
67780 + unsigned char **sum)
67781 +{
67782 + struct acl_role_label *r;
67783 + struct role_allowed_ip *ipp;
67784 + struct role_transition *trans;
67785 + unsigned int i;
67786 + int found = 0;
67787 + u32 curr_ip = current->signal->curr_ip;
67788 +
67789 + current->signal->saved_ip = curr_ip;
67790 +
67791 + /* check transition table */
67792 +
67793 + for (trans = current->role->transitions; trans; trans = trans->next) {
67794 + if (!strcmp(rolename, trans->rolename)) {
67795 + found = 1;
67796 + break;
67797 + }
67798 + }
67799 +
67800 + if (!found)
67801 + return 0;
67802 +
67803 + /* handle special roles that do not require authentication
67804 + and check ip */
67805 +
67806 + FOR_EACH_ROLE_START(r)
67807 + if (!strcmp(rolename, r->rolename) &&
67808 + (r->roletype & GR_ROLE_SPECIAL)) {
67809 + found = 0;
67810 + if (r->allowed_ips != NULL) {
67811 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
67812 + if ((ntohl(curr_ip) & ipp->netmask) ==
67813 + (ntohl(ipp->addr) & ipp->netmask))
67814 + found = 1;
67815 + }
67816 + } else
67817 + found = 2;
67818 + if (!found)
67819 + return 0;
67820 +
67821 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
67822 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
67823 + *salt = NULL;
67824 + *sum = NULL;
67825 + return 1;
67826 + }
67827 + }
67828 + FOR_EACH_ROLE_END(r)
67829 +
67830 + for (i = 0; i < polstate->num_sprole_pws; i++) {
67831 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
67832 + *salt = polstate->acl_special_roles[i]->salt;
67833 + *sum = polstate->acl_special_roles[i]->sum;
67834 + return 1;
67835 + }
67836 + }
67837 +
67838 + return 0;
67839 +}
67840 +
67841 +int gr_check_secure_terminal(struct task_struct *task)
67842 +{
67843 + struct task_struct *p, *p2, *p3;
67844 + struct files_struct *files;
67845 + struct fdtable *fdt;
67846 + struct file *our_file = NULL, *file;
67847 + int i;
67848 +
67849 + if (task->signal->tty == NULL)
67850 + return 1;
67851 +
67852 + files = get_files_struct(task);
67853 + if (files != NULL) {
67854 + rcu_read_lock();
67855 + fdt = files_fdtable(files);
67856 + for (i=0; i < fdt->max_fds; i++) {
67857 + file = fcheck_files(files, i);
67858 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
67859 + get_file(file);
67860 + our_file = file;
67861 + }
67862 + }
67863 + rcu_read_unlock();
67864 + put_files_struct(files);
67865 + }
67866 +
67867 + if (our_file == NULL)
67868 + return 1;
67869 +
67870 + read_lock(&tasklist_lock);
67871 + do_each_thread(p2, p) {
67872 + files = get_files_struct(p);
67873 + if (files == NULL ||
67874 + (p->signal && p->signal->tty == task->signal->tty)) {
67875 + if (files != NULL)
67876 + put_files_struct(files);
67877 + continue;
67878 + }
67879 + rcu_read_lock();
67880 + fdt = files_fdtable(files);
67881 + for (i=0; i < fdt->max_fds; i++) {
67882 + file = fcheck_files(files, i);
67883 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
67884 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
67885 + p3 = task;
67886 + while (task_pid_nr(p3) > 0) {
67887 + if (p3 == p)
67888 + break;
67889 + p3 = p3->real_parent;
67890 + }
67891 + if (p3 == p)
67892 + break;
67893 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
67894 + gr_handle_alertkill(p);
67895 + rcu_read_unlock();
67896 + put_files_struct(files);
67897 + read_unlock(&tasklist_lock);
67898 + fput(our_file);
67899 + return 0;
67900 + }
67901 + }
67902 + rcu_read_unlock();
67903 + put_files_struct(files);
67904 + } while_each_thread(p2, p);
67905 + read_unlock(&tasklist_lock);
67906 +
67907 + fput(our_file);
67908 + return 1;
67909 +}
67910 +
67911 +ssize_t
67912 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
67913 +{
67914 + struct gr_arg_wrapper uwrap;
67915 + unsigned char *sprole_salt = NULL;
67916 + unsigned char *sprole_sum = NULL;
67917 + int error = 0;
67918 + int error2 = 0;
67919 + size_t req_count = 0;
67920 + unsigned char oldmode = 0;
67921 +
67922 + mutex_lock(&gr_dev_mutex);
67923 +
67924 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
67925 + error = -EPERM;
67926 + goto out;
67927 + }
67928 +
67929 +#ifdef CONFIG_COMPAT
67930 + pax_open_kernel();
67931 + if (is_compat_task()) {
67932 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
67933 + copy_gr_arg = &copy_gr_arg_compat;
67934 + copy_acl_object_label = &copy_acl_object_label_compat;
67935 + copy_acl_subject_label = &copy_acl_subject_label_compat;
67936 + copy_acl_role_label = &copy_acl_role_label_compat;
67937 + copy_acl_ip_label = &copy_acl_ip_label_compat;
67938 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
67939 + copy_role_transition = &copy_role_transition_compat;
67940 + copy_sprole_pw = &copy_sprole_pw_compat;
67941 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
67942 + copy_pointer_from_array = &copy_pointer_from_array_compat;
67943 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
67944 + } else {
67945 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
67946 + copy_gr_arg = &copy_gr_arg_normal;
67947 + copy_acl_object_label = &copy_acl_object_label_normal;
67948 + copy_acl_subject_label = &copy_acl_subject_label_normal;
67949 + copy_acl_role_label = &copy_acl_role_label_normal;
67950 + copy_acl_ip_label = &copy_acl_ip_label_normal;
67951 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
67952 + copy_role_transition = &copy_role_transition_normal;
67953 + copy_sprole_pw = &copy_sprole_pw_normal;
67954 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
67955 + copy_pointer_from_array = &copy_pointer_from_array_normal;
67956 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
67957 + }
67958 + pax_close_kernel();
67959 +#endif
67960 +
67961 + req_count = get_gr_arg_wrapper_size();
67962 +
67963 + if (count != req_count) {
67964 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
67965 + error = -EINVAL;
67966 + goto out;
67967 + }
67968 +
67969 +
67970 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
67971 + gr_auth_expires = 0;
67972 + gr_auth_attempts = 0;
67973 + }
67974 +
67975 + error = copy_gr_arg_wrapper(buf, &uwrap);
67976 + if (error)
67977 + goto out;
67978 +
67979 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
67980 + if (error)
67981 + goto out;
67982 +
67983 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
67984 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
67985 + time_after(gr_auth_expires, get_seconds())) {
67986 + error = -EBUSY;
67987 + goto out;
67988 + }
67989 +
67990 + /* if non-root trying to do anything other than use a special role,
67991 + do not attempt authentication, do not count towards authentication
67992 + locking
67993 + */
67994 +
67995 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
67996 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
67997 + gr_is_global_nonroot(current_uid())) {
67998 + error = -EPERM;
67999 + goto out;
68000 + }
68001 +
68002 + /* ensure pw and special role name are null terminated */
68003 +
68004 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
68005 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
68006 +
68007 + /* Okay.
68008 + * We have our enough of the argument structure..(we have yet
68009 + * to copy_from_user the tables themselves) . Copy the tables
68010 + * only if we need them, i.e. for loading operations. */
68011 +
68012 + switch (gr_usermode.mode) {
68013 + case GR_STATUS:
68014 + if (gr_acl_is_enabled()) {
68015 + error = 1;
68016 + if (!gr_check_secure_terminal(current))
68017 + error = 3;
68018 + } else
68019 + error = 2;
68020 + goto out;
68021 + case GR_SHUTDOWN:
68022 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68023 + stop_machine(gr_rbac_disable, NULL, NULL);
68024 + free_variables(false);
68025 + memset(&gr_usermode, 0, sizeof(gr_usermode));
68026 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
68027 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
68028 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
68029 + } else if (gr_acl_is_enabled()) {
68030 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
68031 + error = -EPERM;
68032 + } else {
68033 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
68034 + error = -EAGAIN;
68035 + }
68036 + break;
68037 + case GR_ENABLE:
68038 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
68039 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
68040 + else {
68041 + if (gr_acl_is_enabled())
68042 + error = -EAGAIN;
68043 + else
68044 + error = error2;
68045 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
68046 + }
68047 + break;
68048 + case GR_OLDRELOAD:
68049 + oldmode = 1;
68050 + case GR_RELOAD:
68051 + if (!gr_acl_is_enabled()) {
68052 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
68053 + error = -EAGAIN;
68054 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68055 + error2 = gracl_reload(&gr_usermode, oldmode);
68056 + if (!error2)
68057 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
68058 + else {
68059 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68060 + error = error2;
68061 + }
68062 + } else {
68063 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68064 + error = -EPERM;
68065 + }
68066 + break;
68067 + case GR_SEGVMOD:
68068 + if (unlikely(!gr_acl_is_enabled())) {
68069 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
68070 + error = -EAGAIN;
68071 + break;
68072 + }
68073 +
68074 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68075 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
68076 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
68077 + struct acl_subject_label *segvacl;
68078 + segvacl =
68079 + lookup_acl_subj_label(gr_usermode.segv_inode,
68080 + gr_usermode.segv_device,
68081 + current->role);
68082 + if (segvacl) {
68083 + segvacl->crashes = 0;
68084 + segvacl->expires = 0;
68085 + }
68086 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
68087 + gr_remove_uid(gr_usermode.segv_uid);
68088 + }
68089 + } else {
68090 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
68091 + error = -EPERM;
68092 + }
68093 + break;
68094 + case GR_SPROLE:
68095 + case GR_SPROLEPAM:
68096 + if (unlikely(!gr_acl_is_enabled())) {
68097 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
68098 + error = -EAGAIN;
68099 + break;
68100 + }
68101 +
68102 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
68103 + current->role->expires = 0;
68104 + current->role->auth_attempts = 0;
68105 + }
68106 +
68107 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68108 + time_after(current->role->expires, get_seconds())) {
68109 + error = -EBUSY;
68110 + goto out;
68111 + }
68112 +
68113 + if (lookup_special_role_auth
68114 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
68115 + && ((!sprole_salt && !sprole_sum)
68116 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
68117 + char *p = "";
68118 + assign_special_role(gr_usermode.sp_role);
68119 + read_lock(&tasklist_lock);
68120 + if (current->real_parent)
68121 + p = current->real_parent->role->rolename;
68122 + read_unlock(&tasklist_lock);
68123 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
68124 + p, acl_sp_role_value);
68125 + } else {
68126 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
68127 + error = -EPERM;
68128 + if(!(current->role->auth_attempts++))
68129 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68130 +
68131 + goto out;
68132 + }
68133 + break;
68134 + case GR_UNSPROLE:
68135 + if (unlikely(!gr_acl_is_enabled())) {
68136 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
68137 + error = -EAGAIN;
68138 + break;
68139 + }
68140 +
68141 + if (current->role->roletype & GR_ROLE_SPECIAL) {
68142 + char *p = "";
68143 + int i = 0;
68144 +
68145 + read_lock(&tasklist_lock);
68146 + if (current->real_parent) {
68147 + p = current->real_parent->role->rolename;
68148 + i = current->real_parent->acl_role_id;
68149 + }
68150 + read_unlock(&tasklist_lock);
68151 +
68152 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
68153 + gr_set_acls(1);
68154 + } else {
68155 + error = -EPERM;
68156 + goto out;
68157 + }
68158 + break;
68159 + default:
68160 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
68161 + error = -EINVAL;
68162 + break;
68163 + }
68164 +
68165 + if (error != -EPERM)
68166 + goto out;
68167 +
68168 + if(!(gr_auth_attempts++))
68169 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68170 +
68171 + out:
68172 + mutex_unlock(&gr_dev_mutex);
68173 +
68174 + if (!error)
68175 + error = req_count;
68176 +
68177 + return error;
68178 +}
68179 +
68180 +int
68181 +gr_set_acls(const int type)
68182 +{
68183 + struct task_struct *task, *task2;
68184 + struct acl_role_label *role = current->role;
68185 + struct acl_subject_label *subj;
68186 + __u16 acl_role_id = current->acl_role_id;
68187 + const struct cred *cred;
68188 + int ret;
68189 +
68190 + rcu_read_lock();
68191 + read_lock(&tasklist_lock);
68192 + read_lock(&grsec_exec_file_lock);
68193 + do_each_thread(task2, task) {
68194 + /* check to see if we're called from the exit handler,
68195 + if so, only replace ACLs that have inherited the admin
68196 + ACL */
68197 +
68198 + if (type && (task->role != role ||
68199 + task->acl_role_id != acl_role_id))
68200 + continue;
68201 +
68202 + task->acl_role_id = 0;
68203 + task->acl_sp_role = 0;
68204 + task->inherited = 0;
68205 +
68206 + if (task->exec_file) {
68207 + cred = __task_cred(task);
68208 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68209 + subj = gr_get_subject_for_task(task, NULL);
68210 + if (subj == NULL) {
68211 + ret = -EINVAL;
68212 + read_unlock(&grsec_exec_file_lock);
68213 + read_unlock(&tasklist_lock);
68214 + rcu_read_unlock();
68215 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
68216 + return ret;
68217 + }
68218 + __gr_apply_subject_to_task(polstate, task, subj);
68219 + } else {
68220 + // it's a kernel process
68221 + task->role = polstate->kernel_role;
68222 + task->acl = polstate->kernel_role->root_label;
68223 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68224 + task->acl->mode &= ~GR_PROCFIND;
68225 +#endif
68226 + }
68227 + } while_each_thread(task2, task);
68228 + read_unlock(&grsec_exec_file_lock);
68229 + read_unlock(&tasklist_lock);
68230 + rcu_read_unlock();
68231 +
68232 + return 0;
68233 +}
68234 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
68235 new file mode 100644
68236 index 0000000..39645c9
68237 --- /dev/null
68238 +++ b/grsecurity/gracl_res.c
68239 @@ -0,0 +1,68 @@
68240 +#include <linux/kernel.h>
68241 +#include <linux/sched.h>
68242 +#include <linux/gracl.h>
68243 +#include <linux/grinternal.h>
68244 +
68245 +static const char *restab_log[] = {
68246 + [RLIMIT_CPU] = "RLIMIT_CPU",
68247 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
68248 + [RLIMIT_DATA] = "RLIMIT_DATA",
68249 + [RLIMIT_STACK] = "RLIMIT_STACK",
68250 + [RLIMIT_CORE] = "RLIMIT_CORE",
68251 + [RLIMIT_RSS] = "RLIMIT_RSS",
68252 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
68253 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
68254 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
68255 + [RLIMIT_AS] = "RLIMIT_AS",
68256 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
68257 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
68258 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
68259 + [RLIMIT_NICE] = "RLIMIT_NICE",
68260 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
68261 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
68262 + [GR_CRASH_RES] = "RLIMIT_CRASH"
68263 +};
68264 +
68265 +void
68266 +gr_log_resource(const struct task_struct *task,
68267 + const int res, const unsigned long wanted, const int gt)
68268 +{
68269 + const struct cred *cred;
68270 + unsigned long rlim;
68271 +
68272 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
68273 + return;
68274 +
68275 + // not yet supported resource
68276 + if (unlikely(!restab_log[res]))
68277 + return;
68278 +
68279 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
68280 + rlim = task_rlimit_max(task, res);
68281 + else
68282 + rlim = task_rlimit(task, res);
68283 +
68284 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68285 + return;
68286 +
68287 + rcu_read_lock();
68288 + cred = __task_cred(task);
68289 +
68290 + if (res == RLIMIT_NPROC &&
68291 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68292 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68293 + goto out_rcu_unlock;
68294 + else if (res == RLIMIT_MEMLOCK &&
68295 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68296 + goto out_rcu_unlock;
68297 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68298 + goto out_rcu_unlock;
68299 + rcu_read_unlock();
68300 +
68301 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68302 +
68303 + return;
68304 +out_rcu_unlock:
68305 + rcu_read_unlock();
68306 + return;
68307 +}
68308 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68309 new file mode 100644
68310 index 0000000..2040e61
68311 --- /dev/null
68312 +++ b/grsecurity/gracl_segv.c
68313 @@ -0,0 +1,313 @@
68314 +#include <linux/kernel.h>
68315 +#include <linux/mm.h>
68316 +#include <asm/uaccess.h>
68317 +#include <asm/errno.h>
68318 +#include <asm/mman.h>
68319 +#include <net/sock.h>
68320 +#include <linux/file.h>
68321 +#include <linux/fs.h>
68322 +#include <linux/net.h>
68323 +#include <linux/in.h>
68324 +#include <linux/slab.h>
68325 +#include <linux/types.h>
68326 +#include <linux/sched.h>
68327 +#include <linux/timer.h>
68328 +#include <linux/gracl.h>
68329 +#include <linux/grsecurity.h>
68330 +#include <linux/grinternal.h>
68331 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68332 +#include <linux/magic.h>
68333 +#include <linux/pagemap.h>
68334 +#include "../fs/btrfs/async-thread.h"
68335 +#include "../fs/btrfs/ctree.h"
68336 +#include "../fs/btrfs/btrfs_inode.h"
68337 +#endif
68338 +
68339 +static struct crash_uid *uid_set;
68340 +static unsigned short uid_used;
68341 +static DEFINE_SPINLOCK(gr_uid_lock);
68342 +extern rwlock_t gr_inode_lock;
68343 +extern struct acl_subject_label *
68344 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68345 + struct acl_role_label *role);
68346 +
68347 +static inline dev_t __get_dev(const struct dentry *dentry)
68348 +{
68349 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68350 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68351 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68352 + else
68353 +#endif
68354 + return dentry->d_sb->s_dev;
68355 +}
68356 +
68357 +int
68358 +gr_init_uidset(void)
68359 +{
68360 + uid_set =
68361 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68362 + uid_used = 0;
68363 +
68364 + return uid_set ? 1 : 0;
68365 +}
68366 +
68367 +void
68368 +gr_free_uidset(void)
68369 +{
68370 + if (uid_set) {
68371 + struct crash_uid *tmpset;
68372 + spin_lock(&gr_uid_lock);
68373 + tmpset = uid_set;
68374 + uid_set = NULL;
68375 + uid_used = 0;
68376 + spin_unlock(&gr_uid_lock);
68377 + if (tmpset)
68378 + kfree(tmpset);
68379 + }
68380 +
68381 + return;
68382 +}
68383 +
68384 +int
68385 +gr_find_uid(const uid_t uid)
68386 +{
68387 + struct crash_uid *tmp = uid_set;
68388 + uid_t buid;
68389 + int low = 0, high = uid_used - 1, mid;
68390 +
68391 + while (high >= low) {
68392 + mid = (low + high) >> 1;
68393 + buid = tmp[mid].uid;
68394 + if (buid == uid)
68395 + return mid;
68396 + if (buid > uid)
68397 + high = mid - 1;
68398 + if (buid < uid)
68399 + low = mid + 1;
68400 + }
68401 +
68402 + return -1;
68403 +}
68404 +
68405 +static __inline__ void
68406 +gr_insertsort(void)
68407 +{
68408 + unsigned short i, j;
68409 + struct crash_uid index;
68410 +
68411 + for (i = 1; i < uid_used; i++) {
68412 + index = uid_set[i];
68413 + j = i;
68414 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68415 + uid_set[j] = uid_set[j - 1];
68416 + j--;
68417 + }
68418 + uid_set[j] = index;
68419 + }
68420 +
68421 + return;
68422 +}
68423 +
68424 +static __inline__ void
68425 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68426 +{
68427 + int loc;
68428 + uid_t uid = GR_GLOBAL_UID(kuid);
68429 +
68430 + if (uid_used == GR_UIDTABLE_MAX)
68431 + return;
68432 +
68433 + loc = gr_find_uid(uid);
68434 +
68435 + if (loc >= 0) {
68436 + uid_set[loc].expires = expires;
68437 + return;
68438 + }
68439 +
68440 + uid_set[uid_used].uid = uid;
68441 + uid_set[uid_used].expires = expires;
68442 + uid_used++;
68443 +
68444 + gr_insertsort();
68445 +
68446 + return;
68447 +}
68448 +
68449 +void
68450 +gr_remove_uid(const unsigned short loc)
68451 +{
68452 + unsigned short i;
68453 +
68454 + for (i = loc + 1; i < uid_used; i++)
68455 + uid_set[i - 1] = uid_set[i];
68456 +
68457 + uid_used--;
68458 +
68459 + return;
68460 +}
68461 +
68462 +int
68463 +gr_check_crash_uid(const kuid_t kuid)
68464 +{
68465 + int loc;
68466 + int ret = 0;
68467 + uid_t uid;
68468 +
68469 + if (unlikely(!gr_acl_is_enabled()))
68470 + return 0;
68471 +
68472 + uid = GR_GLOBAL_UID(kuid);
68473 +
68474 + spin_lock(&gr_uid_lock);
68475 + loc = gr_find_uid(uid);
68476 +
68477 + if (loc < 0)
68478 + goto out_unlock;
68479 +
68480 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68481 + gr_remove_uid(loc);
68482 + else
68483 + ret = 1;
68484 +
68485 +out_unlock:
68486 + spin_unlock(&gr_uid_lock);
68487 + return ret;
68488 +}
68489 +
68490 +static __inline__ int
68491 +proc_is_setxid(const struct cred *cred)
68492 +{
68493 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68494 + !uid_eq(cred->uid, cred->fsuid))
68495 + return 1;
68496 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68497 + !gid_eq(cred->gid, cred->fsgid))
68498 + return 1;
68499 +
68500 + return 0;
68501 +}
68502 +
68503 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68504 +
68505 +void
68506 +gr_handle_crash(struct task_struct *task, const int sig)
68507 +{
68508 + struct acl_subject_label *curr;
68509 + struct task_struct *tsk, *tsk2;
68510 + const struct cred *cred;
68511 + const struct cred *cred2;
68512 +
68513 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68514 + return;
68515 +
68516 + if (unlikely(!gr_acl_is_enabled()))
68517 + return;
68518 +
68519 + curr = task->acl;
68520 +
68521 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68522 + return;
68523 +
68524 + if (time_before_eq(curr->expires, get_seconds())) {
68525 + curr->expires = 0;
68526 + curr->crashes = 0;
68527 + }
68528 +
68529 + curr->crashes++;
68530 +
68531 + if (!curr->expires)
68532 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68533 +
68534 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68535 + time_after(curr->expires, get_seconds())) {
68536 + rcu_read_lock();
68537 + cred = __task_cred(task);
68538 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68539 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68540 + spin_lock(&gr_uid_lock);
68541 + gr_insert_uid(cred->uid, curr->expires);
68542 + spin_unlock(&gr_uid_lock);
68543 + curr->expires = 0;
68544 + curr->crashes = 0;
68545 + read_lock(&tasklist_lock);
68546 + do_each_thread(tsk2, tsk) {
68547 + cred2 = __task_cred(tsk);
68548 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68549 + gr_fake_force_sig(SIGKILL, tsk);
68550 + } while_each_thread(tsk2, tsk);
68551 + read_unlock(&tasklist_lock);
68552 + } else {
68553 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68554 + read_lock(&tasklist_lock);
68555 + read_lock(&grsec_exec_file_lock);
68556 + do_each_thread(tsk2, tsk) {
68557 + if (likely(tsk != task)) {
68558 + // if this thread has the same subject as the one that triggered
68559 + // RES_CRASH and it's the same binary, kill it
68560 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68561 + gr_fake_force_sig(SIGKILL, tsk);
68562 + }
68563 + } while_each_thread(tsk2, tsk);
68564 + read_unlock(&grsec_exec_file_lock);
68565 + read_unlock(&tasklist_lock);
68566 + }
68567 + rcu_read_unlock();
68568 + }
68569 +
68570 + return;
68571 +}
68572 +
68573 +int
68574 +gr_check_crash_exec(const struct file *filp)
68575 +{
68576 + struct acl_subject_label *curr;
68577 +
68578 + if (unlikely(!gr_acl_is_enabled()))
68579 + return 0;
68580 +
68581 + read_lock(&gr_inode_lock);
68582 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68583 + __get_dev(filp->f_path.dentry),
68584 + current->role);
68585 + read_unlock(&gr_inode_lock);
68586 +
68587 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68588 + (!curr->crashes && !curr->expires))
68589 + return 0;
68590 +
68591 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68592 + time_after(curr->expires, get_seconds()))
68593 + return 1;
68594 + else if (time_before_eq(curr->expires, get_seconds())) {
68595 + curr->crashes = 0;
68596 + curr->expires = 0;
68597 + }
68598 +
68599 + return 0;
68600 +}
68601 +
68602 +void
68603 +gr_handle_alertkill(struct task_struct *task)
68604 +{
68605 + struct acl_subject_label *curracl;
68606 + __u32 curr_ip;
68607 + struct task_struct *p, *p2;
68608 +
68609 + if (unlikely(!gr_acl_is_enabled()))
68610 + return;
68611 +
68612 + curracl = task->acl;
68613 + curr_ip = task->signal->curr_ip;
68614 +
68615 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68616 + read_lock(&tasklist_lock);
68617 + do_each_thread(p2, p) {
68618 + if (p->signal->curr_ip == curr_ip)
68619 + gr_fake_force_sig(SIGKILL, p);
68620 + } while_each_thread(p2, p);
68621 + read_unlock(&tasklist_lock);
68622 + } else if (curracl->mode & GR_KILLPROC)
68623 + gr_fake_force_sig(SIGKILL, task);
68624 +
68625 + return;
68626 +}
68627 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68628 new file mode 100644
68629 index 0000000..98011b0
68630 --- /dev/null
68631 +++ b/grsecurity/gracl_shm.c
68632 @@ -0,0 +1,40 @@
68633 +#include <linux/kernel.h>
68634 +#include <linux/mm.h>
68635 +#include <linux/sched.h>
68636 +#include <linux/file.h>
68637 +#include <linux/ipc.h>
68638 +#include <linux/gracl.h>
68639 +#include <linux/grsecurity.h>
68640 +#include <linux/grinternal.h>
68641 +
68642 +int
68643 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68644 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68645 +{
68646 + struct task_struct *task;
68647 +
68648 + if (!gr_acl_is_enabled())
68649 + return 1;
68650 +
68651 + rcu_read_lock();
68652 + read_lock(&tasklist_lock);
68653 +
68654 + task = find_task_by_vpid(shm_cprid);
68655 +
68656 + if (unlikely(!task))
68657 + task = find_task_by_vpid(shm_lapid);
68658 +
68659 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68660 + (task_pid_nr(task) == shm_lapid)) &&
68661 + (task->acl->mode & GR_PROTSHM) &&
68662 + (task->acl != current->acl))) {
68663 + read_unlock(&tasklist_lock);
68664 + rcu_read_unlock();
68665 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68666 + return 0;
68667 + }
68668 + read_unlock(&tasklist_lock);
68669 + rcu_read_unlock();
68670 +
68671 + return 1;
68672 +}
68673 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68674 new file mode 100644
68675 index 0000000..bc0be01
68676 --- /dev/null
68677 +++ b/grsecurity/grsec_chdir.c
68678 @@ -0,0 +1,19 @@
68679 +#include <linux/kernel.h>
68680 +#include <linux/sched.h>
68681 +#include <linux/fs.h>
68682 +#include <linux/file.h>
68683 +#include <linux/grsecurity.h>
68684 +#include <linux/grinternal.h>
68685 +
68686 +void
68687 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68688 +{
68689 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68690 + if ((grsec_enable_chdir && grsec_enable_group &&
68691 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68692 + !grsec_enable_group)) {
68693 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68694 + }
68695 +#endif
68696 + return;
68697 +}
68698 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68699 new file mode 100644
68700 index 0000000..e10b319
68701 --- /dev/null
68702 +++ b/grsecurity/grsec_chroot.c
68703 @@ -0,0 +1,370 @@
68704 +#include <linux/kernel.h>
68705 +#include <linux/module.h>
68706 +#include <linux/sched.h>
68707 +#include <linux/file.h>
68708 +#include <linux/fs.h>
68709 +#include <linux/mount.h>
68710 +#include <linux/types.h>
68711 +#include "../fs/mount.h"
68712 +#include <linux/grsecurity.h>
68713 +#include <linux/grinternal.h>
68714 +
68715 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68716 +int gr_init_ran;
68717 +#endif
68718 +
68719 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68720 +{
68721 +#ifdef CONFIG_GRKERNSEC
68722 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68723 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68724 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68725 + && gr_init_ran
68726 +#endif
68727 + )
68728 + task->gr_is_chrooted = 1;
68729 + else {
68730 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68731 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68732 + gr_init_ran = 1;
68733 +#endif
68734 + task->gr_is_chrooted = 0;
68735 + }
68736 +
68737 + task->gr_chroot_dentry = path->dentry;
68738 +#endif
68739 + return;
68740 +}
68741 +
68742 +void gr_clear_chroot_entries(struct task_struct *task)
68743 +{
68744 +#ifdef CONFIG_GRKERNSEC
68745 + task->gr_is_chrooted = 0;
68746 + task->gr_chroot_dentry = NULL;
68747 +#endif
68748 + return;
68749 +}
68750 +
68751 +int
68752 +gr_handle_chroot_unix(const pid_t pid)
68753 +{
68754 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68755 + struct task_struct *p;
68756 +
68757 + if (unlikely(!grsec_enable_chroot_unix))
68758 + return 1;
68759 +
68760 + if (likely(!proc_is_chrooted(current)))
68761 + return 1;
68762 +
68763 + rcu_read_lock();
68764 + read_lock(&tasklist_lock);
68765 + p = find_task_by_vpid_unrestricted(pid);
68766 + if (unlikely(p && !have_same_root(current, p))) {
68767 + read_unlock(&tasklist_lock);
68768 + rcu_read_unlock();
68769 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68770 + return 0;
68771 + }
68772 + read_unlock(&tasklist_lock);
68773 + rcu_read_unlock();
68774 +#endif
68775 + return 1;
68776 +}
68777 +
68778 +int
68779 +gr_handle_chroot_nice(void)
68780 +{
68781 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68782 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68783 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68784 + return -EPERM;
68785 + }
68786 +#endif
68787 + return 0;
68788 +}
68789 +
68790 +int
68791 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68792 +{
68793 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68794 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68795 + && proc_is_chrooted(current)) {
68796 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68797 + return -EACCES;
68798 + }
68799 +#endif
68800 + return 0;
68801 +}
68802 +
68803 +int
68804 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68805 +{
68806 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68807 + struct task_struct *p;
68808 + int ret = 0;
68809 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68810 + return ret;
68811 +
68812 + read_lock(&tasklist_lock);
68813 + do_each_pid_task(pid, type, p) {
68814 + if (!have_same_root(current, p)) {
68815 + ret = 1;
68816 + goto out;
68817 + }
68818 + } while_each_pid_task(pid, type, p);
68819 +out:
68820 + read_unlock(&tasklist_lock);
68821 + return ret;
68822 +#endif
68823 + return 0;
68824 +}
68825 +
68826 +int
68827 +gr_pid_is_chrooted(struct task_struct *p)
68828 +{
68829 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68830 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68831 + return 0;
68832 +
68833 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68834 + !have_same_root(current, p)) {
68835 + return 1;
68836 + }
68837 +#endif
68838 + return 0;
68839 +}
68840 +
68841 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68842 +
68843 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68844 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68845 +{
68846 + struct path path, currentroot;
68847 + int ret = 0;
68848 +
68849 + path.dentry = (struct dentry *)u_dentry;
68850 + path.mnt = (struct vfsmount *)u_mnt;
68851 + get_fs_root(current->fs, &currentroot);
68852 + if (path_is_under(&path, &currentroot))
68853 + ret = 1;
68854 + path_put(&currentroot);
68855 +
68856 + return ret;
68857 +}
68858 +#endif
68859 +
68860 +int
68861 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68862 +{
68863 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68864 + if (!grsec_enable_chroot_fchdir)
68865 + return 1;
68866 +
68867 + if (!proc_is_chrooted(current))
68868 + return 1;
68869 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68870 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68871 + return 0;
68872 + }
68873 +#endif
68874 + return 1;
68875 +}
68876 +
68877 +int
68878 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68879 + const time_t shm_createtime)
68880 +{
68881 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68882 + struct task_struct *p;
68883 + time_t starttime;
68884 +
68885 + if (unlikely(!grsec_enable_chroot_shmat))
68886 + return 1;
68887 +
68888 + if (likely(!proc_is_chrooted(current)))
68889 + return 1;
68890 +
68891 + rcu_read_lock();
68892 + read_lock(&tasklist_lock);
68893 +
68894 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68895 + starttime = p->start_time.tv_sec;
68896 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68897 + if (have_same_root(current, p)) {
68898 + goto allow;
68899 + } else {
68900 + read_unlock(&tasklist_lock);
68901 + rcu_read_unlock();
68902 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68903 + return 0;
68904 + }
68905 + }
68906 + /* creator exited, pid reuse, fall through to next check */
68907 + }
68908 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68909 + if (unlikely(!have_same_root(current, p))) {
68910 + read_unlock(&tasklist_lock);
68911 + rcu_read_unlock();
68912 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68913 + return 0;
68914 + }
68915 + }
68916 +
68917 +allow:
68918 + read_unlock(&tasklist_lock);
68919 + rcu_read_unlock();
68920 +#endif
68921 + return 1;
68922 +}
68923 +
68924 +void
68925 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68926 +{
68927 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68928 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68929 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68930 +#endif
68931 + return;
68932 +}
68933 +
68934 +int
68935 +gr_handle_chroot_mknod(const struct dentry *dentry,
68936 + const struct vfsmount *mnt, const int mode)
68937 +{
68938 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68939 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68940 + proc_is_chrooted(current)) {
68941 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68942 + return -EPERM;
68943 + }
68944 +#endif
68945 + return 0;
68946 +}
68947 +
68948 +int
68949 +gr_handle_chroot_mount(const struct dentry *dentry,
68950 + const struct vfsmount *mnt, const char *dev_name)
68951 +{
68952 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68953 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68954 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68955 + return -EPERM;
68956 + }
68957 +#endif
68958 + return 0;
68959 +}
68960 +
68961 +int
68962 +gr_handle_chroot_pivot(void)
68963 +{
68964 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68965 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68966 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68967 + return -EPERM;
68968 + }
68969 +#endif
68970 + return 0;
68971 +}
68972 +
68973 +int
68974 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68975 +{
68976 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68977 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68978 + !gr_is_outside_chroot(dentry, mnt)) {
68979 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68980 + return -EPERM;
68981 + }
68982 +#endif
68983 + return 0;
68984 +}
68985 +
68986 +extern const char *captab_log[];
68987 +extern int captab_log_entries;
68988 +
68989 +int
68990 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68991 +{
68992 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68993 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68994 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68995 + if (cap_raised(chroot_caps, cap)) {
68996 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68997 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68998 + }
68999 + return 0;
69000 + }
69001 + }
69002 +#endif
69003 + return 1;
69004 +}
69005 +
69006 +int
69007 +gr_chroot_is_capable(const int cap)
69008 +{
69009 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69010 + return gr_task_chroot_is_capable(current, current_cred(), cap);
69011 +#endif
69012 + return 1;
69013 +}
69014 +
69015 +int
69016 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
69017 +{
69018 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69019 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69020 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69021 + if (cap_raised(chroot_caps, cap)) {
69022 + return 0;
69023 + }
69024 + }
69025 +#endif
69026 + return 1;
69027 +}
69028 +
69029 +int
69030 +gr_chroot_is_capable_nolog(const int cap)
69031 +{
69032 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69033 + return gr_task_chroot_is_capable_nolog(current, cap);
69034 +#endif
69035 + return 1;
69036 +}
69037 +
69038 +int
69039 +gr_handle_chroot_sysctl(const int op)
69040 +{
69041 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69042 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
69043 + proc_is_chrooted(current))
69044 + return -EACCES;
69045 +#endif
69046 + return 0;
69047 +}
69048 +
69049 +void
69050 +gr_handle_chroot_chdir(const struct path *path)
69051 +{
69052 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69053 + if (grsec_enable_chroot_chdir)
69054 + set_fs_pwd(current->fs, path);
69055 +#endif
69056 + return;
69057 +}
69058 +
69059 +int
69060 +gr_handle_chroot_chmod(const struct dentry *dentry,
69061 + const struct vfsmount *mnt, const int mode)
69062 +{
69063 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69064 + /* allow chmod +s on directories, but not files */
69065 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
69066 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
69067 + proc_is_chrooted(current)) {
69068 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
69069 + return -EPERM;
69070 + }
69071 +#endif
69072 + return 0;
69073 +}
69074 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
69075 new file mode 100644
69076 index 0000000..0866ab2
69077 --- /dev/null
69078 +++ b/grsecurity/grsec_disabled.c
69079 @@ -0,0 +1,427 @@
69080 +#include <linux/kernel.h>
69081 +#include <linux/module.h>
69082 +#include <linux/sched.h>
69083 +#include <linux/file.h>
69084 +#include <linux/fs.h>
69085 +#include <linux/kdev_t.h>
69086 +#include <linux/net.h>
69087 +#include <linux/in.h>
69088 +#include <linux/ip.h>
69089 +#include <linux/skbuff.h>
69090 +#include <linux/sysctl.h>
69091 +
69092 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
69093 +void
69094 +pax_set_initial_flags(struct linux_binprm *bprm)
69095 +{
69096 + return;
69097 +}
69098 +#endif
69099 +
69100 +#ifdef CONFIG_SYSCTL
69101 +__u32
69102 +gr_handle_sysctl(const struct ctl_table * table, const int op)
69103 +{
69104 + return 0;
69105 +}
69106 +#endif
69107 +
69108 +#ifdef CONFIG_TASKSTATS
69109 +int gr_is_taskstats_denied(int pid)
69110 +{
69111 + return 0;
69112 +}
69113 +#endif
69114 +
69115 +int
69116 +gr_acl_is_enabled(void)
69117 +{
69118 + return 0;
69119 +}
69120 +
69121 +void
69122 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
69123 +{
69124 + return;
69125 +}
69126 +
69127 +int
69128 +gr_handle_rawio(const struct inode *inode)
69129 +{
69130 + return 0;
69131 +}
69132 +
69133 +void
69134 +gr_acl_handle_psacct(struct task_struct *task, const long code)
69135 +{
69136 + return;
69137 +}
69138 +
69139 +int
69140 +gr_handle_ptrace(struct task_struct *task, const long request)
69141 +{
69142 + return 0;
69143 +}
69144 +
69145 +int
69146 +gr_handle_proc_ptrace(struct task_struct *task)
69147 +{
69148 + return 0;
69149 +}
69150 +
69151 +int
69152 +gr_set_acls(const int type)
69153 +{
69154 + return 0;
69155 +}
69156 +
69157 +int
69158 +gr_check_hidden_task(const struct task_struct *tsk)
69159 +{
69160 + return 0;
69161 +}
69162 +
69163 +int
69164 +gr_check_protected_task(const struct task_struct *task)
69165 +{
69166 + return 0;
69167 +}
69168 +
69169 +int
69170 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
69171 +{
69172 + return 0;
69173 +}
69174 +
69175 +void
69176 +gr_copy_label(struct task_struct *tsk)
69177 +{
69178 + return;
69179 +}
69180 +
69181 +void
69182 +gr_set_pax_flags(struct task_struct *task)
69183 +{
69184 + return;
69185 +}
69186 +
69187 +int
69188 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
69189 + const int unsafe_share)
69190 +{
69191 + return 0;
69192 +}
69193 +
69194 +void
69195 +gr_handle_delete(const ino_t ino, const dev_t dev)
69196 +{
69197 + return;
69198 +}
69199 +
69200 +void
69201 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
69202 +{
69203 + return;
69204 +}
69205 +
69206 +void
69207 +gr_handle_crash(struct task_struct *task, const int sig)
69208 +{
69209 + return;
69210 +}
69211 +
69212 +int
69213 +gr_check_crash_exec(const struct file *filp)
69214 +{
69215 + return 0;
69216 +}
69217 +
69218 +int
69219 +gr_check_crash_uid(const kuid_t uid)
69220 +{
69221 + return 0;
69222 +}
69223 +
69224 +void
69225 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69226 + struct dentry *old_dentry,
69227 + struct dentry *new_dentry,
69228 + struct vfsmount *mnt, const __u8 replace)
69229 +{
69230 + return;
69231 +}
69232 +
69233 +int
69234 +gr_search_socket(const int family, const int type, const int protocol)
69235 +{
69236 + return 1;
69237 +}
69238 +
69239 +int
69240 +gr_search_connectbind(const int mode, const struct socket *sock,
69241 + const struct sockaddr_in *addr)
69242 +{
69243 + return 0;
69244 +}
69245 +
69246 +void
69247 +gr_handle_alertkill(struct task_struct *task)
69248 +{
69249 + return;
69250 +}
69251 +
69252 +__u32
69253 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
69254 +{
69255 + return 1;
69256 +}
69257 +
69258 +__u32
69259 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69260 + const struct vfsmount * mnt)
69261 +{
69262 + return 1;
69263 +}
69264 +
69265 +__u32
69266 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69267 + int acc_mode)
69268 +{
69269 + return 1;
69270 +}
69271 +
69272 +__u32
69273 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
69274 +{
69275 + return 1;
69276 +}
69277 +
69278 +__u32
69279 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
69280 +{
69281 + return 1;
69282 +}
69283 +
69284 +int
69285 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
69286 + unsigned int *vm_flags)
69287 +{
69288 + return 1;
69289 +}
69290 +
69291 +__u32
69292 +gr_acl_handle_truncate(const struct dentry * dentry,
69293 + const struct vfsmount * mnt)
69294 +{
69295 + return 1;
69296 +}
69297 +
69298 +__u32
69299 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69300 +{
69301 + return 1;
69302 +}
69303 +
69304 +__u32
69305 +gr_acl_handle_access(const struct dentry * dentry,
69306 + const struct vfsmount * mnt, const int fmode)
69307 +{
69308 + return 1;
69309 +}
69310 +
69311 +__u32
69312 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69313 + umode_t *mode)
69314 +{
69315 + return 1;
69316 +}
69317 +
69318 +__u32
69319 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69320 +{
69321 + return 1;
69322 +}
69323 +
69324 +__u32
69325 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69326 +{
69327 + return 1;
69328 +}
69329 +
69330 +void
69331 +grsecurity_init(void)
69332 +{
69333 + return;
69334 +}
69335 +
69336 +umode_t gr_acl_umask(void)
69337 +{
69338 + return 0;
69339 +}
69340 +
69341 +__u32
69342 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69343 + const struct dentry * parent_dentry,
69344 + const struct vfsmount * parent_mnt,
69345 + const int mode)
69346 +{
69347 + return 1;
69348 +}
69349 +
69350 +__u32
69351 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69352 + const struct dentry * parent_dentry,
69353 + const struct vfsmount * parent_mnt)
69354 +{
69355 + return 1;
69356 +}
69357 +
69358 +__u32
69359 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69360 + const struct dentry * parent_dentry,
69361 + const struct vfsmount * parent_mnt, const struct filename *from)
69362 +{
69363 + return 1;
69364 +}
69365 +
69366 +__u32
69367 +gr_acl_handle_link(const struct dentry * new_dentry,
69368 + const struct dentry * parent_dentry,
69369 + const struct vfsmount * parent_mnt,
69370 + const struct dentry * old_dentry,
69371 + const struct vfsmount * old_mnt, const struct filename *to)
69372 +{
69373 + return 1;
69374 +}
69375 +
69376 +int
69377 +gr_acl_handle_rename(const struct dentry *new_dentry,
69378 + const struct dentry *parent_dentry,
69379 + const struct vfsmount *parent_mnt,
69380 + const struct dentry *old_dentry,
69381 + const struct inode *old_parent_inode,
69382 + const struct vfsmount *old_mnt, const struct filename *newname)
69383 +{
69384 + return 0;
69385 +}
69386 +
69387 +int
69388 +gr_acl_handle_filldir(const struct file *file, const char *name,
69389 + const int namelen, const ino_t ino)
69390 +{
69391 + return 1;
69392 +}
69393 +
69394 +int
69395 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69396 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69397 +{
69398 + return 1;
69399 +}
69400 +
69401 +int
69402 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69403 +{
69404 + return 0;
69405 +}
69406 +
69407 +int
69408 +gr_search_accept(const struct socket *sock)
69409 +{
69410 + return 0;
69411 +}
69412 +
69413 +int
69414 +gr_search_listen(const struct socket *sock)
69415 +{
69416 + return 0;
69417 +}
69418 +
69419 +int
69420 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69421 +{
69422 + return 0;
69423 +}
69424 +
69425 +__u32
69426 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69427 +{
69428 + return 1;
69429 +}
69430 +
69431 +__u32
69432 +gr_acl_handle_creat(const struct dentry * dentry,
69433 + const struct dentry * p_dentry,
69434 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69435 + const int imode)
69436 +{
69437 + return 1;
69438 +}
69439 +
69440 +void
69441 +gr_acl_handle_exit(void)
69442 +{
69443 + return;
69444 +}
69445 +
69446 +int
69447 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69448 +{
69449 + return 1;
69450 +}
69451 +
69452 +void
69453 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69454 +{
69455 + return;
69456 +}
69457 +
69458 +int
69459 +gr_acl_handle_procpidmem(const struct task_struct *task)
69460 +{
69461 + return 0;
69462 +}
69463 +
69464 +int
69465 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69466 +{
69467 + return 0;
69468 +}
69469 +
69470 +int
69471 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69472 +{
69473 + return 0;
69474 +}
69475 +
69476 +int
69477 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69478 +{
69479 + return 0;
69480 +}
69481 +
69482 +int
69483 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69484 +{
69485 + return 0;
69486 +}
69487 +
69488 +int gr_acl_enable_at_secure(void)
69489 +{
69490 + return 0;
69491 +}
69492 +
69493 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69494 +{
69495 + return dentry->d_sb->s_dev;
69496 +}
69497 +
69498 +void gr_put_exec_file(struct task_struct *task)
69499 +{
69500 + return;
69501 +}
69502 +
69503 +#ifdef CONFIG_SECURITY
69504 +EXPORT_SYMBOL(gr_check_user_change);
69505 +EXPORT_SYMBOL(gr_check_group_change);
69506 +#endif
69507 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69508 new file mode 100644
69509 index 0000000..387032b
69510 --- /dev/null
69511 +++ b/grsecurity/grsec_exec.c
69512 @@ -0,0 +1,187 @@
69513 +#include <linux/kernel.h>
69514 +#include <linux/sched.h>
69515 +#include <linux/file.h>
69516 +#include <linux/binfmts.h>
69517 +#include <linux/fs.h>
69518 +#include <linux/types.h>
69519 +#include <linux/grdefs.h>
69520 +#include <linux/grsecurity.h>
69521 +#include <linux/grinternal.h>
69522 +#include <linux/capability.h>
69523 +#include <linux/module.h>
69524 +#include <linux/compat.h>
69525 +
69526 +#include <asm/uaccess.h>
69527 +
69528 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69529 +static char gr_exec_arg_buf[132];
69530 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69531 +#endif
69532 +
69533 +struct user_arg_ptr {
69534 +#ifdef CONFIG_COMPAT
69535 + bool is_compat;
69536 +#endif
69537 + union {
69538 + const char __user *const __user *native;
69539 +#ifdef CONFIG_COMPAT
69540 + const compat_uptr_t __user *compat;
69541 +#endif
69542 + } ptr;
69543 +};
69544 +
69545 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69546 +
69547 +void
69548 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69549 +{
69550 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69551 + char *grarg = gr_exec_arg_buf;
69552 + unsigned int i, x, execlen = 0;
69553 + char c;
69554 +
69555 + if (!((grsec_enable_execlog && grsec_enable_group &&
69556 + in_group_p(grsec_audit_gid))
69557 + || (grsec_enable_execlog && !grsec_enable_group)))
69558 + return;
69559 +
69560 + mutex_lock(&gr_exec_arg_mutex);
69561 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69562 +
69563 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69564 + const char __user *p;
69565 + unsigned int len;
69566 +
69567 + p = get_user_arg_ptr(argv, i);
69568 + if (IS_ERR(p))
69569 + goto log;
69570 +
69571 + len = strnlen_user(p, 128 - execlen);
69572 + if (len > 128 - execlen)
69573 + len = 128 - execlen;
69574 + else if (len > 0)
69575 + len--;
69576 + if (copy_from_user(grarg + execlen, p, len))
69577 + goto log;
69578 +
69579 + /* rewrite unprintable characters */
69580 + for (x = 0; x < len; x++) {
69581 + c = *(grarg + execlen + x);
69582 + if (c < 32 || c > 126)
69583 + *(grarg + execlen + x) = ' ';
69584 + }
69585 +
69586 + execlen += len;
69587 + *(grarg + execlen) = ' ';
69588 + *(grarg + execlen + 1) = '\0';
69589 + execlen++;
69590 + }
69591 +
69592 + log:
69593 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69594 + bprm->file->f_path.mnt, grarg);
69595 + mutex_unlock(&gr_exec_arg_mutex);
69596 +#endif
69597 + return;
69598 +}
69599 +
69600 +#ifdef CONFIG_GRKERNSEC
69601 +extern int gr_acl_is_capable(const int cap);
69602 +extern int gr_acl_is_capable_nolog(const int cap);
69603 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69604 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69605 +extern int gr_chroot_is_capable(const int cap);
69606 +extern int gr_chroot_is_capable_nolog(const int cap);
69607 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69608 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69609 +#endif
69610 +
69611 +const char *captab_log[] = {
69612 + "CAP_CHOWN",
69613 + "CAP_DAC_OVERRIDE",
69614 + "CAP_DAC_READ_SEARCH",
69615 + "CAP_FOWNER",
69616 + "CAP_FSETID",
69617 + "CAP_KILL",
69618 + "CAP_SETGID",
69619 + "CAP_SETUID",
69620 + "CAP_SETPCAP",
69621 + "CAP_LINUX_IMMUTABLE",
69622 + "CAP_NET_BIND_SERVICE",
69623 + "CAP_NET_BROADCAST",
69624 + "CAP_NET_ADMIN",
69625 + "CAP_NET_RAW",
69626 + "CAP_IPC_LOCK",
69627 + "CAP_IPC_OWNER",
69628 + "CAP_SYS_MODULE",
69629 + "CAP_SYS_RAWIO",
69630 + "CAP_SYS_CHROOT",
69631 + "CAP_SYS_PTRACE",
69632 + "CAP_SYS_PACCT",
69633 + "CAP_SYS_ADMIN",
69634 + "CAP_SYS_BOOT",
69635 + "CAP_SYS_NICE",
69636 + "CAP_SYS_RESOURCE",
69637 + "CAP_SYS_TIME",
69638 + "CAP_SYS_TTY_CONFIG",
69639 + "CAP_MKNOD",
69640 + "CAP_LEASE",
69641 + "CAP_AUDIT_WRITE",
69642 + "CAP_AUDIT_CONTROL",
69643 + "CAP_SETFCAP",
69644 + "CAP_MAC_OVERRIDE",
69645 + "CAP_MAC_ADMIN",
69646 + "CAP_SYSLOG",
69647 + "CAP_WAKE_ALARM"
69648 +};
69649 +
69650 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69651 +
69652 +int gr_is_capable(const int cap)
69653 +{
69654 +#ifdef CONFIG_GRKERNSEC
69655 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69656 + return 1;
69657 + return 0;
69658 +#else
69659 + return 1;
69660 +#endif
69661 +}
69662 +
69663 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69664 +{
69665 +#ifdef CONFIG_GRKERNSEC
69666 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69667 + return 1;
69668 + return 0;
69669 +#else
69670 + return 1;
69671 +#endif
69672 +}
69673 +
69674 +int gr_is_capable_nolog(const int cap)
69675 +{
69676 +#ifdef CONFIG_GRKERNSEC
69677 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69678 + return 1;
69679 + return 0;
69680 +#else
69681 + return 1;
69682 +#endif
69683 +}
69684 +
69685 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69686 +{
69687 +#ifdef CONFIG_GRKERNSEC
69688 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69689 + return 1;
69690 + return 0;
69691 +#else
69692 + return 1;
69693 +#endif
69694 +}
69695 +
69696 +EXPORT_SYMBOL(gr_is_capable);
69697 +EXPORT_SYMBOL(gr_is_capable_nolog);
69698 +EXPORT_SYMBOL(gr_task_is_capable);
69699 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69700 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69701 new file mode 100644
69702 index 0000000..06cc6ea
69703 --- /dev/null
69704 +++ b/grsecurity/grsec_fifo.c
69705 @@ -0,0 +1,24 @@
69706 +#include <linux/kernel.h>
69707 +#include <linux/sched.h>
69708 +#include <linux/fs.h>
69709 +#include <linux/file.h>
69710 +#include <linux/grinternal.h>
69711 +
69712 +int
69713 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69714 + const struct dentry *dir, const int flag, const int acc_mode)
69715 +{
69716 +#ifdef CONFIG_GRKERNSEC_FIFO
69717 + const struct cred *cred = current_cred();
69718 +
69719 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69720 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69721 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69722 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69723 + if (!inode_permission(dentry->d_inode, acc_mode))
69724 + 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));
69725 + return -EACCES;
69726 + }
69727 +#endif
69728 + return 0;
69729 +}
69730 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69731 new file mode 100644
69732 index 0000000..8ca18bf
69733 --- /dev/null
69734 +++ b/grsecurity/grsec_fork.c
69735 @@ -0,0 +1,23 @@
69736 +#include <linux/kernel.h>
69737 +#include <linux/sched.h>
69738 +#include <linux/grsecurity.h>
69739 +#include <linux/grinternal.h>
69740 +#include <linux/errno.h>
69741 +
69742 +void
69743 +gr_log_forkfail(const int retval)
69744 +{
69745 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69746 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69747 + switch (retval) {
69748 + case -EAGAIN:
69749 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69750 + break;
69751 + case -ENOMEM:
69752 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69753 + break;
69754 + }
69755 + }
69756 +#endif
69757 + return;
69758 +}
69759 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69760 new file mode 100644
69761 index 0000000..a88e901
69762 --- /dev/null
69763 +++ b/grsecurity/grsec_init.c
69764 @@ -0,0 +1,272 @@
69765 +#include <linux/kernel.h>
69766 +#include <linux/sched.h>
69767 +#include <linux/mm.h>
69768 +#include <linux/gracl.h>
69769 +#include <linux/slab.h>
69770 +#include <linux/vmalloc.h>
69771 +#include <linux/percpu.h>
69772 +#include <linux/module.h>
69773 +
69774 +int grsec_enable_ptrace_readexec;
69775 +int grsec_enable_setxid;
69776 +int grsec_enable_symlinkown;
69777 +kgid_t grsec_symlinkown_gid;
69778 +int grsec_enable_brute;
69779 +int grsec_enable_link;
69780 +int grsec_enable_dmesg;
69781 +int grsec_enable_harden_ptrace;
69782 +int grsec_enable_harden_ipc;
69783 +int grsec_enable_fifo;
69784 +int grsec_enable_execlog;
69785 +int grsec_enable_signal;
69786 +int grsec_enable_forkfail;
69787 +int grsec_enable_audit_ptrace;
69788 +int grsec_enable_time;
69789 +int grsec_enable_group;
69790 +kgid_t grsec_audit_gid;
69791 +int grsec_enable_chdir;
69792 +int grsec_enable_mount;
69793 +int grsec_enable_rofs;
69794 +int grsec_deny_new_usb;
69795 +int grsec_enable_chroot_findtask;
69796 +int grsec_enable_chroot_mount;
69797 +int grsec_enable_chroot_shmat;
69798 +int grsec_enable_chroot_fchdir;
69799 +int grsec_enable_chroot_double;
69800 +int grsec_enable_chroot_pivot;
69801 +int grsec_enable_chroot_chdir;
69802 +int grsec_enable_chroot_chmod;
69803 +int grsec_enable_chroot_mknod;
69804 +int grsec_enable_chroot_nice;
69805 +int grsec_enable_chroot_execlog;
69806 +int grsec_enable_chroot_caps;
69807 +int grsec_enable_chroot_sysctl;
69808 +int grsec_enable_chroot_unix;
69809 +int grsec_enable_tpe;
69810 +kgid_t grsec_tpe_gid;
69811 +int grsec_enable_blackhole;
69812 +#ifdef CONFIG_IPV6_MODULE
69813 +EXPORT_SYMBOL(grsec_enable_blackhole);
69814 +#endif
69815 +int grsec_lastack_retries;
69816 +int grsec_enable_tpe_all;
69817 +int grsec_enable_tpe_invert;
69818 +int grsec_enable_socket_all;
69819 +kgid_t grsec_socket_all_gid;
69820 +int grsec_enable_socket_client;
69821 +kgid_t grsec_socket_client_gid;
69822 +int grsec_enable_socket_server;
69823 +kgid_t grsec_socket_server_gid;
69824 +int grsec_resource_logging;
69825 +int grsec_disable_privio;
69826 +int grsec_enable_log_rwxmaps;
69827 +int grsec_lock;
69828 +
69829 +DEFINE_SPINLOCK(grsec_alert_lock);
69830 +unsigned long grsec_alert_wtime = 0;
69831 +unsigned long grsec_alert_fyet = 0;
69832 +
69833 +DEFINE_SPINLOCK(grsec_audit_lock);
69834 +
69835 +DEFINE_RWLOCK(grsec_exec_file_lock);
69836 +
69837 +char *gr_shared_page[4];
69838 +
69839 +char *gr_alert_log_fmt;
69840 +char *gr_audit_log_fmt;
69841 +char *gr_alert_log_buf;
69842 +char *gr_audit_log_buf;
69843 +
69844 +void __init
69845 +grsecurity_init(void)
69846 +{
69847 + int j;
69848 + /* create the per-cpu shared pages */
69849 +
69850 +#ifdef CONFIG_X86
69851 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69852 +#endif
69853 +
69854 + for (j = 0; j < 4; j++) {
69855 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69856 + if (gr_shared_page[j] == NULL) {
69857 + panic("Unable to allocate grsecurity shared page");
69858 + return;
69859 + }
69860 + }
69861 +
69862 + /* allocate log buffers */
69863 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69864 + if (!gr_alert_log_fmt) {
69865 + panic("Unable to allocate grsecurity alert log format buffer");
69866 + return;
69867 + }
69868 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69869 + if (!gr_audit_log_fmt) {
69870 + panic("Unable to allocate grsecurity audit log format buffer");
69871 + return;
69872 + }
69873 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69874 + if (!gr_alert_log_buf) {
69875 + panic("Unable to allocate grsecurity alert log buffer");
69876 + return;
69877 + }
69878 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69879 + if (!gr_audit_log_buf) {
69880 + panic("Unable to allocate grsecurity audit log buffer");
69881 + return;
69882 + }
69883 +
69884 +#ifdef CONFIG_GRKERNSEC_IO
69885 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69886 + grsec_disable_privio = 1;
69887 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69888 + grsec_disable_privio = 1;
69889 +#else
69890 + grsec_disable_privio = 0;
69891 +#endif
69892 +#endif
69893 +
69894 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69895 + /* for backward compatibility, tpe_invert always defaults to on if
69896 + enabled in the kernel
69897 + */
69898 + grsec_enable_tpe_invert = 1;
69899 +#endif
69900 +
69901 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69902 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69903 + grsec_lock = 1;
69904 +#endif
69905 +
69906 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69907 + grsec_enable_log_rwxmaps = 1;
69908 +#endif
69909 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69910 + grsec_enable_group = 1;
69911 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69912 +#endif
69913 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69914 + grsec_enable_ptrace_readexec = 1;
69915 +#endif
69916 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69917 + grsec_enable_chdir = 1;
69918 +#endif
69919 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69920 + grsec_enable_harden_ptrace = 1;
69921 +#endif
69922 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
69923 + grsec_enable_harden_ipc = 1;
69924 +#endif
69925 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69926 + grsec_enable_mount = 1;
69927 +#endif
69928 +#ifdef CONFIG_GRKERNSEC_LINK
69929 + grsec_enable_link = 1;
69930 +#endif
69931 +#ifdef CONFIG_GRKERNSEC_BRUTE
69932 + grsec_enable_brute = 1;
69933 +#endif
69934 +#ifdef CONFIG_GRKERNSEC_DMESG
69935 + grsec_enable_dmesg = 1;
69936 +#endif
69937 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69938 + grsec_enable_blackhole = 1;
69939 + grsec_lastack_retries = 4;
69940 +#endif
69941 +#ifdef CONFIG_GRKERNSEC_FIFO
69942 + grsec_enable_fifo = 1;
69943 +#endif
69944 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69945 + grsec_enable_execlog = 1;
69946 +#endif
69947 +#ifdef CONFIG_GRKERNSEC_SETXID
69948 + grsec_enable_setxid = 1;
69949 +#endif
69950 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69951 + grsec_enable_signal = 1;
69952 +#endif
69953 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69954 + grsec_enable_forkfail = 1;
69955 +#endif
69956 +#ifdef CONFIG_GRKERNSEC_TIME
69957 + grsec_enable_time = 1;
69958 +#endif
69959 +#ifdef CONFIG_GRKERNSEC_RESLOG
69960 + grsec_resource_logging = 1;
69961 +#endif
69962 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69963 + grsec_enable_chroot_findtask = 1;
69964 +#endif
69965 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69966 + grsec_enable_chroot_unix = 1;
69967 +#endif
69968 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69969 + grsec_enable_chroot_mount = 1;
69970 +#endif
69971 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69972 + grsec_enable_chroot_fchdir = 1;
69973 +#endif
69974 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69975 + grsec_enable_chroot_shmat = 1;
69976 +#endif
69977 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69978 + grsec_enable_audit_ptrace = 1;
69979 +#endif
69980 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69981 + grsec_enable_chroot_double = 1;
69982 +#endif
69983 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69984 + grsec_enable_chroot_pivot = 1;
69985 +#endif
69986 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69987 + grsec_enable_chroot_chdir = 1;
69988 +#endif
69989 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69990 + grsec_enable_chroot_chmod = 1;
69991 +#endif
69992 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69993 + grsec_enable_chroot_mknod = 1;
69994 +#endif
69995 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69996 + grsec_enable_chroot_nice = 1;
69997 +#endif
69998 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69999 + grsec_enable_chroot_execlog = 1;
70000 +#endif
70001 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70002 + grsec_enable_chroot_caps = 1;
70003 +#endif
70004 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70005 + grsec_enable_chroot_sysctl = 1;
70006 +#endif
70007 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70008 + grsec_enable_symlinkown = 1;
70009 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
70010 +#endif
70011 +#ifdef CONFIG_GRKERNSEC_TPE
70012 + grsec_enable_tpe = 1;
70013 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
70014 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70015 + grsec_enable_tpe_all = 1;
70016 +#endif
70017 +#endif
70018 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70019 + grsec_enable_socket_all = 1;
70020 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
70021 +#endif
70022 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70023 + grsec_enable_socket_client = 1;
70024 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
70025 +#endif
70026 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70027 + grsec_enable_socket_server = 1;
70028 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
70029 +#endif
70030 +#endif
70031 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
70032 + grsec_deny_new_usb = 1;
70033 +#endif
70034 +
70035 + return;
70036 +}
70037 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
70038 new file mode 100644
70039 index 0000000..f365de0
70040 --- /dev/null
70041 +++ b/grsecurity/grsec_ipc.c
70042 @@ -0,0 +1,22 @@
70043 +#include <linux/kernel.h>
70044 +#include <linux/mm.h>
70045 +#include <linux/sched.h>
70046 +#include <linux/file.h>
70047 +#include <linux/ipc.h>
70048 +#include <linux/ipc_namespace.h>
70049 +#include <linux/grsecurity.h>
70050 +#include <linux/grinternal.h>
70051 +
70052 +int
70053 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
70054 +{
70055 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70056 + int write = (requested_mode & 00002);
70057 +
70058 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
70059 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
70060 + return 0;
70061 + }
70062 +#endif
70063 + return 1;
70064 +}
70065 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
70066 new file mode 100644
70067 index 0000000..5e05e20
70068 --- /dev/null
70069 +++ b/grsecurity/grsec_link.c
70070 @@ -0,0 +1,58 @@
70071 +#include <linux/kernel.h>
70072 +#include <linux/sched.h>
70073 +#include <linux/fs.h>
70074 +#include <linux/file.h>
70075 +#include <linux/grinternal.h>
70076 +
70077 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
70078 +{
70079 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70080 + const struct inode *link_inode = link->dentry->d_inode;
70081 +
70082 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
70083 + /* ignore root-owned links, e.g. /proc/self */
70084 + gr_is_global_nonroot(link_inode->i_uid) && target &&
70085 + !uid_eq(link_inode->i_uid, target->i_uid)) {
70086 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
70087 + return 1;
70088 + }
70089 +#endif
70090 + return 0;
70091 +}
70092 +
70093 +int
70094 +gr_handle_follow_link(const struct inode *parent,
70095 + const struct inode *inode,
70096 + const struct dentry *dentry, const struct vfsmount *mnt)
70097 +{
70098 +#ifdef CONFIG_GRKERNSEC_LINK
70099 + const struct cred *cred = current_cred();
70100 +
70101 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
70102 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
70103 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
70104 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
70105 + return -EACCES;
70106 + }
70107 +#endif
70108 + return 0;
70109 +}
70110 +
70111 +int
70112 +gr_handle_hardlink(const struct dentry *dentry,
70113 + const struct vfsmount *mnt,
70114 + struct inode *inode, const int mode, const struct filename *to)
70115 +{
70116 +#ifdef CONFIG_GRKERNSEC_LINK
70117 + const struct cred *cred = current_cred();
70118 +
70119 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
70120 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
70121 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
70122 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
70123 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
70124 + return -EPERM;
70125 + }
70126 +#endif
70127 + return 0;
70128 +}
70129 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
70130 new file mode 100644
70131 index 0000000..dbe0a6b
70132 --- /dev/null
70133 +++ b/grsecurity/grsec_log.c
70134 @@ -0,0 +1,341 @@
70135 +#include <linux/kernel.h>
70136 +#include <linux/sched.h>
70137 +#include <linux/file.h>
70138 +#include <linux/tty.h>
70139 +#include <linux/fs.h>
70140 +#include <linux/mm.h>
70141 +#include <linux/grinternal.h>
70142 +
70143 +#ifdef CONFIG_TREE_PREEMPT_RCU
70144 +#define DISABLE_PREEMPT() preempt_disable()
70145 +#define ENABLE_PREEMPT() preempt_enable()
70146 +#else
70147 +#define DISABLE_PREEMPT()
70148 +#define ENABLE_PREEMPT()
70149 +#endif
70150 +
70151 +#define BEGIN_LOCKS(x) \
70152 + DISABLE_PREEMPT(); \
70153 + rcu_read_lock(); \
70154 + read_lock(&tasklist_lock); \
70155 + read_lock(&grsec_exec_file_lock); \
70156 + if (x != GR_DO_AUDIT) \
70157 + spin_lock(&grsec_alert_lock); \
70158 + else \
70159 + spin_lock(&grsec_audit_lock)
70160 +
70161 +#define END_LOCKS(x) \
70162 + if (x != GR_DO_AUDIT) \
70163 + spin_unlock(&grsec_alert_lock); \
70164 + else \
70165 + spin_unlock(&grsec_audit_lock); \
70166 + read_unlock(&grsec_exec_file_lock); \
70167 + read_unlock(&tasklist_lock); \
70168 + rcu_read_unlock(); \
70169 + ENABLE_PREEMPT(); \
70170 + if (x == GR_DONT_AUDIT) \
70171 + gr_handle_alertkill(current)
70172 +
70173 +enum {
70174 + FLOODING,
70175 + NO_FLOODING
70176 +};
70177 +
70178 +extern char *gr_alert_log_fmt;
70179 +extern char *gr_audit_log_fmt;
70180 +extern char *gr_alert_log_buf;
70181 +extern char *gr_audit_log_buf;
70182 +
70183 +static int gr_log_start(int audit)
70184 +{
70185 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
70186 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
70187 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70188 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
70189 + unsigned long curr_secs = get_seconds();
70190 +
70191 + if (audit == GR_DO_AUDIT)
70192 + goto set_fmt;
70193 +
70194 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
70195 + grsec_alert_wtime = curr_secs;
70196 + grsec_alert_fyet = 0;
70197 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
70198 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
70199 + grsec_alert_fyet++;
70200 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
70201 + grsec_alert_wtime = curr_secs;
70202 + grsec_alert_fyet++;
70203 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
70204 + return FLOODING;
70205 + }
70206 + else return FLOODING;
70207 +
70208 +set_fmt:
70209 +#endif
70210 + memset(buf, 0, PAGE_SIZE);
70211 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
70212 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
70213 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70214 + } else if (current->signal->curr_ip) {
70215 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
70216 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
70217 + } else if (gr_acl_is_enabled()) {
70218 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
70219 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70220 + } else {
70221 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
70222 + strcpy(buf, fmt);
70223 + }
70224 +
70225 + return NO_FLOODING;
70226 +}
70227 +
70228 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70229 + __attribute__ ((format (printf, 2, 0)));
70230 +
70231 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70232 +{
70233 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70234 + unsigned int len = strlen(buf);
70235 +
70236 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70237 +
70238 + return;
70239 +}
70240 +
70241 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70242 + __attribute__ ((format (printf, 2, 3)));
70243 +
70244 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70245 +{
70246 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70247 + unsigned int len = strlen(buf);
70248 + va_list ap;
70249 +
70250 + va_start(ap, msg);
70251 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70252 + va_end(ap);
70253 +
70254 + return;
70255 +}
70256 +
70257 +static void gr_log_end(int audit, int append_default)
70258 +{
70259 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70260 + if (append_default) {
70261 + struct task_struct *task = current;
70262 + struct task_struct *parent = task->real_parent;
70263 + const struct cred *cred = __task_cred(task);
70264 + const struct cred *pcred = __task_cred(parent);
70265 + unsigned int len = strlen(buf);
70266 +
70267 + 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));
70268 + }
70269 +
70270 + printk("%s\n", buf);
70271 +
70272 + return;
70273 +}
70274 +
70275 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70276 +{
70277 + int logtype;
70278 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70279 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70280 + void *voidptr = NULL;
70281 + int num1 = 0, num2 = 0;
70282 + unsigned long ulong1 = 0, ulong2 = 0;
70283 + struct dentry *dentry = NULL;
70284 + struct vfsmount *mnt = NULL;
70285 + struct file *file = NULL;
70286 + struct task_struct *task = NULL;
70287 + struct vm_area_struct *vma = NULL;
70288 + const struct cred *cred, *pcred;
70289 + va_list ap;
70290 +
70291 + BEGIN_LOCKS(audit);
70292 + logtype = gr_log_start(audit);
70293 + if (logtype == FLOODING) {
70294 + END_LOCKS(audit);
70295 + return;
70296 + }
70297 + va_start(ap, argtypes);
70298 + switch (argtypes) {
70299 + case GR_TTYSNIFF:
70300 + task = va_arg(ap, struct task_struct *);
70301 + 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));
70302 + break;
70303 + case GR_SYSCTL_HIDDEN:
70304 + str1 = va_arg(ap, char *);
70305 + gr_log_middle_varargs(audit, msg, result, str1);
70306 + break;
70307 + case GR_RBAC:
70308 + dentry = va_arg(ap, struct dentry *);
70309 + mnt = va_arg(ap, struct vfsmount *);
70310 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70311 + break;
70312 + case GR_RBAC_STR:
70313 + dentry = va_arg(ap, struct dentry *);
70314 + mnt = va_arg(ap, struct vfsmount *);
70315 + str1 = va_arg(ap, char *);
70316 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70317 + break;
70318 + case GR_STR_RBAC:
70319 + str1 = va_arg(ap, char *);
70320 + dentry = va_arg(ap, struct dentry *);
70321 + mnt = va_arg(ap, struct vfsmount *);
70322 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70323 + break;
70324 + case GR_RBAC_MODE2:
70325 + dentry = va_arg(ap, struct dentry *);
70326 + mnt = va_arg(ap, struct vfsmount *);
70327 + str1 = va_arg(ap, char *);
70328 + str2 = va_arg(ap, char *);
70329 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70330 + break;
70331 + case GR_RBAC_MODE3:
70332 + dentry = va_arg(ap, struct dentry *);
70333 + mnt = va_arg(ap, struct vfsmount *);
70334 + str1 = va_arg(ap, char *);
70335 + str2 = va_arg(ap, char *);
70336 + str3 = va_arg(ap, char *);
70337 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70338 + break;
70339 + case GR_FILENAME:
70340 + dentry = va_arg(ap, struct dentry *);
70341 + mnt = va_arg(ap, struct vfsmount *);
70342 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70343 + break;
70344 + case GR_STR_FILENAME:
70345 + str1 = va_arg(ap, char *);
70346 + dentry = va_arg(ap, struct dentry *);
70347 + mnt = va_arg(ap, struct vfsmount *);
70348 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70349 + break;
70350 + case GR_FILENAME_STR:
70351 + dentry = va_arg(ap, struct dentry *);
70352 + mnt = va_arg(ap, struct vfsmount *);
70353 + str1 = va_arg(ap, char *);
70354 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70355 + break;
70356 + case GR_FILENAME_TWO_INT:
70357 + dentry = va_arg(ap, struct dentry *);
70358 + mnt = va_arg(ap, struct vfsmount *);
70359 + num1 = va_arg(ap, int);
70360 + num2 = va_arg(ap, int);
70361 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70362 + break;
70363 + case GR_FILENAME_TWO_INT_STR:
70364 + dentry = va_arg(ap, struct dentry *);
70365 + mnt = va_arg(ap, struct vfsmount *);
70366 + num1 = va_arg(ap, int);
70367 + num2 = va_arg(ap, int);
70368 + str1 = va_arg(ap, char *);
70369 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70370 + break;
70371 + case GR_TEXTREL:
70372 + file = va_arg(ap, struct file *);
70373 + ulong1 = va_arg(ap, unsigned long);
70374 + ulong2 = va_arg(ap, unsigned long);
70375 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70376 + break;
70377 + case GR_PTRACE:
70378 + task = va_arg(ap, struct task_struct *);
70379 + 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));
70380 + break;
70381 + case GR_RESOURCE:
70382 + task = va_arg(ap, struct task_struct *);
70383 + cred = __task_cred(task);
70384 + pcred = __task_cred(task->real_parent);
70385 + ulong1 = va_arg(ap, unsigned long);
70386 + str1 = va_arg(ap, char *);
70387 + ulong2 = va_arg(ap, unsigned long);
70388 + 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));
70389 + break;
70390 + case GR_CAP:
70391 + task = va_arg(ap, struct task_struct *);
70392 + cred = __task_cred(task);
70393 + pcred = __task_cred(task->real_parent);
70394 + str1 = va_arg(ap, char *);
70395 + 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));
70396 + break;
70397 + case GR_SIG:
70398 + str1 = va_arg(ap, char *);
70399 + voidptr = va_arg(ap, void *);
70400 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70401 + break;
70402 + case GR_SIG2:
70403 + task = va_arg(ap, struct task_struct *);
70404 + cred = __task_cred(task);
70405 + pcred = __task_cred(task->real_parent);
70406 + num1 = va_arg(ap, int);
70407 + 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));
70408 + break;
70409 + case GR_CRASH1:
70410 + task = va_arg(ap, struct task_struct *);
70411 + cred = __task_cred(task);
70412 + pcred = __task_cred(task->real_parent);
70413 + ulong1 = va_arg(ap, unsigned long);
70414 + 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);
70415 + break;
70416 + case GR_CRASH2:
70417 + task = va_arg(ap, struct task_struct *);
70418 + cred = __task_cred(task);
70419 + pcred = __task_cred(task->real_parent);
70420 + ulong1 = va_arg(ap, unsigned long);
70421 + 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);
70422 + break;
70423 + case GR_RWXMAP:
70424 + file = va_arg(ap, struct file *);
70425 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70426 + break;
70427 + case GR_RWXMAPVMA:
70428 + vma = va_arg(ap, struct vm_area_struct *);
70429 + if (vma->vm_file)
70430 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70431 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70432 + str1 = "<stack>";
70433 + else if (vma->vm_start <= current->mm->brk &&
70434 + vma->vm_end >= current->mm->start_brk)
70435 + str1 = "<heap>";
70436 + else
70437 + str1 = "<anonymous mapping>";
70438 + gr_log_middle_varargs(audit, msg, str1);
70439 + break;
70440 + case GR_PSACCT:
70441 + {
70442 + unsigned int wday, cday;
70443 + __u8 whr, chr;
70444 + __u8 wmin, cmin;
70445 + __u8 wsec, csec;
70446 + char cur_tty[64] = { 0 };
70447 + char parent_tty[64] = { 0 };
70448 +
70449 + task = va_arg(ap, struct task_struct *);
70450 + wday = va_arg(ap, unsigned int);
70451 + cday = va_arg(ap, unsigned int);
70452 + whr = va_arg(ap, int);
70453 + chr = va_arg(ap, int);
70454 + wmin = va_arg(ap, int);
70455 + cmin = va_arg(ap, int);
70456 + wsec = va_arg(ap, int);
70457 + csec = va_arg(ap, int);
70458 + ulong1 = va_arg(ap, unsigned long);
70459 + cred = __task_cred(task);
70460 + pcred = __task_cred(task->real_parent);
70461 +
70462 + 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));
70463 + }
70464 + break;
70465 + default:
70466 + gr_log_middle(audit, msg, ap);
70467 + }
70468 + va_end(ap);
70469 + // these don't need DEFAULTSECARGS printed on the end
70470 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70471 + gr_log_end(audit, 0);
70472 + else
70473 + gr_log_end(audit, 1);
70474 + END_LOCKS(audit);
70475 +}
70476 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70477 new file mode 100644
70478 index 0000000..f536303
70479 --- /dev/null
70480 +++ b/grsecurity/grsec_mem.c
70481 @@ -0,0 +1,40 @@
70482 +#include <linux/kernel.h>
70483 +#include <linux/sched.h>
70484 +#include <linux/mm.h>
70485 +#include <linux/mman.h>
70486 +#include <linux/grinternal.h>
70487 +
70488 +void
70489 +gr_handle_ioperm(void)
70490 +{
70491 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70492 + return;
70493 +}
70494 +
70495 +void
70496 +gr_handle_iopl(void)
70497 +{
70498 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70499 + return;
70500 +}
70501 +
70502 +void
70503 +gr_handle_mem_readwrite(u64 from, u64 to)
70504 +{
70505 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70506 + return;
70507 +}
70508 +
70509 +void
70510 +gr_handle_vm86(void)
70511 +{
70512 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70513 + return;
70514 +}
70515 +
70516 +void
70517 +gr_log_badprocpid(const char *entry)
70518 +{
70519 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70520 + return;
70521 +}
70522 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70523 new file mode 100644
70524 index 0000000..2131422
70525 --- /dev/null
70526 +++ b/grsecurity/grsec_mount.c
70527 @@ -0,0 +1,62 @@
70528 +#include <linux/kernel.h>
70529 +#include <linux/sched.h>
70530 +#include <linux/mount.h>
70531 +#include <linux/grsecurity.h>
70532 +#include <linux/grinternal.h>
70533 +
70534 +void
70535 +gr_log_remount(const char *devname, const int retval)
70536 +{
70537 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70538 + if (grsec_enable_mount && (retval >= 0))
70539 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70540 +#endif
70541 + return;
70542 +}
70543 +
70544 +void
70545 +gr_log_unmount(const char *devname, const int retval)
70546 +{
70547 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70548 + if (grsec_enable_mount && (retval >= 0))
70549 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70550 +#endif
70551 + return;
70552 +}
70553 +
70554 +void
70555 +gr_log_mount(const char *from, const char *to, const int retval)
70556 +{
70557 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70558 + if (grsec_enable_mount && (retval >= 0))
70559 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70560 +#endif
70561 + return;
70562 +}
70563 +
70564 +int
70565 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70566 +{
70567 +#ifdef CONFIG_GRKERNSEC_ROFS
70568 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70569 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70570 + return -EPERM;
70571 + } else
70572 + return 0;
70573 +#endif
70574 + return 0;
70575 +}
70576 +
70577 +int
70578 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70579 +{
70580 +#ifdef CONFIG_GRKERNSEC_ROFS
70581 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70582 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70583 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70584 + return -EPERM;
70585 + } else
70586 + return 0;
70587 +#endif
70588 + return 0;
70589 +}
70590 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70591 new file mode 100644
70592 index 0000000..6ee9d50
70593 --- /dev/null
70594 +++ b/grsecurity/grsec_pax.c
70595 @@ -0,0 +1,45 @@
70596 +#include <linux/kernel.h>
70597 +#include <linux/sched.h>
70598 +#include <linux/mm.h>
70599 +#include <linux/file.h>
70600 +#include <linux/grinternal.h>
70601 +#include <linux/grsecurity.h>
70602 +
70603 +void
70604 +gr_log_textrel(struct vm_area_struct * vma)
70605 +{
70606 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70607 + if (grsec_enable_log_rwxmaps)
70608 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70609 +#endif
70610 + return;
70611 +}
70612 +
70613 +void gr_log_ptgnustack(struct file *file)
70614 +{
70615 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70616 + if (grsec_enable_log_rwxmaps)
70617 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70618 +#endif
70619 + return;
70620 +}
70621 +
70622 +void
70623 +gr_log_rwxmmap(struct file *file)
70624 +{
70625 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70626 + if (grsec_enable_log_rwxmaps)
70627 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70628 +#endif
70629 + return;
70630 +}
70631 +
70632 +void
70633 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70634 +{
70635 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70636 + if (grsec_enable_log_rwxmaps)
70637 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70638 +#endif
70639 + return;
70640 +}
70641 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70642 new file mode 100644
70643 index 0000000..f7f29aa
70644 --- /dev/null
70645 +++ b/grsecurity/grsec_ptrace.c
70646 @@ -0,0 +1,30 @@
70647 +#include <linux/kernel.h>
70648 +#include <linux/sched.h>
70649 +#include <linux/grinternal.h>
70650 +#include <linux/security.h>
70651 +
70652 +void
70653 +gr_audit_ptrace(struct task_struct *task)
70654 +{
70655 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70656 + if (grsec_enable_audit_ptrace)
70657 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70658 +#endif
70659 + return;
70660 +}
70661 +
70662 +int
70663 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70664 +{
70665 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70666 + const struct dentry *dentry = file->f_path.dentry;
70667 + const struct vfsmount *mnt = file->f_path.mnt;
70668 +
70669 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70670 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70671 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70672 + return -EACCES;
70673 + }
70674 +#endif
70675 + return 0;
70676 +}
70677 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70678 new file mode 100644
70679 index 0000000..4e29cc7
70680 --- /dev/null
70681 +++ b/grsecurity/grsec_sig.c
70682 @@ -0,0 +1,246 @@
70683 +#include <linux/kernel.h>
70684 +#include <linux/sched.h>
70685 +#include <linux/fs.h>
70686 +#include <linux/delay.h>
70687 +#include <linux/grsecurity.h>
70688 +#include <linux/grinternal.h>
70689 +#include <linux/hardirq.h>
70690 +
70691 +char *signames[] = {
70692 + [SIGSEGV] = "Segmentation fault",
70693 + [SIGILL] = "Illegal instruction",
70694 + [SIGABRT] = "Abort",
70695 + [SIGBUS] = "Invalid alignment/Bus error"
70696 +};
70697 +
70698 +void
70699 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70700 +{
70701 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70702 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70703 + (sig == SIGABRT) || (sig == SIGBUS))) {
70704 + if (task_pid_nr(t) == task_pid_nr(current)) {
70705 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70706 + } else {
70707 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70708 + }
70709 + }
70710 +#endif
70711 + return;
70712 +}
70713 +
70714 +int
70715 +gr_handle_signal(const struct task_struct *p, const int sig)
70716 +{
70717 +#ifdef CONFIG_GRKERNSEC
70718 + /* ignore the 0 signal for protected task checks */
70719 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70720 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70721 + return -EPERM;
70722 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70723 + return -EPERM;
70724 + }
70725 +#endif
70726 + return 0;
70727 +}
70728 +
70729 +#ifdef CONFIG_GRKERNSEC
70730 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70731 +
70732 +int gr_fake_force_sig(int sig, struct task_struct *t)
70733 +{
70734 + unsigned long int flags;
70735 + int ret, blocked, ignored;
70736 + struct k_sigaction *action;
70737 +
70738 + spin_lock_irqsave(&t->sighand->siglock, flags);
70739 + action = &t->sighand->action[sig-1];
70740 + ignored = action->sa.sa_handler == SIG_IGN;
70741 + blocked = sigismember(&t->blocked, sig);
70742 + if (blocked || ignored) {
70743 + action->sa.sa_handler = SIG_DFL;
70744 + if (blocked) {
70745 + sigdelset(&t->blocked, sig);
70746 + recalc_sigpending_and_wake(t);
70747 + }
70748 + }
70749 + if (action->sa.sa_handler == SIG_DFL)
70750 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70751 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70752 +
70753 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70754 +
70755 + return ret;
70756 +}
70757 +#endif
70758 +
70759 +#ifdef CONFIG_GRKERNSEC_BRUTE
70760 +#define GR_USER_BAN_TIME (15 * 60)
70761 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70762 +
70763 +static int __get_dumpable(unsigned long mm_flags)
70764 +{
70765 + int ret;
70766 +
70767 + ret = mm_flags & MMF_DUMPABLE_MASK;
70768 + return (ret >= 2) ? 2 : ret;
70769 +}
70770 +#endif
70771 +
70772 +void gr_handle_brute_attach(unsigned long mm_flags)
70773 +{
70774 +#ifdef CONFIG_GRKERNSEC_BRUTE
70775 + struct task_struct *p = current;
70776 + kuid_t uid = GLOBAL_ROOT_UID;
70777 + int daemon = 0;
70778 +
70779 + if (!grsec_enable_brute)
70780 + return;
70781 +
70782 + rcu_read_lock();
70783 + read_lock(&tasklist_lock);
70784 + read_lock(&grsec_exec_file_lock);
70785 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70786 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70787 + p->real_parent->brute = 1;
70788 + daemon = 1;
70789 + } else {
70790 + const struct cred *cred = __task_cred(p), *cred2;
70791 + struct task_struct *tsk, *tsk2;
70792 +
70793 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70794 + struct user_struct *user;
70795 +
70796 + uid = cred->uid;
70797 +
70798 + /* this is put upon execution past expiration */
70799 + user = find_user(uid);
70800 + if (user == NULL)
70801 + goto unlock;
70802 + user->suid_banned = 1;
70803 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70804 + if (user->suid_ban_expires == ~0UL)
70805 + user->suid_ban_expires--;
70806 +
70807 + /* only kill other threads of the same binary, from the same user */
70808 + do_each_thread(tsk2, tsk) {
70809 + cred2 = __task_cred(tsk);
70810 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70811 + gr_fake_force_sig(SIGKILL, tsk);
70812 + } while_each_thread(tsk2, tsk);
70813 + }
70814 + }
70815 +unlock:
70816 + read_unlock(&grsec_exec_file_lock);
70817 + read_unlock(&tasklist_lock);
70818 + rcu_read_unlock();
70819 +
70820 + if (gr_is_global_nonroot(uid))
70821 + 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);
70822 + else if (daemon)
70823 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70824 +
70825 +#endif
70826 + return;
70827 +}
70828 +
70829 +void gr_handle_brute_check(void)
70830 +{
70831 +#ifdef CONFIG_GRKERNSEC_BRUTE
70832 + struct task_struct *p = current;
70833 +
70834 + if (unlikely(p->brute)) {
70835 + if (!grsec_enable_brute)
70836 + p->brute = 0;
70837 + else if (time_before(get_seconds(), p->brute_expires))
70838 + msleep(30 * 1000);
70839 + }
70840 +#endif
70841 + return;
70842 +}
70843 +
70844 +void gr_handle_kernel_exploit(void)
70845 +{
70846 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70847 + const struct cred *cred;
70848 + struct task_struct *tsk, *tsk2;
70849 + struct user_struct *user;
70850 + kuid_t uid;
70851 +
70852 + if (in_irq() || in_serving_softirq() || in_nmi())
70853 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70854 +
70855 + uid = current_uid();
70856 +
70857 + if (gr_is_global_root(uid))
70858 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70859 + else {
70860 + /* kill all the processes of this user, hold a reference
70861 + to their creds struct, and prevent them from creating
70862 + another process until system reset
70863 + */
70864 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70865 + GR_GLOBAL_UID(uid));
70866 + /* we intentionally leak this ref */
70867 + user = get_uid(current->cred->user);
70868 + if (user)
70869 + user->kernel_banned = 1;
70870 +
70871 + /* kill all processes of this user */
70872 + read_lock(&tasklist_lock);
70873 + do_each_thread(tsk2, tsk) {
70874 + cred = __task_cred(tsk);
70875 + if (uid_eq(cred->uid, uid))
70876 + gr_fake_force_sig(SIGKILL, tsk);
70877 + } while_each_thread(tsk2, tsk);
70878 + read_unlock(&tasklist_lock);
70879 + }
70880 +#endif
70881 +}
70882 +
70883 +#ifdef CONFIG_GRKERNSEC_BRUTE
70884 +static bool suid_ban_expired(struct user_struct *user)
70885 +{
70886 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70887 + user->suid_banned = 0;
70888 + user->suid_ban_expires = 0;
70889 + free_uid(user);
70890 + return true;
70891 + }
70892 +
70893 + return false;
70894 +}
70895 +#endif
70896 +
70897 +int gr_process_kernel_exec_ban(void)
70898 +{
70899 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70900 + if (unlikely(current->cred->user->kernel_banned))
70901 + return -EPERM;
70902 +#endif
70903 + return 0;
70904 +}
70905 +
70906 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70907 +{
70908 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70909 + if (unlikely(user->kernel_banned))
70910 + gr_fake_force_sig(SIGKILL, current);
70911 +#endif
70912 + return 0;
70913 +}
70914 +
70915 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70916 +{
70917 +#ifdef CONFIG_GRKERNSEC_BRUTE
70918 + struct user_struct *user = current->cred->user;
70919 + if (unlikely(user->suid_banned)) {
70920 + if (suid_ban_expired(user))
70921 + return 0;
70922 + /* disallow execution of suid binaries only */
70923 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70924 + return -EPERM;
70925 + }
70926 +#endif
70927 + return 0;
70928 +}
70929 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70930 new file mode 100644
70931 index 0000000..4030d57
70932 --- /dev/null
70933 +++ b/grsecurity/grsec_sock.c
70934 @@ -0,0 +1,244 @@
70935 +#include <linux/kernel.h>
70936 +#include <linux/module.h>
70937 +#include <linux/sched.h>
70938 +#include <linux/file.h>
70939 +#include <linux/net.h>
70940 +#include <linux/in.h>
70941 +#include <linux/ip.h>
70942 +#include <net/sock.h>
70943 +#include <net/inet_sock.h>
70944 +#include <linux/grsecurity.h>
70945 +#include <linux/grinternal.h>
70946 +#include <linux/gracl.h>
70947 +
70948 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70949 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70950 +
70951 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70952 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70953 +
70954 +#ifdef CONFIG_UNIX_MODULE
70955 +EXPORT_SYMBOL(gr_acl_handle_unix);
70956 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70957 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70958 +EXPORT_SYMBOL(gr_handle_create);
70959 +#endif
70960 +
70961 +#ifdef CONFIG_GRKERNSEC
70962 +#define gr_conn_table_size 32749
70963 +struct conn_table_entry {
70964 + struct conn_table_entry *next;
70965 + struct signal_struct *sig;
70966 +};
70967 +
70968 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70969 +DEFINE_SPINLOCK(gr_conn_table_lock);
70970 +
70971 +extern const char * gr_socktype_to_name(unsigned char type);
70972 +extern const char * gr_proto_to_name(unsigned char proto);
70973 +extern const char * gr_sockfamily_to_name(unsigned char family);
70974 +
70975 +static __inline__ int
70976 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70977 +{
70978 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70979 +}
70980 +
70981 +static __inline__ int
70982 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70983 + __u16 sport, __u16 dport)
70984 +{
70985 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70986 + sig->gr_sport == sport && sig->gr_dport == dport))
70987 + return 1;
70988 + else
70989 + return 0;
70990 +}
70991 +
70992 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70993 +{
70994 + struct conn_table_entry **match;
70995 + unsigned int index;
70996 +
70997 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70998 + sig->gr_sport, sig->gr_dport,
70999 + gr_conn_table_size);
71000 +
71001 + newent->sig = sig;
71002 +
71003 + match = &gr_conn_table[index];
71004 + newent->next = *match;
71005 + *match = newent;
71006 +
71007 + return;
71008 +}
71009 +
71010 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
71011 +{
71012 + struct conn_table_entry *match, *last = NULL;
71013 + unsigned int index;
71014 +
71015 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71016 + sig->gr_sport, sig->gr_dport,
71017 + gr_conn_table_size);
71018 +
71019 + match = gr_conn_table[index];
71020 + while (match && !conn_match(match->sig,
71021 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
71022 + sig->gr_dport)) {
71023 + last = match;
71024 + match = match->next;
71025 + }
71026 +
71027 + if (match) {
71028 + if (last)
71029 + last->next = match->next;
71030 + else
71031 + gr_conn_table[index] = NULL;
71032 + kfree(match);
71033 + }
71034 +
71035 + return;
71036 +}
71037 +
71038 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
71039 + __u16 sport, __u16 dport)
71040 +{
71041 + struct conn_table_entry *match;
71042 + unsigned int index;
71043 +
71044 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
71045 +
71046 + match = gr_conn_table[index];
71047 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
71048 + match = match->next;
71049 +
71050 + if (match)
71051 + return match->sig;
71052 + else
71053 + return NULL;
71054 +}
71055 +
71056 +#endif
71057 +
71058 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
71059 +{
71060 +#ifdef CONFIG_GRKERNSEC
71061 + struct signal_struct *sig = task->signal;
71062 + struct conn_table_entry *newent;
71063 +
71064 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
71065 + if (newent == NULL)
71066 + return;
71067 + /* no bh lock needed since we are called with bh disabled */
71068 + spin_lock(&gr_conn_table_lock);
71069 + gr_del_task_from_ip_table_nolock(sig);
71070 + sig->gr_saddr = inet->inet_rcv_saddr;
71071 + sig->gr_daddr = inet->inet_daddr;
71072 + sig->gr_sport = inet->inet_sport;
71073 + sig->gr_dport = inet->inet_dport;
71074 + gr_add_to_task_ip_table_nolock(sig, newent);
71075 + spin_unlock(&gr_conn_table_lock);
71076 +#endif
71077 + return;
71078 +}
71079 +
71080 +void gr_del_task_from_ip_table(struct task_struct *task)
71081 +{
71082 +#ifdef CONFIG_GRKERNSEC
71083 + spin_lock_bh(&gr_conn_table_lock);
71084 + gr_del_task_from_ip_table_nolock(task->signal);
71085 + spin_unlock_bh(&gr_conn_table_lock);
71086 +#endif
71087 + return;
71088 +}
71089 +
71090 +void
71091 +gr_attach_curr_ip(const struct sock *sk)
71092 +{
71093 +#ifdef CONFIG_GRKERNSEC
71094 + struct signal_struct *p, *set;
71095 + const struct inet_sock *inet = inet_sk(sk);
71096 +
71097 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
71098 + return;
71099 +
71100 + set = current->signal;
71101 +
71102 + spin_lock_bh(&gr_conn_table_lock);
71103 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
71104 + inet->inet_dport, inet->inet_sport);
71105 + if (unlikely(p != NULL)) {
71106 + set->curr_ip = p->curr_ip;
71107 + set->used_accept = 1;
71108 + gr_del_task_from_ip_table_nolock(p);
71109 + spin_unlock_bh(&gr_conn_table_lock);
71110 + return;
71111 + }
71112 + spin_unlock_bh(&gr_conn_table_lock);
71113 +
71114 + set->curr_ip = inet->inet_daddr;
71115 + set->used_accept = 1;
71116 +#endif
71117 + return;
71118 +}
71119 +
71120 +int
71121 +gr_handle_sock_all(const int family, const int type, const int protocol)
71122 +{
71123 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71124 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
71125 + (family != AF_UNIX)) {
71126 + if (family == AF_INET)
71127 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
71128 + else
71129 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
71130 + return -EACCES;
71131 + }
71132 +#endif
71133 + return 0;
71134 +}
71135 +
71136 +int
71137 +gr_handle_sock_server(const struct sockaddr *sck)
71138 +{
71139 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71140 + if (grsec_enable_socket_server &&
71141 + in_group_p(grsec_socket_server_gid) &&
71142 + sck && (sck->sa_family != AF_UNIX) &&
71143 + (sck->sa_family != AF_LOCAL)) {
71144 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71145 + return -EACCES;
71146 + }
71147 +#endif
71148 + return 0;
71149 +}
71150 +
71151 +int
71152 +gr_handle_sock_server_other(const struct sock *sck)
71153 +{
71154 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71155 + if (grsec_enable_socket_server &&
71156 + in_group_p(grsec_socket_server_gid) &&
71157 + sck && (sck->sk_family != AF_UNIX) &&
71158 + (sck->sk_family != AF_LOCAL)) {
71159 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71160 + return -EACCES;
71161 + }
71162 +#endif
71163 + return 0;
71164 +}
71165 +
71166 +int
71167 +gr_handle_sock_client(const struct sockaddr *sck)
71168 +{
71169 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71170 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
71171 + sck && (sck->sa_family != AF_UNIX) &&
71172 + (sck->sa_family != AF_LOCAL)) {
71173 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
71174 + return -EACCES;
71175 + }
71176 +#endif
71177 + return 0;
71178 +}
71179 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
71180 new file mode 100644
71181 index 0000000..8159888
71182 --- /dev/null
71183 +++ b/grsecurity/grsec_sysctl.c
71184 @@ -0,0 +1,479 @@
71185 +#include <linux/kernel.h>
71186 +#include <linux/sched.h>
71187 +#include <linux/sysctl.h>
71188 +#include <linux/grsecurity.h>
71189 +#include <linux/grinternal.h>
71190 +
71191 +int
71192 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
71193 +{
71194 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71195 + if (dirname == NULL || name == NULL)
71196 + return 0;
71197 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
71198 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
71199 + return -EACCES;
71200 + }
71201 +#endif
71202 + return 0;
71203 +}
71204 +
71205 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
71206 +static int __maybe_unused __read_only one = 1;
71207 +#endif
71208 +
71209 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
71210 + defined(CONFIG_GRKERNSEC_DENYUSB)
71211 +struct ctl_table grsecurity_table[] = {
71212 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71213 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
71214 +#ifdef CONFIG_GRKERNSEC_IO
71215 + {
71216 + .procname = "disable_priv_io",
71217 + .data = &grsec_disable_privio,
71218 + .maxlen = sizeof(int),
71219 + .mode = 0600,
71220 + .proc_handler = &proc_dointvec,
71221 + },
71222 +#endif
71223 +#endif
71224 +#ifdef CONFIG_GRKERNSEC_LINK
71225 + {
71226 + .procname = "linking_restrictions",
71227 + .data = &grsec_enable_link,
71228 + .maxlen = sizeof(int),
71229 + .mode = 0600,
71230 + .proc_handler = &proc_dointvec,
71231 + },
71232 +#endif
71233 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71234 + {
71235 + .procname = "enforce_symlinksifowner",
71236 + .data = &grsec_enable_symlinkown,
71237 + .maxlen = sizeof(int),
71238 + .mode = 0600,
71239 + .proc_handler = &proc_dointvec,
71240 + },
71241 + {
71242 + .procname = "symlinkown_gid",
71243 + .data = &grsec_symlinkown_gid,
71244 + .maxlen = sizeof(int),
71245 + .mode = 0600,
71246 + .proc_handler = &proc_dointvec,
71247 + },
71248 +#endif
71249 +#ifdef CONFIG_GRKERNSEC_BRUTE
71250 + {
71251 + .procname = "deter_bruteforce",
71252 + .data = &grsec_enable_brute,
71253 + .maxlen = sizeof(int),
71254 + .mode = 0600,
71255 + .proc_handler = &proc_dointvec,
71256 + },
71257 +#endif
71258 +#ifdef CONFIG_GRKERNSEC_FIFO
71259 + {
71260 + .procname = "fifo_restrictions",
71261 + .data = &grsec_enable_fifo,
71262 + .maxlen = sizeof(int),
71263 + .mode = 0600,
71264 + .proc_handler = &proc_dointvec,
71265 + },
71266 +#endif
71267 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71268 + {
71269 + .procname = "ptrace_readexec",
71270 + .data = &grsec_enable_ptrace_readexec,
71271 + .maxlen = sizeof(int),
71272 + .mode = 0600,
71273 + .proc_handler = &proc_dointvec,
71274 + },
71275 +#endif
71276 +#ifdef CONFIG_GRKERNSEC_SETXID
71277 + {
71278 + .procname = "consistent_setxid",
71279 + .data = &grsec_enable_setxid,
71280 + .maxlen = sizeof(int),
71281 + .mode = 0600,
71282 + .proc_handler = &proc_dointvec,
71283 + },
71284 +#endif
71285 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71286 + {
71287 + .procname = "ip_blackhole",
71288 + .data = &grsec_enable_blackhole,
71289 + .maxlen = sizeof(int),
71290 + .mode = 0600,
71291 + .proc_handler = &proc_dointvec,
71292 + },
71293 + {
71294 + .procname = "lastack_retries",
71295 + .data = &grsec_lastack_retries,
71296 + .maxlen = sizeof(int),
71297 + .mode = 0600,
71298 + .proc_handler = &proc_dointvec,
71299 + },
71300 +#endif
71301 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71302 + {
71303 + .procname = "exec_logging",
71304 + .data = &grsec_enable_execlog,
71305 + .maxlen = sizeof(int),
71306 + .mode = 0600,
71307 + .proc_handler = &proc_dointvec,
71308 + },
71309 +#endif
71310 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71311 + {
71312 + .procname = "rwxmap_logging",
71313 + .data = &grsec_enable_log_rwxmaps,
71314 + .maxlen = sizeof(int),
71315 + .mode = 0600,
71316 + .proc_handler = &proc_dointvec,
71317 + },
71318 +#endif
71319 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71320 + {
71321 + .procname = "signal_logging",
71322 + .data = &grsec_enable_signal,
71323 + .maxlen = sizeof(int),
71324 + .mode = 0600,
71325 + .proc_handler = &proc_dointvec,
71326 + },
71327 +#endif
71328 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71329 + {
71330 + .procname = "forkfail_logging",
71331 + .data = &grsec_enable_forkfail,
71332 + .maxlen = sizeof(int),
71333 + .mode = 0600,
71334 + .proc_handler = &proc_dointvec,
71335 + },
71336 +#endif
71337 +#ifdef CONFIG_GRKERNSEC_TIME
71338 + {
71339 + .procname = "timechange_logging",
71340 + .data = &grsec_enable_time,
71341 + .maxlen = sizeof(int),
71342 + .mode = 0600,
71343 + .proc_handler = &proc_dointvec,
71344 + },
71345 +#endif
71346 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71347 + {
71348 + .procname = "chroot_deny_shmat",
71349 + .data = &grsec_enable_chroot_shmat,
71350 + .maxlen = sizeof(int),
71351 + .mode = 0600,
71352 + .proc_handler = &proc_dointvec,
71353 + },
71354 +#endif
71355 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71356 + {
71357 + .procname = "chroot_deny_unix",
71358 + .data = &grsec_enable_chroot_unix,
71359 + .maxlen = sizeof(int),
71360 + .mode = 0600,
71361 + .proc_handler = &proc_dointvec,
71362 + },
71363 +#endif
71364 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71365 + {
71366 + .procname = "chroot_deny_mount",
71367 + .data = &grsec_enable_chroot_mount,
71368 + .maxlen = sizeof(int),
71369 + .mode = 0600,
71370 + .proc_handler = &proc_dointvec,
71371 + },
71372 +#endif
71373 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71374 + {
71375 + .procname = "chroot_deny_fchdir",
71376 + .data = &grsec_enable_chroot_fchdir,
71377 + .maxlen = sizeof(int),
71378 + .mode = 0600,
71379 + .proc_handler = &proc_dointvec,
71380 + },
71381 +#endif
71382 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71383 + {
71384 + .procname = "chroot_deny_chroot",
71385 + .data = &grsec_enable_chroot_double,
71386 + .maxlen = sizeof(int),
71387 + .mode = 0600,
71388 + .proc_handler = &proc_dointvec,
71389 + },
71390 +#endif
71391 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71392 + {
71393 + .procname = "chroot_deny_pivot",
71394 + .data = &grsec_enable_chroot_pivot,
71395 + .maxlen = sizeof(int),
71396 + .mode = 0600,
71397 + .proc_handler = &proc_dointvec,
71398 + },
71399 +#endif
71400 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71401 + {
71402 + .procname = "chroot_enforce_chdir",
71403 + .data = &grsec_enable_chroot_chdir,
71404 + .maxlen = sizeof(int),
71405 + .mode = 0600,
71406 + .proc_handler = &proc_dointvec,
71407 + },
71408 +#endif
71409 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71410 + {
71411 + .procname = "chroot_deny_chmod",
71412 + .data = &grsec_enable_chroot_chmod,
71413 + .maxlen = sizeof(int),
71414 + .mode = 0600,
71415 + .proc_handler = &proc_dointvec,
71416 + },
71417 +#endif
71418 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71419 + {
71420 + .procname = "chroot_deny_mknod",
71421 + .data = &grsec_enable_chroot_mknod,
71422 + .maxlen = sizeof(int),
71423 + .mode = 0600,
71424 + .proc_handler = &proc_dointvec,
71425 + },
71426 +#endif
71427 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71428 + {
71429 + .procname = "chroot_restrict_nice",
71430 + .data = &grsec_enable_chroot_nice,
71431 + .maxlen = sizeof(int),
71432 + .mode = 0600,
71433 + .proc_handler = &proc_dointvec,
71434 + },
71435 +#endif
71436 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71437 + {
71438 + .procname = "chroot_execlog",
71439 + .data = &grsec_enable_chroot_execlog,
71440 + .maxlen = sizeof(int),
71441 + .mode = 0600,
71442 + .proc_handler = &proc_dointvec,
71443 + },
71444 +#endif
71445 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71446 + {
71447 + .procname = "chroot_caps",
71448 + .data = &grsec_enable_chroot_caps,
71449 + .maxlen = sizeof(int),
71450 + .mode = 0600,
71451 + .proc_handler = &proc_dointvec,
71452 + },
71453 +#endif
71454 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71455 + {
71456 + .procname = "chroot_deny_sysctl",
71457 + .data = &grsec_enable_chroot_sysctl,
71458 + .maxlen = sizeof(int),
71459 + .mode = 0600,
71460 + .proc_handler = &proc_dointvec,
71461 + },
71462 +#endif
71463 +#ifdef CONFIG_GRKERNSEC_TPE
71464 + {
71465 + .procname = "tpe",
71466 + .data = &grsec_enable_tpe,
71467 + .maxlen = sizeof(int),
71468 + .mode = 0600,
71469 + .proc_handler = &proc_dointvec,
71470 + },
71471 + {
71472 + .procname = "tpe_gid",
71473 + .data = &grsec_tpe_gid,
71474 + .maxlen = sizeof(int),
71475 + .mode = 0600,
71476 + .proc_handler = &proc_dointvec,
71477 + },
71478 +#endif
71479 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71480 + {
71481 + .procname = "tpe_invert",
71482 + .data = &grsec_enable_tpe_invert,
71483 + .maxlen = sizeof(int),
71484 + .mode = 0600,
71485 + .proc_handler = &proc_dointvec,
71486 + },
71487 +#endif
71488 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71489 + {
71490 + .procname = "tpe_restrict_all",
71491 + .data = &grsec_enable_tpe_all,
71492 + .maxlen = sizeof(int),
71493 + .mode = 0600,
71494 + .proc_handler = &proc_dointvec,
71495 + },
71496 +#endif
71497 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71498 + {
71499 + .procname = "socket_all",
71500 + .data = &grsec_enable_socket_all,
71501 + .maxlen = sizeof(int),
71502 + .mode = 0600,
71503 + .proc_handler = &proc_dointvec,
71504 + },
71505 + {
71506 + .procname = "socket_all_gid",
71507 + .data = &grsec_socket_all_gid,
71508 + .maxlen = sizeof(int),
71509 + .mode = 0600,
71510 + .proc_handler = &proc_dointvec,
71511 + },
71512 +#endif
71513 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71514 + {
71515 + .procname = "socket_client",
71516 + .data = &grsec_enable_socket_client,
71517 + .maxlen = sizeof(int),
71518 + .mode = 0600,
71519 + .proc_handler = &proc_dointvec,
71520 + },
71521 + {
71522 + .procname = "socket_client_gid",
71523 + .data = &grsec_socket_client_gid,
71524 + .maxlen = sizeof(int),
71525 + .mode = 0600,
71526 + .proc_handler = &proc_dointvec,
71527 + },
71528 +#endif
71529 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71530 + {
71531 + .procname = "socket_server",
71532 + .data = &grsec_enable_socket_server,
71533 + .maxlen = sizeof(int),
71534 + .mode = 0600,
71535 + .proc_handler = &proc_dointvec,
71536 + },
71537 + {
71538 + .procname = "socket_server_gid",
71539 + .data = &grsec_socket_server_gid,
71540 + .maxlen = sizeof(int),
71541 + .mode = 0600,
71542 + .proc_handler = &proc_dointvec,
71543 + },
71544 +#endif
71545 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71546 + {
71547 + .procname = "audit_group",
71548 + .data = &grsec_enable_group,
71549 + .maxlen = sizeof(int),
71550 + .mode = 0600,
71551 + .proc_handler = &proc_dointvec,
71552 + },
71553 + {
71554 + .procname = "audit_gid",
71555 + .data = &grsec_audit_gid,
71556 + .maxlen = sizeof(int),
71557 + .mode = 0600,
71558 + .proc_handler = &proc_dointvec,
71559 + },
71560 +#endif
71561 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71562 + {
71563 + .procname = "audit_chdir",
71564 + .data = &grsec_enable_chdir,
71565 + .maxlen = sizeof(int),
71566 + .mode = 0600,
71567 + .proc_handler = &proc_dointvec,
71568 + },
71569 +#endif
71570 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71571 + {
71572 + .procname = "audit_mount",
71573 + .data = &grsec_enable_mount,
71574 + .maxlen = sizeof(int),
71575 + .mode = 0600,
71576 + .proc_handler = &proc_dointvec,
71577 + },
71578 +#endif
71579 +#ifdef CONFIG_GRKERNSEC_DMESG
71580 + {
71581 + .procname = "dmesg",
71582 + .data = &grsec_enable_dmesg,
71583 + .maxlen = sizeof(int),
71584 + .mode = 0600,
71585 + .proc_handler = &proc_dointvec,
71586 + },
71587 +#endif
71588 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71589 + {
71590 + .procname = "chroot_findtask",
71591 + .data = &grsec_enable_chroot_findtask,
71592 + .maxlen = sizeof(int),
71593 + .mode = 0600,
71594 + .proc_handler = &proc_dointvec,
71595 + },
71596 +#endif
71597 +#ifdef CONFIG_GRKERNSEC_RESLOG
71598 + {
71599 + .procname = "resource_logging",
71600 + .data = &grsec_resource_logging,
71601 + .maxlen = sizeof(int),
71602 + .mode = 0600,
71603 + .proc_handler = &proc_dointvec,
71604 + },
71605 +#endif
71606 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71607 + {
71608 + .procname = "audit_ptrace",
71609 + .data = &grsec_enable_audit_ptrace,
71610 + .maxlen = sizeof(int),
71611 + .mode = 0600,
71612 + .proc_handler = &proc_dointvec,
71613 + },
71614 +#endif
71615 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71616 + {
71617 + .procname = "harden_ptrace",
71618 + .data = &grsec_enable_harden_ptrace,
71619 + .maxlen = sizeof(int),
71620 + .mode = 0600,
71621 + .proc_handler = &proc_dointvec,
71622 + },
71623 +#endif
71624 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71625 + {
71626 + .procname = "harden_ipc",
71627 + .data = &grsec_enable_harden_ipc,
71628 + .maxlen = sizeof(int),
71629 + .mode = 0600,
71630 + .proc_handler = &proc_dointvec,
71631 + },
71632 +#endif
71633 + {
71634 + .procname = "grsec_lock",
71635 + .data = &grsec_lock,
71636 + .maxlen = sizeof(int),
71637 + .mode = 0600,
71638 + .proc_handler = &proc_dointvec,
71639 + },
71640 +#endif
71641 +#ifdef CONFIG_GRKERNSEC_ROFS
71642 + {
71643 + .procname = "romount_protect",
71644 + .data = &grsec_enable_rofs,
71645 + .maxlen = sizeof(int),
71646 + .mode = 0600,
71647 + .proc_handler = &proc_dointvec_minmax,
71648 + .extra1 = &one,
71649 + .extra2 = &one,
71650 + },
71651 +#endif
71652 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71653 + {
71654 + .procname = "deny_new_usb",
71655 + .data = &grsec_deny_new_usb,
71656 + .maxlen = sizeof(int),
71657 + .mode = 0600,
71658 + .proc_handler = &proc_dointvec,
71659 + },
71660 +#endif
71661 + { }
71662 +};
71663 +#endif
71664 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71665 new file mode 100644
71666 index 0000000..0dc13c3
71667 --- /dev/null
71668 +++ b/grsecurity/grsec_time.c
71669 @@ -0,0 +1,16 @@
71670 +#include <linux/kernel.h>
71671 +#include <linux/sched.h>
71672 +#include <linux/grinternal.h>
71673 +#include <linux/module.h>
71674 +
71675 +void
71676 +gr_log_timechange(void)
71677 +{
71678 +#ifdef CONFIG_GRKERNSEC_TIME
71679 + if (grsec_enable_time)
71680 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71681 +#endif
71682 + return;
71683 +}
71684 +
71685 +EXPORT_SYMBOL(gr_log_timechange);
71686 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71687 new file mode 100644
71688 index 0000000..ee57dcf
71689 --- /dev/null
71690 +++ b/grsecurity/grsec_tpe.c
71691 @@ -0,0 +1,73 @@
71692 +#include <linux/kernel.h>
71693 +#include <linux/sched.h>
71694 +#include <linux/file.h>
71695 +#include <linux/fs.h>
71696 +#include <linux/grinternal.h>
71697 +
71698 +extern int gr_acl_tpe_check(void);
71699 +
71700 +int
71701 +gr_tpe_allow(const struct file *file)
71702 +{
71703 +#ifdef CONFIG_GRKERNSEC
71704 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71705 + const struct cred *cred = current_cred();
71706 + char *msg = NULL;
71707 + char *msg2 = NULL;
71708 +
71709 + // never restrict root
71710 + if (gr_is_global_root(cred->uid))
71711 + return 1;
71712 +
71713 + if (grsec_enable_tpe) {
71714 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71715 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71716 + msg = "not being in trusted group";
71717 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71718 + msg = "being in untrusted group";
71719 +#else
71720 + if (in_group_p(grsec_tpe_gid))
71721 + msg = "being in untrusted group";
71722 +#endif
71723 + }
71724 + if (!msg && gr_acl_tpe_check())
71725 + msg = "being in untrusted role";
71726 +
71727 + // not in any affected group/role
71728 + if (!msg)
71729 + goto next_check;
71730 +
71731 + if (gr_is_global_nonroot(inode->i_uid))
71732 + msg2 = "file in non-root-owned directory";
71733 + else if (inode->i_mode & S_IWOTH)
71734 + msg2 = "file in world-writable directory";
71735 + else if (inode->i_mode & S_IWGRP)
71736 + msg2 = "file in group-writable directory";
71737 +
71738 + if (msg && msg2) {
71739 + char fullmsg[70] = {0};
71740 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71741 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71742 + return 0;
71743 + }
71744 + msg = NULL;
71745 +next_check:
71746 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71747 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71748 + return 1;
71749 +
71750 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71751 + msg = "directory not owned by user";
71752 + else if (inode->i_mode & S_IWOTH)
71753 + msg = "file in world-writable directory";
71754 + else if (inode->i_mode & S_IWGRP)
71755 + msg = "file in group-writable directory";
71756 +
71757 + if (msg) {
71758 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71759 + return 0;
71760 + }
71761 +#endif
71762 +#endif
71763 + return 1;
71764 +}
71765 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71766 new file mode 100644
71767 index 0000000..ae02d8e
71768 --- /dev/null
71769 +++ b/grsecurity/grsec_usb.c
71770 @@ -0,0 +1,15 @@
71771 +#include <linux/kernel.h>
71772 +#include <linux/grinternal.h>
71773 +#include <linux/module.h>
71774 +
71775 +int gr_handle_new_usb(void)
71776 +{
71777 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71778 + if (grsec_deny_new_usb) {
71779 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71780 + return 1;
71781 + }
71782 +#endif
71783 + return 0;
71784 +}
71785 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71786 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71787 new file mode 100644
71788 index 0000000..9f7b1ac
71789 --- /dev/null
71790 +++ b/grsecurity/grsum.c
71791 @@ -0,0 +1,61 @@
71792 +#include <linux/err.h>
71793 +#include <linux/kernel.h>
71794 +#include <linux/sched.h>
71795 +#include <linux/mm.h>
71796 +#include <linux/scatterlist.h>
71797 +#include <linux/crypto.h>
71798 +#include <linux/gracl.h>
71799 +
71800 +
71801 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71802 +#error "crypto and sha256 must be built into the kernel"
71803 +#endif
71804 +
71805 +int
71806 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71807 +{
71808 + char *p;
71809 + struct crypto_hash *tfm;
71810 + struct hash_desc desc;
71811 + struct scatterlist sg;
71812 + unsigned char temp_sum[GR_SHA_LEN];
71813 + volatile int retval = 0;
71814 + volatile int dummy = 0;
71815 + unsigned int i;
71816 +
71817 + sg_init_table(&sg, 1);
71818 +
71819 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71820 + if (IS_ERR(tfm)) {
71821 + /* should never happen, since sha256 should be built in */
71822 + return 1;
71823 + }
71824 +
71825 + desc.tfm = tfm;
71826 + desc.flags = 0;
71827 +
71828 + crypto_hash_init(&desc);
71829 +
71830 + p = salt;
71831 + sg_set_buf(&sg, p, GR_SALT_LEN);
71832 + crypto_hash_update(&desc, &sg, sg.length);
71833 +
71834 + p = entry->pw;
71835 + sg_set_buf(&sg, p, strlen(p));
71836 +
71837 + crypto_hash_update(&desc, &sg, sg.length);
71838 +
71839 + crypto_hash_final(&desc, temp_sum);
71840 +
71841 + memset(entry->pw, 0, GR_PW_LEN);
71842 +
71843 + for (i = 0; i < GR_SHA_LEN; i++)
71844 + if (sum[i] != temp_sum[i])
71845 + retval = 1;
71846 + else
71847 + dummy = 1; // waste a cycle
71848 +
71849 + crypto_free_hash(tfm);
71850 +
71851 + return retval;
71852 +}
71853 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71854 index 77ff547..181834f 100644
71855 --- a/include/asm-generic/4level-fixup.h
71856 +++ b/include/asm-generic/4level-fixup.h
71857 @@ -13,8 +13,10 @@
71858 #define pmd_alloc(mm, pud, address) \
71859 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71860 NULL: pmd_offset(pud, address))
71861 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71862
71863 #define pud_alloc(mm, pgd, address) (pgd)
71864 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71865 #define pud_offset(pgd, start) (pgd)
71866 #define pud_none(pud) 0
71867 #define pud_bad(pud) 0
71868 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71869 index b7babf0..04ad282 100644
71870 --- a/include/asm-generic/atomic-long.h
71871 +++ b/include/asm-generic/atomic-long.h
71872 @@ -22,6 +22,12 @@
71873
71874 typedef atomic64_t atomic_long_t;
71875
71876 +#ifdef CONFIG_PAX_REFCOUNT
71877 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71878 +#else
71879 +typedef atomic64_t atomic_long_unchecked_t;
71880 +#endif
71881 +
71882 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71883
71884 static inline long atomic_long_read(atomic_long_t *l)
71885 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71886 return (long)atomic64_read(v);
71887 }
71888
71889 +#ifdef CONFIG_PAX_REFCOUNT
71890 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71891 +{
71892 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71893 +
71894 + return (long)atomic64_read_unchecked(v);
71895 +}
71896 +#endif
71897 +
71898 static inline void atomic_long_set(atomic_long_t *l, long i)
71899 {
71900 atomic64_t *v = (atomic64_t *)l;
71901 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71902 atomic64_set(v, i);
71903 }
71904
71905 +#ifdef CONFIG_PAX_REFCOUNT
71906 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71907 +{
71908 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71909 +
71910 + atomic64_set_unchecked(v, i);
71911 +}
71912 +#endif
71913 +
71914 static inline void atomic_long_inc(atomic_long_t *l)
71915 {
71916 atomic64_t *v = (atomic64_t *)l;
71917 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71918 atomic64_inc(v);
71919 }
71920
71921 +#ifdef CONFIG_PAX_REFCOUNT
71922 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71923 +{
71924 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71925 +
71926 + atomic64_inc_unchecked(v);
71927 +}
71928 +#endif
71929 +
71930 static inline void atomic_long_dec(atomic_long_t *l)
71931 {
71932 atomic64_t *v = (atomic64_t *)l;
71933 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71934 atomic64_dec(v);
71935 }
71936
71937 +#ifdef CONFIG_PAX_REFCOUNT
71938 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71939 +{
71940 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71941 +
71942 + atomic64_dec_unchecked(v);
71943 +}
71944 +#endif
71945 +
71946 static inline void atomic_long_add(long i, atomic_long_t *l)
71947 {
71948 atomic64_t *v = (atomic64_t *)l;
71949 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71950 atomic64_add(i, v);
71951 }
71952
71953 +#ifdef CONFIG_PAX_REFCOUNT
71954 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71955 +{
71956 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71957 +
71958 + atomic64_add_unchecked(i, v);
71959 +}
71960 +#endif
71961 +
71962 static inline void atomic_long_sub(long i, atomic_long_t *l)
71963 {
71964 atomic64_t *v = (atomic64_t *)l;
71965 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71966 atomic64_sub(i, v);
71967 }
71968
71969 +#ifdef CONFIG_PAX_REFCOUNT
71970 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71971 +{
71972 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71973 +
71974 + atomic64_sub_unchecked(i, v);
71975 +}
71976 +#endif
71977 +
71978 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71979 {
71980 atomic64_t *v = (atomic64_t *)l;
71981 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71982 return (long)atomic64_add_return(i, v);
71983 }
71984
71985 +#ifdef CONFIG_PAX_REFCOUNT
71986 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71987 +{
71988 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71989 +
71990 + return (long)atomic64_add_return_unchecked(i, v);
71991 +}
71992 +#endif
71993 +
71994 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71995 {
71996 atomic64_t *v = (atomic64_t *)l;
71997 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71998 return (long)atomic64_inc_return(v);
71999 }
72000
72001 +#ifdef CONFIG_PAX_REFCOUNT
72002 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72003 +{
72004 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72005 +
72006 + return (long)atomic64_inc_return_unchecked(v);
72007 +}
72008 +#endif
72009 +
72010 static inline long atomic_long_dec_return(atomic_long_t *l)
72011 {
72012 atomic64_t *v = (atomic64_t *)l;
72013 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72014
72015 typedef atomic_t atomic_long_t;
72016
72017 +#ifdef CONFIG_PAX_REFCOUNT
72018 +typedef atomic_unchecked_t atomic_long_unchecked_t;
72019 +#else
72020 +typedef atomic_t atomic_long_unchecked_t;
72021 +#endif
72022 +
72023 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
72024 static inline long atomic_long_read(atomic_long_t *l)
72025 {
72026 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72027 return (long)atomic_read(v);
72028 }
72029
72030 +#ifdef CONFIG_PAX_REFCOUNT
72031 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72032 +{
72033 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72034 +
72035 + return (long)atomic_read_unchecked(v);
72036 +}
72037 +#endif
72038 +
72039 static inline void atomic_long_set(atomic_long_t *l, long i)
72040 {
72041 atomic_t *v = (atomic_t *)l;
72042 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72043 atomic_set(v, i);
72044 }
72045
72046 +#ifdef CONFIG_PAX_REFCOUNT
72047 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72048 +{
72049 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72050 +
72051 + atomic_set_unchecked(v, i);
72052 +}
72053 +#endif
72054 +
72055 static inline void atomic_long_inc(atomic_long_t *l)
72056 {
72057 atomic_t *v = (atomic_t *)l;
72058 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72059 atomic_inc(v);
72060 }
72061
72062 +#ifdef CONFIG_PAX_REFCOUNT
72063 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72064 +{
72065 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72066 +
72067 + atomic_inc_unchecked(v);
72068 +}
72069 +#endif
72070 +
72071 static inline void atomic_long_dec(atomic_long_t *l)
72072 {
72073 atomic_t *v = (atomic_t *)l;
72074 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72075 atomic_dec(v);
72076 }
72077
72078 +#ifdef CONFIG_PAX_REFCOUNT
72079 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72080 +{
72081 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72082 +
72083 + atomic_dec_unchecked(v);
72084 +}
72085 +#endif
72086 +
72087 static inline void atomic_long_add(long i, atomic_long_t *l)
72088 {
72089 atomic_t *v = (atomic_t *)l;
72090 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72091 atomic_add(i, v);
72092 }
72093
72094 +#ifdef CONFIG_PAX_REFCOUNT
72095 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72096 +{
72097 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72098 +
72099 + atomic_add_unchecked(i, v);
72100 +}
72101 +#endif
72102 +
72103 static inline void atomic_long_sub(long i, atomic_long_t *l)
72104 {
72105 atomic_t *v = (atomic_t *)l;
72106 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72107 atomic_sub(i, v);
72108 }
72109
72110 +#ifdef CONFIG_PAX_REFCOUNT
72111 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72112 +{
72113 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72114 +
72115 + atomic_sub_unchecked(i, v);
72116 +}
72117 +#endif
72118 +
72119 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72120 {
72121 atomic_t *v = (atomic_t *)l;
72122 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72123 return (long)atomic_add_return(i, v);
72124 }
72125
72126 +#ifdef CONFIG_PAX_REFCOUNT
72127 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72128 +{
72129 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72130 +
72131 + return (long)atomic_add_return_unchecked(i, v);
72132 +}
72133 +
72134 +#endif
72135 +
72136 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72137 {
72138 atomic_t *v = (atomic_t *)l;
72139 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72140 return (long)atomic_inc_return(v);
72141 }
72142
72143 +#ifdef CONFIG_PAX_REFCOUNT
72144 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72145 +{
72146 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72147 +
72148 + return (long)atomic_inc_return_unchecked(v);
72149 +}
72150 +#endif
72151 +
72152 static inline long atomic_long_dec_return(atomic_long_t *l)
72153 {
72154 atomic_t *v = (atomic_t *)l;
72155 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72156
72157 #endif /* BITS_PER_LONG == 64 */
72158
72159 +#ifdef CONFIG_PAX_REFCOUNT
72160 +static inline void pax_refcount_needs_these_functions(void)
72161 +{
72162 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
72163 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
72164 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
72165 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
72166 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
72167 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
72168 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
72169 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
72170 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
72171 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
72172 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
72173 +#ifdef CONFIG_X86
72174 + atomic_clear_mask_unchecked(0, NULL);
72175 + atomic_set_mask_unchecked(0, NULL);
72176 +#endif
72177 +
72178 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
72179 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
72180 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
72181 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
72182 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
72183 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
72184 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
72185 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
72186 +}
72187 +#else
72188 +#define atomic_read_unchecked(v) atomic_read(v)
72189 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
72190 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
72191 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
72192 +#define atomic_inc_unchecked(v) atomic_inc(v)
72193 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
72194 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
72195 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
72196 +#define atomic_dec_unchecked(v) atomic_dec(v)
72197 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
72198 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
72199 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
72200 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
72201 +
72202 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
72203 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
72204 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
72205 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
72206 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
72207 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
72208 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
72209 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
72210 +#endif
72211 +
72212 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
72213 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
72214 index 33bd2de..f31bff97 100644
72215 --- a/include/asm-generic/atomic.h
72216 +++ b/include/asm-generic/atomic.h
72217 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
72218 * Atomically clears the bits set in @mask from @v
72219 */
72220 #ifndef atomic_clear_mask
72221 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
72222 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
72223 {
72224 unsigned long flags;
72225
72226 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
72227 index b18ce4f..2ee2843 100644
72228 --- a/include/asm-generic/atomic64.h
72229 +++ b/include/asm-generic/atomic64.h
72230 @@ -16,6 +16,8 @@ typedef struct {
72231 long long counter;
72232 } atomic64_t;
72233
72234 +typedef atomic64_t atomic64_unchecked_t;
72235 +
72236 #define ATOMIC64_INIT(i) { (i) }
72237
72238 extern long long atomic64_read(const atomic64_t *v);
72239 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
72240 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
72241 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
72242
72243 +#define atomic64_read_unchecked(v) atomic64_read(v)
72244 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
72245 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
72246 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
72247 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
72248 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
72249 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
72250 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
72251 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
72252 +
72253 #endif /* _ASM_GENERIC_ATOMIC64_H */
72254 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
72255 index 1bfcfe5..e04c5c9 100644
72256 --- a/include/asm-generic/cache.h
72257 +++ b/include/asm-generic/cache.h
72258 @@ -6,7 +6,7 @@
72259 * cache lines need to provide their own cache.h.
72260 */
72261
72262 -#define L1_CACHE_SHIFT 5
72263 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
72264 +#define L1_CACHE_SHIFT 5UL
72265 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
72266
72267 #endif /* __ASM_GENERIC_CACHE_H */
72268 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72269 index 0d68a1e..b74a761 100644
72270 --- a/include/asm-generic/emergency-restart.h
72271 +++ b/include/asm-generic/emergency-restart.h
72272 @@ -1,7 +1,7 @@
72273 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72274 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72275
72276 -static inline void machine_emergency_restart(void)
72277 +static inline __noreturn void machine_emergency_restart(void)
72278 {
72279 machine_restart(NULL);
72280 }
72281 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72282 index 90f99c7..00ce236 100644
72283 --- a/include/asm-generic/kmap_types.h
72284 +++ b/include/asm-generic/kmap_types.h
72285 @@ -2,9 +2,9 @@
72286 #define _ASM_GENERIC_KMAP_TYPES_H
72287
72288 #ifdef __WITH_KM_FENCE
72289 -# define KM_TYPE_NR 41
72290 +# define KM_TYPE_NR 42
72291 #else
72292 -# define KM_TYPE_NR 20
72293 +# define KM_TYPE_NR 21
72294 #endif
72295
72296 #endif
72297 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72298 index 9ceb03b..62b0b8f 100644
72299 --- a/include/asm-generic/local.h
72300 +++ b/include/asm-generic/local.h
72301 @@ -23,24 +23,37 @@ typedef struct
72302 atomic_long_t a;
72303 } local_t;
72304
72305 +typedef struct {
72306 + atomic_long_unchecked_t a;
72307 +} local_unchecked_t;
72308 +
72309 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72310
72311 #define local_read(l) atomic_long_read(&(l)->a)
72312 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72313 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72314 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72315 #define local_inc(l) atomic_long_inc(&(l)->a)
72316 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72317 #define local_dec(l) atomic_long_dec(&(l)->a)
72318 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72319 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72320 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72321 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72322 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72323
72324 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72325 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72326 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72327 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72328 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72329 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72330 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72331 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72332 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72333
72334 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72335 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72336 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72337 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72338 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72339 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72340 index 725612b..9cc513a 100644
72341 --- a/include/asm-generic/pgtable-nopmd.h
72342 +++ b/include/asm-generic/pgtable-nopmd.h
72343 @@ -1,14 +1,19 @@
72344 #ifndef _PGTABLE_NOPMD_H
72345 #define _PGTABLE_NOPMD_H
72346
72347 -#ifndef __ASSEMBLY__
72348 -
72349 #include <asm-generic/pgtable-nopud.h>
72350
72351 -struct mm_struct;
72352 -
72353 #define __PAGETABLE_PMD_FOLDED
72354
72355 +#define PMD_SHIFT PUD_SHIFT
72356 +#define PTRS_PER_PMD 1
72357 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72358 +#define PMD_MASK (~(PMD_SIZE-1))
72359 +
72360 +#ifndef __ASSEMBLY__
72361 +
72362 +struct mm_struct;
72363 +
72364 /*
72365 * Having the pmd type consist of a pud gets the size right, and allows
72366 * us to conceptually access the pud entry that this pmd is folded into
72367 @@ -16,11 +21,6 @@ struct mm_struct;
72368 */
72369 typedef struct { pud_t pud; } pmd_t;
72370
72371 -#define PMD_SHIFT PUD_SHIFT
72372 -#define PTRS_PER_PMD 1
72373 -#define PMD_SIZE (1UL << PMD_SHIFT)
72374 -#define PMD_MASK (~(PMD_SIZE-1))
72375 -
72376 /*
72377 * The "pud_xxx()" functions here are trivial for a folded two-level
72378 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72379 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72380 index 810431d..0ec4804f 100644
72381 --- a/include/asm-generic/pgtable-nopud.h
72382 +++ b/include/asm-generic/pgtable-nopud.h
72383 @@ -1,10 +1,15 @@
72384 #ifndef _PGTABLE_NOPUD_H
72385 #define _PGTABLE_NOPUD_H
72386
72387 -#ifndef __ASSEMBLY__
72388 -
72389 #define __PAGETABLE_PUD_FOLDED
72390
72391 +#define PUD_SHIFT PGDIR_SHIFT
72392 +#define PTRS_PER_PUD 1
72393 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72394 +#define PUD_MASK (~(PUD_SIZE-1))
72395 +
72396 +#ifndef __ASSEMBLY__
72397 +
72398 /*
72399 * Having the pud type consist of a pgd gets the size right, and allows
72400 * us to conceptually access the pgd entry that this pud is folded into
72401 @@ -12,11 +17,6 @@
72402 */
72403 typedef struct { pgd_t pgd; } pud_t;
72404
72405 -#define PUD_SHIFT PGDIR_SHIFT
72406 -#define PTRS_PER_PUD 1
72407 -#define PUD_SIZE (1UL << PUD_SHIFT)
72408 -#define PUD_MASK (~(PUD_SIZE-1))
72409 -
72410 /*
72411 * The "pgd_xxx()" functions here are trivial for a folded two-level
72412 * setup: the pud is never bad, and a pud always exists (as it's folded
72413 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72414 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72415
72416 #define pgd_populate(mm, pgd, pud) do { } while (0)
72417 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72418 /*
72419 * (puds are folded into pgds so this doesn't get actually called,
72420 * but the define is needed for a generic inline function.)
72421 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72422 index 0807ddf..cd67747 100644
72423 --- a/include/asm-generic/pgtable.h
72424 +++ b/include/asm-generic/pgtable.h
72425 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72426 }
72427 #endif /* CONFIG_NUMA_BALANCING */
72428
72429 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72430 +#ifdef CONFIG_PAX_KERNEXEC
72431 +#error KERNEXEC requires pax_open_kernel
72432 +#else
72433 +static inline unsigned long pax_open_kernel(void) { return 0; }
72434 +#endif
72435 +#endif
72436 +
72437 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72438 +#ifdef CONFIG_PAX_KERNEXEC
72439 +#error KERNEXEC requires pax_close_kernel
72440 +#else
72441 +static inline unsigned long pax_close_kernel(void) { return 0; }
72442 +#endif
72443 +#endif
72444 +
72445 #endif /* CONFIG_MMU */
72446
72447 #endif /* !__ASSEMBLY__ */
72448 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72449 index dc1269c..48a4f51 100644
72450 --- a/include/asm-generic/uaccess.h
72451 +++ b/include/asm-generic/uaccess.h
72452 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72453 return __clear_user(to, n);
72454 }
72455
72456 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72457 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72458 +#error UDEREF requires pax_open_userland
72459 +#else
72460 +static inline unsigned long pax_open_userland(void) { return 0; }
72461 +#endif
72462 +#endif
72463 +
72464 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72465 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72466 +#error UDEREF requires pax_close_userland
72467 +#else
72468 +static inline unsigned long pax_close_userland(void) { return 0; }
72469 +#endif
72470 +#endif
72471 +
72472 #endif /* __ASM_GENERIC_UACCESS_H */
72473 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72474 index 69732d2..cbe16d9 100644
72475 --- a/include/asm-generic/vmlinux.lds.h
72476 +++ b/include/asm-generic/vmlinux.lds.h
72477 @@ -227,6 +227,7 @@
72478 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72479 VMLINUX_SYMBOL(__start_rodata) = .; \
72480 *(.rodata) *(.rodata.*) \
72481 + *(.data..read_only) \
72482 *(__vermagic) /* Kernel version magic */ \
72483 . = ALIGN(8); \
72484 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72485 @@ -710,17 +711,18 @@
72486 * section in the linker script will go there too. @phdr should have
72487 * a leading colon.
72488 *
72489 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72490 + * Note that this macros defines per_cpu_load as an absolute symbol.
72491 * If there is no need to put the percpu section at a predetermined
72492 * address, use PERCPU_SECTION.
72493 */
72494 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72495 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72496 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72497 + per_cpu_load = .; \
72498 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72499 - LOAD_OFFSET) { \
72500 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72501 PERCPU_INPUT(cacheline) \
72502 } phdr \
72503 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72504 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72505
72506 /**
72507 * PERCPU_SECTION - define output section for percpu area, simple version
72508 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72509 index 418d270..bfd2794 100644
72510 --- a/include/crypto/algapi.h
72511 +++ b/include/crypto/algapi.h
72512 @@ -34,7 +34,7 @@ struct crypto_type {
72513 unsigned int maskclear;
72514 unsigned int maskset;
72515 unsigned int tfmsize;
72516 -};
72517 +} __do_const;
72518
72519 struct crypto_instance {
72520 struct crypto_alg alg;
72521 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72522 index 12083dc..39740ec 100644
72523 --- a/include/drm/drmP.h
72524 +++ b/include/drm/drmP.h
72525 @@ -69,6 +69,7 @@
72526 #include <linux/workqueue.h>
72527 #include <linux/poll.h>
72528 #include <asm/pgalloc.h>
72529 +#include <asm/local.h>
72530 #include <drm/drm.h>
72531 #include <drm/drm_sarea.h>
72532
72533 @@ -293,10 +294,12 @@ do { \
72534 * \param cmd command.
72535 * \param arg argument.
72536 */
72537 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72538 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72539 + struct drm_file *file_priv);
72540 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72541 struct drm_file *file_priv);
72542
72543 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72544 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72545 unsigned long arg);
72546
72547 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72548 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72549 struct drm_ioctl_desc {
72550 unsigned int cmd;
72551 int flags;
72552 - drm_ioctl_t *func;
72553 + drm_ioctl_t func;
72554 unsigned int cmd_drv;
72555 const char *name;
72556 -};
72557 +} __do_const;
72558
72559 /**
72560 * Creates a driver or general drm_ioctl_desc array entry for the given
72561 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72562 int (*show)(struct seq_file*, void*); /** show callback */
72563 u32 driver_features; /**< Required driver features for this entry */
72564 void *data;
72565 -};
72566 +} __do_const;
72567
72568 /**
72569 * debugfs node structure. This structure represents a debugfs file.
72570 @@ -1088,7 +1091,7 @@ struct drm_device {
72571
72572 /** \name Usage Counters */
72573 /*@{ */
72574 - int open_count; /**< Outstanding files open */
72575 + local_t open_count; /**< Outstanding files open */
72576 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72577 atomic_t vma_count; /**< Outstanding vma areas open */
72578 int buf_use; /**< Buffers in use -- cannot alloc */
72579 @@ -1099,7 +1102,7 @@ struct drm_device {
72580 /*@{ */
72581 unsigned long counters;
72582 enum drm_stat_type types[15];
72583 - atomic_t counts[15];
72584 + atomic_unchecked_t counts[15];
72585 /*@} */
72586
72587 struct list_head filelist;
72588 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72589 index f43d556..94d9343 100644
72590 --- a/include/drm/drm_crtc_helper.h
72591 +++ b/include/drm/drm_crtc_helper.h
72592 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72593 struct drm_connector *connector);
72594 /* disable encoder when not in use - more explicit than dpms off */
72595 void (*disable)(struct drm_encoder *encoder);
72596 -};
72597 +} __no_const;
72598
72599 /**
72600 * drm_connector_helper_funcs - helper operations for connectors
72601 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72602 index 72dcbe8..8db58d7 100644
72603 --- a/include/drm/ttm/ttm_memory.h
72604 +++ b/include/drm/ttm/ttm_memory.h
72605 @@ -48,7 +48,7 @@
72606
72607 struct ttm_mem_shrink {
72608 int (*do_shrink) (struct ttm_mem_shrink *);
72609 -};
72610 +} __no_const;
72611
72612 /**
72613 * struct ttm_mem_global - Global memory accounting structure.
72614 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72615 index 4b840e8..155d235 100644
72616 --- a/include/keys/asymmetric-subtype.h
72617 +++ b/include/keys/asymmetric-subtype.h
72618 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72619 /* Verify the signature on a key of this subtype (optional) */
72620 int (*verify_signature)(const struct key *key,
72621 const struct public_key_signature *sig);
72622 -};
72623 +} __do_const;
72624
72625 /**
72626 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72627 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72628 index c1da539..1dcec55 100644
72629 --- a/include/linux/atmdev.h
72630 +++ b/include/linux/atmdev.h
72631 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72632 #endif
72633
72634 struct k_atm_aal_stats {
72635 -#define __HANDLE_ITEM(i) atomic_t i
72636 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72637 __AAL_STAT_ITEMS
72638 #undef __HANDLE_ITEM
72639 };
72640 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72641 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72642 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72643 struct module *owner;
72644 -};
72645 +} __do_const ;
72646
72647 struct atmphy_ops {
72648 int (*start)(struct atm_dev *dev);
72649 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72650 index 70cf138..0418ee2 100644
72651 --- a/include/linux/binfmts.h
72652 +++ b/include/linux/binfmts.h
72653 @@ -73,8 +73,10 @@ struct linux_binfmt {
72654 int (*load_binary)(struct linux_binprm *);
72655 int (*load_shlib)(struct file *);
72656 int (*core_dump)(struct coredump_params *cprm);
72657 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72658 + void (*handle_mmap)(struct file *);
72659 unsigned long min_coredump; /* minimal dump size */
72660 -};
72661 +} __do_const;
72662
72663 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72664
72665 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72666 index 2fdb4a4..54aad7e 100644
72667 --- a/include/linux/blkdev.h
72668 +++ b/include/linux/blkdev.h
72669 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72670 /* this callback is with swap_lock and sometimes page table lock held */
72671 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72672 struct module *owner;
72673 -};
72674 +} __do_const;
72675
72676 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72677 unsigned long);
72678 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72679 index 7c2e030..b72475d 100644
72680 --- a/include/linux/blktrace_api.h
72681 +++ b/include/linux/blktrace_api.h
72682 @@ -23,7 +23,7 @@ struct blk_trace {
72683 struct dentry *dir;
72684 struct dentry *dropped_file;
72685 struct dentry *msg_file;
72686 - atomic_t dropped;
72687 + atomic_unchecked_t dropped;
72688 };
72689
72690 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72691 diff --git a/include/linux/cache.h b/include/linux/cache.h
72692 index 4c57065..40346da 100644
72693 --- a/include/linux/cache.h
72694 +++ b/include/linux/cache.h
72695 @@ -16,6 +16,14 @@
72696 #define __read_mostly
72697 #endif
72698
72699 +#ifndef __read_only
72700 +#ifdef CONFIG_PAX_KERNEXEC
72701 +#error KERNEXEC requires __read_only
72702 +#else
72703 +#define __read_only __read_mostly
72704 +#endif
72705 +#endif
72706 +
72707 #ifndef ____cacheline_aligned
72708 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72709 #endif
72710 diff --git a/include/linux/capability.h b/include/linux/capability.h
72711 index d9a4f7f4..19f77d6 100644
72712 --- a/include/linux/capability.h
72713 +++ b/include/linux/capability.h
72714 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72715 extern bool nsown_capable(int cap);
72716 extern bool inode_capable(const struct inode *inode, int cap);
72717 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72718 +extern bool capable_nolog(int cap);
72719 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72720 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72721
72722 /* audit system wants to get cap info from files as well */
72723 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72724
72725 +extern int is_privileged_binary(const struct dentry *dentry);
72726 +
72727 #endif /* !_LINUX_CAPABILITY_H */
72728 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72729 index 8609d57..86e4d79 100644
72730 --- a/include/linux/cdrom.h
72731 +++ b/include/linux/cdrom.h
72732 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72733
72734 /* driver specifications */
72735 const int capability; /* capability flags */
72736 - int n_minors; /* number of active minor devices */
72737 /* handle uniform packets for scsi type devices (scsi,atapi) */
72738 int (*generic_packet) (struct cdrom_device_info *,
72739 struct packet_command *);
72740 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72741 index 4ce9056..86caac6 100644
72742 --- a/include/linux/cleancache.h
72743 +++ b/include/linux/cleancache.h
72744 @@ -31,7 +31,7 @@ struct cleancache_ops {
72745 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72746 void (*invalidate_inode)(int, struct cleancache_filekey);
72747 void (*invalidate_fs)(int);
72748 -};
72749 +} __no_const;
72750
72751 extern struct cleancache_ops *
72752 cleancache_register_ops(struct cleancache_ops *ops);
72753 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72754 index 1ec14a7..d0654a2 100644
72755 --- a/include/linux/clk-provider.h
72756 +++ b/include/linux/clk-provider.h
72757 @@ -132,6 +132,7 @@ struct clk_ops {
72758 unsigned long);
72759 void (*init)(struct clk_hw *hw);
72760 };
72761 +typedef struct clk_ops __no_const clk_ops_no_const;
72762
72763 /**
72764 * struct clk_init_data - holds init data that's common to all clocks and is
72765 diff --git a/include/linux/compat.h b/include/linux/compat.h
72766 index ec1aee4..1077986 100644
72767 --- a/include/linux/compat.h
72768 +++ b/include/linux/compat.h
72769 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72770 compat_size_t __user *len_ptr);
72771
72772 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72773 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72774 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72775 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72776 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72777 compat_ssize_t msgsz, int msgflg);
72778 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72779 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72780 compat_ulong_t addr, compat_ulong_t data);
72781 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72782 - compat_long_t addr, compat_long_t data);
72783 + compat_ulong_t addr, compat_ulong_t data);
72784
72785 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72786 /*
72787 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72788 index ded4299..da50e3b 100644
72789 --- a/include/linux/compiler-gcc4.h
72790 +++ b/include/linux/compiler-gcc4.h
72791 @@ -39,9 +39,29 @@
72792 # define __compiletime_warning(message) __attribute__((warning(message)))
72793 # define __compiletime_error(message) __attribute__((error(message)))
72794 #endif /* __CHECKER__ */
72795 +
72796 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72797 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72798 +#define __bos0(ptr) __bos((ptr), 0)
72799 +#define __bos1(ptr) __bos((ptr), 1)
72800 #endif /* GCC_VERSION >= 40300 */
72801
72802 #if GCC_VERSION >= 40500
72803 +
72804 +#ifdef CONSTIFY_PLUGIN
72805 +#define __no_const __attribute__((no_const))
72806 +#define __do_const __attribute__((do_const))
72807 +#endif
72808 +
72809 +#ifdef SIZE_OVERFLOW_PLUGIN
72810 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72811 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72812 +#endif
72813 +
72814 +#ifdef LATENT_ENTROPY_PLUGIN
72815 +#define __latent_entropy __attribute__((latent_entropy))
72816 +#endif
72817 +
72818 /*
72819 * Mark a position in code as unreachable. This can be used to
72820 * suppress control flow warnings after asm blocks that transfer
72821 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72822 index 92669cd..1771a15 100644
72823 --- a/include/linux/compiler.h
72824 +++ b/include/linux/compiler.h
72825 @@ -5,11 +5,14 @@
72826
72827 #ifdef __CHECKER__
72828 # define __user __attribute__((noderef, address_space(1)))
72829 +# define __force_user __force __user
72830 # define __kernel __attribute__((address_space(0)))
72831 +# define __force_kernel __force __kernel
72832 # define __safe __attribute__((safe))
72833 # define __force __attribute__((force))
72834 # define __nocast __attribute__((nocast))
72835 # define __iomem __attribute__((noderef, address_space(2)))
72836 +# define __force_iomem __force __iomem
72837 # define __must_hold(x) __attribute__((context(x,1,1)))
72838 # define __acquires(x) __attribute__((context(x,0,1)))
72839 # define __releases(x) __attribute__((context(x,1,0)))
72840 @@ -17,20 +20,37 @@
72841 # define __release(x) __context__(x,-1)
72842 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72843 # define __percpu __attribute__((noderef, address_space(3)))
72844 +# define __force_percpu __force __percpu
72845 #ifdef CONFIG_SPARSE_RCU_POINTER
72846 # define __rcu __attribute__((noderef, address_space(4)))
72847 +# define __force_rcu __force __rcu
72848 #else
72849 # define __rcu
72850 +# define __force_rcu
72851 #endif
72852 extern void __chk_user_ptr(const volatile void __user *);
72853 extern void __chk_io_ptr(const volatile void __iomem *);
72854 #else
72855 -# define __user
72856 -# define __kernel
72857 +# ifdef CHECKER_PLUGIN
72858 +//# define __user
72859 +//# define __force_user
72860 +//# define __kernel
72861 +//# define __force_kernel
72862 +# else
72863 +# ifdef STRUCTLEAK_PLUGIN
72864 +# define __user __attribute__((user))
72865 +# else
72866 +# define __user
72867 +# endif
72868 +# define __force_user
72869 +# define __kernel
72870 +# define __force_kernel
72871 +# endif
72872 # define __safe
72873 # define __force
72874 # define __nocast
72875 # define __iomem
72876 +# define __force_iomem
72877 # define __chk_user_ptr(x) (void)0
72878 # define __chk_io_ptr(x) (void)0
72879 # define __builtin_warning(x, y...) (1)
72880 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72881 # define __release(x) (void)0
72882 # define __cond_lock(x,c) (c)
72883 # define __percpu
72884 +# define __force_percpu
72885 # define __rcu
72886 +# define __force_rcu
72887 #endif
72888
72889 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72890 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72891 # define __attribute_const__ /* unimplemented */
72892 #endif
72893
72894 +#ifndef __no_const
72895 +# define __no_const
72896 +#endif
72897 +
72898 +#ifndef __do_const
72899 +# define __do_const
72900 +#endif
72901 +
72902 +#ifndef __size_overflow
72903 +# define __size_overflow(...)
72904 +#endif
72905 +
72906 +#ifndef __intentional_overflow
72907 +# define __intentional_overflow(...)
72908 +#endif
72909 +
72910 +#ifndef __latent_entropy
72911 +# define __latent_entropy
72912 +#endif
72913 +
72914 /*
72915 * Tell gcc if a function is cold. The compiler will assume any path
72916 * directly leading to the call is unlikely.
72917 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72918 #define __cold
72919 #endif
72920
72921 +#ifndef __alloc_size
72922 +#define __alloc_size(...)
72923 +#endif
72924 +
72925 +#ifndef __bos
72926 +#define __bos(ptr, arg)
72927 +#endif
72928 +
72929 +#ifndef __bos0
72930 +#define __bos0(ptr)
72931 +#endif
72932 +
72933 +#ifndef __bos1
72934 +#define __bos1(ptr)
72935 +#endif
72936 +
72937 /* Simple shorthand for a section definition */
72938 #ifndef __section
72939 # define __section(S) __attribute__ ((__section__(#S)))
72940 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72941 * use is to mediate communication between process-level code and irq/NMI
72942 * handlers, all running on the same CPU.
72943 */
72944 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72945 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72946 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72947
72948 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72949 #ifdef CONFIG_KPROBES
72950 diff --git a/include/linux/completion.h b/include/linux/completion.h
72951 index 3cd574d..adce5fa 100644
72952 --- a/include/linux/completion.h
72953 +++ b/include/linux/completion.h
72954 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72955 extern void wait_for_completion(struct completion *);
72956 extern void wait_for_completion_io(struct completion *);
72957 extern int wait_for_completion_interruptible(struct completion *x);
72958 -extern int wait_for_completion_killable(struct completion *x);
72959 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72960 extern unsigned long wait_for_completion_timeout(struct completion *x,
72961 unsigned long timeout);
72962 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72963 unsigned long timeout);
72964 extern long wait_for_completion_interruptible_timeout(
72965 - struct completion *x, unsigned long timeout);
72966 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72967 extern long wait_for_completion_killable_timeout(
72968 - struct completion *x, unsigned long timeout);
72969 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72970 extern bool try_wait_for_completion(struct completion *x);
72971 extern bool completion_done(struct completion *x);
72972
72973 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72974 index 34025df..d94bbbc 100644
72975 --- a/include/linux/configfs.h
72976 +++ b/include/linux/configfs.h
72977 @@ -125,7 +125,7 @@ struct configfs_attribute {
72978 const char *ca_name;
72979 struct module *ca_owner;
72980 umode_t ca_mode;
72981 -};
72982 +} __do_const;
72983
72984 /*
72985 * Users often need to create attribute structures for their configurable
72986 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72987 index 90d5a15..950cb80 100644
72988 --- a/include/linux/cpufreq.h
72989 +++ b/include/linux/cpufreq.h
72990 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72991 int (*suspend) (struct cpufreq_policy *policy);
72992 int (*resume) (struct cpufreq_policy *policy);
72993 struct freq_attr **attr;
72994 -};
72995 +} __do_const;
72996
72997 /* flags */
72998
72999 @@ -325,6 +325,7 @@ struct global_attr {
73000 ssize_t (*store)(struct kobject *a, struct attribute *b,
73001 const char *c, size_t count);
73002 };
73003 +typedef struct global_attr __no_const global_attr_no_const;
73004
73005 #define define_one_global_ro(_name) \
73006 static struct global_attr _name = \
73007 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
73008 index 0bc4b74..973b368 100644
73009 --- a/include/linux/cpuidle.h
73010 +++ b/include/linux/cpuidle.h
73011 @@ -52,7 +52,8 @@ struct cpuidle_state {
73012 int index);
73013
73014 int (*enter_dead) (struct cpuidle_device *dev, int index);
73015 -};
73016 +} __do_const;
73017 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
73018
73019 /* Idle State Flags */
73020 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
73021 @@ -191,7 +192,7 @@ struct cpuidle_governor {
73022 void (*reflect) (struct cpuidle_device *dev, int index);
73023
73024 struct module *owner;
73025 -};
73026 +} __do_const;
73027
73028 #ifdef CONFIG_CPU_IDLE
73029
73030 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
73031 index d08e4d2..95fad61 100644
73032 --- a/include/linux/cpumask.h
73033 +++ b/include/linux/cpumask.h
73034 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73035 }
73036
73037 /* Valid inputs for n are -1 and 0. */
73038 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73039 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73040 {
73041 return n+1;
73042 }
73043
73044 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73045 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73046 {
73047 return n+1;
73048 }
73049
73050 -static inline unsigned int cpumask_next_and(int n,
73051 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
73052 const struct cpumask *srcp,
73053 const struct cpumask *andp)
73054 {
73055 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73056 *
73057 * Returns >= nr_cpu_ids if no further cpus set.
73058 */
73059 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73060 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73061 {
73062 /* -1 is a legal arg here. */
73063 if (n != -1)
73064 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73065 *
73066 * Returns >= nr_cpu_ids if no further cpus unset.
73067 */
73068 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73069 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73070 {
73071 /* -1 is a legal arg here. */
73072 if (n != -1)
73073 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73074 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
73075 }
73076
73077 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
73078 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
73079 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
73080
73081 /**
73082 diff --git a/include/linux/cred.h b/include/linux/cred.h
73083 index 04421e8..6bce4ef 100644
73084 --- a/include/linux/cred.h
73085 +++ b/include/linux/cred.h
73086 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
73087 static inline void validate_process_creds(void)
73088 {
73089 }
73090 +static inline void validate_task_creds(struct task_struct *task)
73091 +{
73092 +}
73093 #endif
73094
73095 /**
73096 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
73097 index b92eadf..b4ecdc1 100644
73098 --- a/include/linux/crypto.h
73099 +++ b/include/linux/crypto.h
73100 @@ -373,7 +373,7 @@ struct cipher_tfm {
73101 const u8 *key, unsigned int keylen);
73102 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73103 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73104 -};
73105 +} __no_const;
73106
73107 struct hash_tfm {
73108 int (*init)(struct hash_desc *desc);
73109 @@ -394,13 +394,13 @@ struct compress_tfm {
73110 int (*cot_decompress)(struct crypto_tfm *tfm,
73111 const u8 *src, unsigned int slen,
73112 u8 *dst, unsigned int *dlen);
73113 -};
73114 +} __no_const;
73115
73116 struct rng_tfm {
73117 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
73118 unsigned int dlen);
73119 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
73120 -};
73121 +} __no_const;
73122
73123 #define crt_ablkcipher crt_u.ablkcipher
73124 #define crt_aead crt_u.aead
73125 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
73126 index 653589e..4ef254a 100644
73127 --- a/include/linux/ctype.h
73128 +++ b/include/linux/ctype.h
73129 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
73130 * Fast implementation of tolower() for internal usage. Do not use in your
73131 * code.
73132 */
73133 -static inline char _tolower(const char c)
73134 +static inline unsigned char _tolower(const unsigned char c)
73135 {
73136 return c | 0x20;
73137 }
73138 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
73139 index 7925bf0..d5143d2 100644
73140 --- a/include/linux/decompress/mm.h
73141 +++ b/include/linux/decompress/mm.h
73142 @@ -77,7 +77,7 @@ static void free(void *where)
73143 * warnings when not needed (indeed large_malloc / large_free are not
73144 * needed by inflate */
73145
73146 -#define malloc(a) kmalloc(a, GFP_KERNEL)
73147 +#define malloc(a) kmalloc((a), GFP_KERNEL)
73148 #define free(a) kfree(a)
73149
73150 #define large_malloc(a) vmalloc(a)
73151 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
73152 index 5f1ab92..39c35ae 100644
73153 --- a/include/linux/devfreq.h
73154 +++ b/include/linux/devfreq.h
73155 @@ -114,7 +114,7 @@ struct devfreq_governor {
73156 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
73157 int (*event_handler)(struct devfreq *devfreq,
73158 unsigned int event, void *data);
73159 -};
73160 +} __do_const;
73161
73162 /**
73163 * struct devfreq - Device devfreq structure
73164 diff --git a/include/linux/device.h b/include/linux/device.h
73165 index 22b546a..a573dc9 100644
73166 --- a/include/linux/device.h
73167 +++ b/include/linux/device.h
73168 @@ -305,7 +305,7 @@ struct subsys_interface {
73169 struct list_head node;
73170 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
73171 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
73172 -};
73173 +} __do_const;
73174
73175 int subsys_interface_register(struct subsys_interface *sif);
73176 void subsys_interface_unregister(struct subsys_interface *sif);
73177 @@ -493,7 +493,7 @@ struct device_type {
73178 void (*release)(struct device *dev);
73179
73180 const struct dev_pm_ops *pm;
73181 -};
73182 +} __do_const;
73183
73184 /* interface for exporting device attributes */
73185 struct device_attribute {
73186 @@ -503,11 +503,12 @@ struct device_attribute {
73187 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
73188 const char *buf, size_t count);
73189 };
73190 +typedef struct device_attribute __no_const device_attribute_no_const;
73191
73192 struct dev_ext_attribute {
73193 struct device_attribute attr;
73194 void *var;
73195 -};
73196 +} __do_const;
73197
73198 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
73199 char *buf);
73200 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
73201 index 94af418..b1ca7a2 100644
73202 --- a/include/linux/dma-mapping.h
73203 +++ b/include/linux/dma-mapping.h
73204 @@ -54,7 +54,7 @@ struct dma_map_ops {
73205 u64 (*get_required_mask)(struct device *dev);
73206 #endif
73207 int is_phys;
73208 -};
73209 +} __do_const;
73210
73211 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
73212
73213 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
73214 index cb286b1..923d066 100644
73215 --- a/include/linux/dmaengine.h
73216 +++ b/include/linux/dmaengine.h
73217 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
73218 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
73219 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
73220
73221 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73222 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73223 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
73224 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73225 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73226 struct dma_pinned_list *pinned_list, struct page *page,
73227 unsigned int offset, size_t len);
73228
73229 diff --git a/include/linux/efi.h b/include/linux/efi.h
73230 index 5f8f176..62a0556 100644
73231 --- a/include/linux/efi.h
73232 +++ b/include/linux/efi.h
73233 @@ -745,6 +745,7 @@ struct efivar_operations {
73234 efi_set_variable_t *set_variable;
73235 efi_query_variable_store_t *query_variable_store;
73236 };
73237 +typedef struct efivar_operations __no_const efivar_operations_no_const;
73238
73239 struct efivars {
73240 /*
73241 diff --git a/include/linux/elf.h b/include/linux/elf.h
73242 index 40a3c0e..4c45a38 100644
73243 --- a/include/linux/elf.h
73244 +++ b/include/linux/elf.h
73245 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
73246 #define elf_note elf32_note
73247 #define elf_addr_t Elf32_Off
73248 #define Elf_Half Elf32_Half
73249 +#define elf_dyn Elf32_Dyn
73250
73251 #else
73252
73253 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
73254 #define elf_note elf64_note
73255 #define elf_addr_t Elf64_Off
73256 #define Elf_Half Elf64_Half
73257 +#define elf_dyn Elf64_Dyn
73258
73259 #endif
73260
73261 diff --git a/include/linux/err.h b/include/linux/err.h
73262 index 221fcfb..f29e5e2 100644
73263 --- a/include/linux/err.h
73264 +++ b/include/linux/err.h
73265 @@ -19,12 +19,12 @@
73266
73267 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
73268
73269 -static inline void * __must_check ERR_PTR(long error)
73270 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
73271 {
73272 return (void *) error;
73273 }
73274
73275 -static inline long __must_check PTR_ERR(__force const void *ptr)
73276 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
73277 {
73278 return (long) ptr;
73279 }
73280 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
73281 index fcb51c8..bdafcf6 100644
73282 --- a/include/linux/extcon.h
73283 +++ b/include/linux/extcon.h
73284 @@ -134,7 +134,7 @@ struct extcon_dev {
73285 /* /sys/class/extcon/.../mutually_exclusive/... */
73286 struct attribute_group attr_g_muex;
73287 struct attribute **attrs_muex;
73288 - struct device_attribute *d_attrs_muex;
73289 + device_attribute_no_const *d_attrs_muex;
73290 };
73291
73292 /**
73293 diff --git a/include/linux/fb.h b/include/linux/fb.h
73294 index ffac70a..ca3e711 100644
73295 --- a/include/linux/fb.h
73296 +++ b/include/linux/fb.h
73297 @@ -304,7 +304,7 @@ struct fb_ops {
73298 /* called at KDB enter and leave time to prepare the console */
73299 int (*fb_debug_enter)(struct fb_info *info);
73300 int (*fb_debug_leave)(struct fb_info *info);
73301 -};
73302 +} __do_const;
73303
73304 #ifdef CONFIG_FB_TILEBLITTING
73305 #define FB_TILE_CURSOR_NONE 0
73306 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73307 index 085197b..0fa6f0b 100644
73308 --- a/include/linux/fdtable.h
73309 +++ b/include/linux/fdtable.h
73310 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73311 void put_files_struct(struct files_struct *fs);
73312 void reset_files_struct(struct files_struct *);
73313 int unshare_files(struct files_struct **);
73314 -struct files_struct *dup_fd(struct files_struct *, int *);
73315 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73316 void do_close_on_exec(struct files_struct *);
73317 int iterate_fd(struct files_struct *, unsigned,
73318 int (*)(const void *, struct file *, unsigned),
73319 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73320 index 8293262..2b3b8bd 100644
73321 --- a/include/linux/frontswap.h
73322 +++ b/include/linux/frontswap.h
73323 @@ -11,7 +11,7 @@ struct frontswap_ops {
73324 int (*load)(unsigned, pgoff_t, struct page *);
73325 void (*invalidate_page)(unsigned, pgoff_t);
73326 void (*invalidate_area)(unsigned);
73327 -};
73328 +} __no_const;
73329
73330 extern bool frontswap_enabled;
73331 extern struct frontswap_ops *
73332 diff --git a/include/linux/fs.h b/include/linux/fs.h
73333 index 9818747..788bfbd 100644
73334 --- a/include/linux/fs.h
73335 +++ b/include/linux/fs.h
73336 @@ -1554,7 +1554,8 @@ struct file_operations {
73337 long (*fallocate)(struct file *file, int mode, loff_t offset,
73338 loff_t len);
73339 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73340 -};
73341 +} __do_const;
73342 +typedef struct file_operations __no_const file_operations_no_const;
73343
73344 struct inode_operations {
73345 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73346 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73347 return !IS_DEADDIR(inode);
73348 }
73349
73350 +static inline bool is_sidechannel_device(const struct inode *inode)
73351 +{
73352 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73353 + umode_t mode = inode->i_mode;
73354 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73355 +#else
73356 + return false;
73357 +#endif
73358 +}
73359 +
73360 #endif /* _LINUX_FS_H */
73361 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73362 index 2b93a9a..855d94a 100644
73363 --- a/include/linux/fs_struct.h
73364 +++ b/include/linux/fs_struct.h
73365 @@ -6,7 +6,7 @@
73366 #include <linux/seqlock.h>
73367
73368 struct fs_struct {
73369 - int users;
73370 + atomic_t users;
73371 spinlock_t lock;
73372 seqcount_t seq;
73373 int umask;
73374 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73375 index a9ff9a3..1ba1788 100644
73376 --- a/include/linux/fscache-cache.h
73377 +++ b/include/linux/fscache-cache.h
73378 @@ -113,7 +113,7 @@ struct fscache_operation {
73379 fscache_operation_release_t release;
73380 };
73381
73382 -extern atomic_t fscache_op_debug_id;
73383 +extern atomic_unchecked_t fscache_op_debug_id;
73384 extern void fscache_op_work_func(struct work_struct *work);
73385
73386 extern void fscache_enqueue_operation(struct fscache_operation *);
73387 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73388 INIT_WORK(&op->work, fscache_op_work_func);
73389 atomic_set(&op->usage, 1);
73390 op->state = FSCACHE_OP_ST_INITIALISED;
73391 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73392 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73393 op->processor = processor;
73394 op->release = release;
73395 INIT_LIST_HEAD(&op->pend_link);
73396 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73397 index 7a08623..4c07b0f 100644
73398 --- a/include/linux/fscache.h
73399 +++ b/include/linux/fscache.h
73400 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73401 * - this is mandatory for any object that may have data
73402 */
73403 void (*now_uncached)(void *cookie_netfs_data);
73404 -};
73405 +} __do_const;
73406
73407 /*
73408 * fscache cached network filesystem type
73409 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73410 index 1c804b0..1432c2b 100644
73411 --- a/include/linux/fsnotify.h
73412 +++ b/include/linux/fsnotify.h
73413 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73414 struct inode *inode = file_inode(file);
73415 __u32 mask = FS_ACCESS;
73416
73417 + if (is_sidechannel_device(inode))
73418 + return;
73419 +
73420 if (S_ISDIR(inode->i_mode))
73421 mask |= FS_ISDIR;
73422
73423 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73424 struct inode *inode = file_inode(file);
73425 __u32 mask = FS_MODIFY;
73426
73427 + if (is_sidechannel_device(inode))
73428 + return;
73429 +
73430 if (S_ISDIR(inode->i_mode))
73431 mask |= FS_ISDIR;
73432
73433 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73434 */
73435 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73436 {
73437 - return kstrdup(name, GFP_KERNEL);
73438 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73439 }
73440
73441 /*
73442 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73443 index 9f3c275..8bdff5d 100644
73444 --- a/include/linux/genhd.h
73445 +++ b/include/linux/genhd.h
73446 @@ -194,7 +194,7 @@ struct gendisk {
73447 struct kobject *slave_dir;
73448
73449 struct timer_rand_state *random;
73450 - atomic_t sync_io; /* RAID */
73451 + atomic_unchecked_t sync_io; /* RAID */
73452 struct disk_events *ev;
73453 #ifdef CONFIG_BLK_DEV_INTEGRITY
73454 struct blk_integrity *integrity;
73455 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
73456 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
73457
73458 /* drivers/char/random.c */
73459 -extern void add_disk_randomness(struct gendisk *disk);
73460 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
73461 extern void rand_initialize_disk(struct gendisk *disk);
73462
73463 static inline sector_t get_start_sect(struct block_device *bdev)
73464 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73465 index 023bc34..b02b46a 100644
73466 --- a/include/linux/genl_magic_func.h
73467 +++ b/include/linux/genl_magic_func.h
73468 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73469 },
73470
73471 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73472 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73473 +static struct genl_ops ZZZ_genl_ops[] = {
73474 #include GENL_MAGIC_INCLUDE_FILE
73475 };
73476
73477 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73478 index 9b4dd49..61fd41d 100644
73479 --- a/include/linux/gfp.h
73480 +++ b/include/linux/gfp.h
73481 @@ -35,6 +35,13 @@ struct vm_area_struct;
73482 #define ___GFP_NO_KSWAPD 0x400000u
73483 #define ___GFP_OTHER_NODE 0x800000u
73484 #define ___GFP_WRITE 0x1000000u
73485 +
73486 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73487 +#define ___GFP_USERCOPY 0x2000000u
73488 +#else
73489 +#define ___GFP_USERCOPY 0
73490 +#endif
73491 +
73492 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73493
73494 /*
73495 @@ -92,6 +99,7 @@ struct vm_area_struct;
73496 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73497 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73498 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73499 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73500
73501 /*
73502 * This may seem redundant, but it's a way of annotating false positives vs.
73503 @@ -99,7 +107,7 @@ struct vm_area_struct;
73504 */
73505 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73506
73507 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73508 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73509 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73510
73511 /* This equals 0, but use constants in case they ever change */
73512 @@ -153,6 +161,8 @@ struct vm_area_struct;
73513 /* 4GB DMA on some platforms */
73514 #define GFP_DMA32 __GFP_DMA32
73515
73516 +#define GFP_USERCOPY __GFP_USERCOPY
73517 +
73518 /* Convert GFP flags to their corresponding migrate type */
73519 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73520 {
73521 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73522 new file mode 100644
73523 index 0000000..edb2cb6
73524 --- /dev/null
73525 +++ b/include/linux/gracl.h
73526 @@ -0,0 +1,340 @@
73527 +#ifndef GR_ACL_H
73528 +#define GR_ACL_H
73529 +
73530 +#include <linux/grdefs.h>
73531 +#include <linux/resource.h>
73532 +#include <linux/capability.h>
73533 +#include <linux/dcache.h>
73534 +#include <asm/resource.h>
73535 +
73536 +/* Major status information */
73537 +
73538 +#define GR_VERSION "grsecurity 3.0"
73539 +#define GRSECURITY_VERSION 0x3000
73540 +
73541 +enum {
73542 + GR_SHUTDOWN = 0,
73543 + GR_ENABLE = 1,
73544 + GR_SPROLE = 2,
73545 + GR_OLDRELOAD = 3,
73546 + GR_SEGVMOD = 4,
73547 + GR_STATUS = 5,
73548 + GR_UNSPROLE = 6,
73549 + GR_PASSSET = 7,
73550 + GR_SPROLEPAM = 8,
73551 + GR_RELOAD = 9,
73552 +};
73553 +
73554 +/* Password setup definitions
73555 + * kernel/grhash.c */
73556 +enum {
73557 + GR_PW_LEN = 128,
73558 + GR_SALT_LEN = 16,
73559 + GR_SHA_LEN = 32,
73560 +};
73561 +
73562 +enum {
73563 + GR_SPROLE_LEN = 64,
73564 +};
73565 +
73566 +enum {
73567 + GR_NO_GLOB = 0,
73568 + GR_REG_GLOB,
73569 + GR_CREATE_GLOB
73570 +};
73571 +
73572 +#define GR_NLIMITS 32
73573 +
73574 +/* Begin Data Structures */
73575 +
73576 +struct sprole_pw {
73577 + unsigned char *rolename;
73578 + unsigned char salt[GR_SALT_LEN];
73579 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73580 +};
73581 +
73582 +struct name_entry {
73583 + __u32 key;
73584 + ino_t inode;
73585 + dev_t device;
73586 + char *name;
73587 + __u16 len;
73588 + __u8 deleted;
73589 + struct name_entry *prev;
73590 + struct name_entry *next;
73591 +};
73592 +
73593 +struct inodev_entry {
73594 + struct name_entry *nentry;
73595 + struct inodev_entry *prev;
73596 + struct inodev_entry *next;
73597 +};
73598 +
73599 +struct acl_role_db {
73600 + struct acl_role_label **r_hash;
73601 + __u32 r_size;
73602 +};
73603 +
73604 +struct inodev_db {
73605 + struct inodev_entry **i_hash;
73606 + __u32 i_size;
73607 +};
73608 +
73609 +struct name_db {
73610 + struct name_entry **n_hash;
73611 + __u32 n_size;
73612 +};
73613 +
73614 +struct crash_uid {
73615 + uid_t uid;
73616 + unsigned long expires;
73617 +};
73618 +
73619 +struct gr_hash_struct {
73620 + void **table;
73621 + void **nametable;
73622 + void *first;
73623 + __u32 table_size;
73624 + __u32 used_size;
73625 + int type;
73626 +};
73627 +
73628 +/* Userspace Grsecurity ACL data structures */
73629 +
73630 +struct acl_subject_label {
73631 + char *filename;
73632 + ino_t inode;
73633 + dev_t device;
73634 + __u32 mode;
73635 + kernel_cap_t cap_mask;
73636 + kernel_cap_t cap_lower;
73637 + kernel_cap_t cap_invert_audit;
73638 +
73639 + struct rlimit res[GR_NLIMITS];
73640 + __u32 resmask;
73641 +
73642 + __u8 user_trans_type;
73643 + __u8 group_trans_type;
73644 + uid_t *user_transitions;
73645 + gid_t *group_transitions;
73646 + __u16 user_trans_num;
73647 + __u16 group_trans_num;
73648 +
73649 + __u32 sock_families[2];
73650 + __u32 ip_proto[8];
73651 + __u32 ip_type;
73652 + struct acl_ip_label **ips;
73653 + __u32 ip_num;
73654 + __u32 inaddr_any_override;
73655 +
73656 + __u32 crashes;
73657 + unsigned long expires;
73658 +
73659 + struct acl_subject_label *parent_subject;
73660 + struct gr_hash_struct *hash;
73661 + struct acl_subject_label *prev;
73662 + struct acl_subject_label *next;
73663 +
73664 + struct acl_object_label **obj_hash;
73665 + __u32 obj_hash_size;
73666 + __u16 pax_flags;
73667 +};
73668 +
73669 +struct role_allowed_ip {
73670 + __u32 addr;
73671 + __u32 netmask;
73672 +
73673 + struct role_allowed_ip *prev;
73674 + struct role_allowed_ip *next;
73675 +};
73676 +
73677 +struct role_transition {
73678 + char *rolename;
73679 +
73680 + struct role_transition *prev;
73681 + struct role_transition *next;
73682 +};
73683 +
73684 +struct acl_role_label {
73685 + char *rolename;
73686 + uid_t uidgid;
73687 + __u16 roletype;
73688 +
73689 + __u16 auth_attempts;
73690 + unsigned long expires;
73691 +
73692 + struct acl_subject_label *root_label;
73693 + struct gr_hash_struct *hash;
73694 +
73695 + struct acl_role_label *prev;
73696 + struct acl_role_label *next;
73697 +
73698 + struct role_transition *transitions;
73699 + struct role_allowed_ip *allowed_ips;
73700 + uid_t *domain_children;
73701 + __u16 domain_child_num;
73702 +
73703 + umode_t umask;
73704 +
73705 + struct acl_subject_label **subj_hash;
73706 + __u32 subj_hash_size;
73707 +};
73708 +
73709 +struct user_acl_role_db {
73710 + struct acl_role_label **r_table;
73711 + __u32 num_pointers; /* Number of allocations to track */
73712 + __u32 num_roles; /* Number of roles */
73713 + __u32 num_domain_children; /* Number of domain children */
73714 + __u32 num_subjects; /* Number of subjects */
73715 + __u32 num_objects; /* Number of objects */
73716 +};
73717 +
73718 +struct acl_object_label {
73719 + char *filename;
73720 + ino_t inode;
73721 + dev_t device;
73722 + __u32 mode;
73723 +
73724 + struct acl_subject_label *nested;
73725 + struct acl_object_label *globbed;
73726 +
73727 + /* next two structures not used */
73728 +
73729 + struct acl_object_label *prev;
73730 + struct acl_object_label *next;
73731 +};
73732 +
73733 +struct acl_ip_label {
73734 + char *iface;
73735 + __u32 addr;
73736 + __u32 netmask;
73737 + __u16 low, high;
73738 + __u8 mode;
73739 + __u32 type;
73740 + __u32 proto[8];
73741 +
73742 + /* next two structures not used */
73743 +
73744 + struct acl_ip_label *prev;
73745 + struct acl_ip_label *next;
73746 +};
73747 +
73748 +struct gr_arg {
73749 + struct user_acl_role_db role_db;
73750 + unsigned char pw[GR_PW_LEN];
73751 + unsigned char salt[GR_SALT_LEN];
73752 + unsigned char sum[GR_SHA_LEN];
73753 + unsigned char sp_role[GR_SPROLE_LEN];
73754 + struct sprole_pw *sprole_pws;
73755 + dev_t segv_device;
73756 + ino_t segv_inode;
73757 + uid_t segv_uid;
73758 + __u16 num_sprole_pws;
73759 + __u16 mode;
73760 +};
73761 +
73762 +struct gr_arg_wrapper {
73763 + struct gr_arg *arg;
73764 + __u32 version;
73765 + __u32 size;
73766 +};
73767 +
73768 +struct subject_map {
73769 + struct acl_subject_label *user;
73770 + struct acl_subject_label *kernel;
73771 + struct subject_map *prev;
73772 + struct subject_map *next;
73773 +};
73774 +
73775 +struct acl_subj_map_db {
73776 + struct subject_map **s_hash;
73777 + __u32 s_size;
73778 +};
73779 +
73780 +struct gr_policy_state {
73781 + struct sprole_pw **acl_special_roles;
73782 + __u16 num_sprole_pws;
73783 + struct acl_role_label *kernel_role;
73784 + struct acl_role_label *role_list;
73785 + struct acl_role_label *default_role;
73786 + struct acl_role_db acl_role_set;
73787 + struct acl_subj_map_db subj_map_set;
73788 + struct name_db name_set;
73789 + struct inodev_db inodev_set;
73790 +};
73791 +
73792 +struct gr_alloc_state {
73793 + unsigned long alloc_stack_next;
73794 + unsigned long alloc_stack_size;
73795 + void **alloc_stack;
73796 +};
73797 +
73798 +struct gr_reload_state {
73799 + struct gr_policy_state oldpolicy;
73800 + struct gr_alloc_state oldalloc;
73801 + struct gr_policy_state newpolicy;
73802 + struct gr_alloc_state newalloc;
73803 + struct gr_policy_state *oldpolicy_ptr;
73804 + struct gr_alloc_state *oldalloc_ptr;
73805 + unsigned char oldmode;
73806 +};
73807 +
73808 +/* End Data Structures Section */
73809 +
73810 +/* Hash functions generated by empirical testing by Brad Spengler
73811 + Makes good use of the low bits of the inode. Generally 0-1 times
73812 + in loop for successful match. 0-3 for unsuccessful match.
73813 + Shift/add algorithm with modulus of table size and an XOR*/
73814 +
73815 +static __inline__ unsigned int
73816 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73817 +{
73818 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73819 +}
73820 +
73821 + static __inline__ unsigned int
73822 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73823 +{
73824 + return ((const unsigned long)userp % sz);
73825 +}
73826 +
73827 +static __inline__ unsigned int
73828 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73829 +{
73830 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73831 +}
73832 +
73833 +static __inline__ unsigned int
73834 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73835 +{
73836 + return full_name_hash((const unsigned char *)name, len) % sz;
73837 +}
73838 +
73839 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73840 + subj = NULL; \
73841 + iter = 0; \
73842 + while (iter < role->subj_hash_size) { \
73843 + if (subj == NULL) \
73844 + subj = role->subj_hash[iter]; \
73845 + if (subj == NULL) { \
73846 + iter++; \
73847 + continue; \
73848 + }
73849 +
73850 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73851 + subj = subj->next; \
73852 + if (subj == NULL) \
73853 + iter++; \
73854 + }
73855 +
73856 +
73857 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73858 + subj = role->hash->first; \
73859 + while (subj != NULL) {
73860 +
73861 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73862 + subj = subj->next; \
73863 + }
73864 +
73865 +#endif
73866 +
73867 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73868 new file mode 100644
73869 index 0000000..33ebd1f
73870 --- /dev/null
73871 +++ b/include/linux/gracl_compat.h
73872 @@ -0,0 +1,156 @@
73873 +#ifndef GR_ACL_COMPAT_H
73874 +#define GR_ACL_COMPAT_H
73875 +
73876 +#include <linux/resource.h>
73877 +#include <asm/resource.h>
73878 +
73879 +struct sprole_pw_compat {
73880 + compat_uptr_t rolename;
73881 + unsigned char salt[GR_SALT_LEN];
73882 + unsigned char sum[GR_SHA_LEN];
73883 +};
73884 +
73885 +struct gr_hash_struct_compat {
73886 + compat_uptr_t table;
73887 + compat_uptr_t nametable;
73888 + compat_uptr_t first;
73889 + __u32 table_size;
73890 + __u32 used_size;
73891 + int type;
73892 +};
73893 +
73894 +struct acl_subject_label_compat {
73895 + compat_uptr_t filename;
73896 + compat_ino_t inode;
73897 + __u32 device;
73898 + __u32 mode;
73899 + kernel_cap_t cap_mask;
73900 + kernel_cap_t cap_lower;
73901 + kernel_cap_t cap_invert_audit;
73902 +
73903 + struct compat_rlimit res[GR_NLIMITS];
73904 + __u32 resmask;
73905 +
73906 + __u8 user_trans_type;
73907 + __u8 group_trans_type;
73908 + compat_uptr_t user_transitions;
73909 + compat_uptr_t group_transitions;
73910 + __u16 user_trans_num;
73911 + __u16 group_trans_num;
73912 +
73913 + __u32 sock_families[2];
73914 + __u32 ip_proto[8];
73915 + __u32 ip_type;
73916 + compat_uptr_t ips;
73917 + __u32 ip_num;
73918 + __u32 inaddr_any_override;
73919 +
73920 + __u32 crashes;
73921 + compat_ulong_t expires;
73922 +
73923 + compat_uptr_t parent_subject;
73924 + compat_uptr_t hash;
73925 + compat_uptr_t prev;
73926 + compat_uptr_t next;
73927 +
73928 + compat_uptr_t obj_hash;
73929 + __u32 obj_hash_size;
73930 + __u16 pax_flags;
73931 +};
73932 +
73933 +struct role_allowed_ip_compat {
73934 + __u32 addr;
73935 + __u32 netmask;
73936 +
73937 + compat_uptr_t prev;
73938 + compat_uptr_t next;
73939 +};
73940 +
73941 +struct role_transition_compat {
73942 + compat_uptr_t rolename;
73943 +
73944 + compat_uptr_t prev;
73945 + compat_uptr_t next;
73946 +};
73947 +
73948 +struct acl_role_label_compat {
73949 + compat_uptr_t rolename;
73950 + uid_t uidgid;
73951 + __u16 roletype;
73952 +
73953 + __u16 auth_attempts;
73954 + compat_ulong_t expires;
73955 +
73956 + compat_uptr_t root_label;
73957 + compat_uptr_t hash;
73958 +
73959 + compat_uptr_t prev;
73960 + compat_uptr_t next;
73961 +
73962 + compat_uptr_t transitions;
73963 + compat_uptr_t allowed_ips;
73964 + compat_uptr_t domain_children;
73965 + __u16 domain_child_num;
73966 +
73967 + umode_t umask;
73968 +
73969 + compat_uptr_t subj_hash;
73970 + __u32 subj_hash_size;
73971 +};
73972 +
73973 +struct user_acl_role_db_compat {
73974 + compat_uptr_t r_table;
73975 + __u32 num_pointers;
73976 + __u32 num_roles;
73977 + __u32 num_domain_children;
73978 + __u32 num_subjects;
73979 + __u32 num_objects;
73980 +};
73981 +
73982 +struct acl_object_label_compat {
73983 + compat_uptr_t filename;
73984 + compat_ino_t inode;
73985 + __u32 device;
73986 + __u32 mode;
73987 +
73988 + compat_uptr_t nested;
73989 + compat_uptr_t globbed;
73990 +
73991 + compat_uptr_t prev;
73992 + compat_uptr_t next;
73993 +};
73994 +
73995 +struct acl_ip_label_compat {
73996 + compat_uptr_t iface;
73997 + __u32 addr;
73998 + __u32 netmask;
73999 + __u16 low, high;
74000 + __u8 mode;
74001 + __u32 type;
74002 + __u32 proto[8];
74003 +
74004 + compat_uptr_t prev;
74005 + compat_uptr_t next;
74006 +};
74007 +
74008 +struct gr_arg_compat {
74009 + struct user_acl_role_db_compat role_db;
74010 + unsigned char pw[GR_PW_LEN];
74011 + unsigned char salt[GR_SALT_LEN];
74012 + unsigned char sum[GR_SHA_LEN];
74013 + unsigned char sp_role[GR_SPROLE_LEN];
74014 + compat_uptr_t sprole_pws;
74015 + __u32 segv_device;
74016 + compat_ino_t segv_inode;
74017 + uid_t segv_uid;
74018 + __u16 num_sprole_pws;
74019 + __u16 mode;
74020 +};
74021 +
74022 +struct gr_arg_wrapper_compat {
74023 + compat_uptr_t arg;
74024 + __u32 version;
74025 + __u32 size;
74026 +};
74027 +
74028 +#endif
74029 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
74030 new file mode 100644
74031 index 0000000..323ecf2
74032 --- /dev/null
74033 +++ b/include/linux/gralloc.h
74034 @@ -0,0 +1,9 @@
74035 +#ifndef __GRALLOC_H
74036 +#define __GRALLOC_H
74037 +
74038 +void acl_free_all(void);
74039 +int acl_alloc_stack_init(unsigned long size);
74040 +void *acl_alloc(unsigned long len);
74041 +void *acl_alloc_num(unsigned long num, unsigned long len);
74042 +
74043 +#endif
74044 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
74045 new file mode 100644
74046 index 0000000..be66033
74047 --- /dev/null
74048 +++ b/include/linux/grdefs.h
74049 @@ -0,0 +1,140 @@
74050 +#ifndef GRDEFS_H
74051 +#define GRDEFS_H
74052 +
74053 +/* Begin grsecurity status declarations */
74054 +
74055 +enum {
74056 + GR_READY = 0x01,
74057 + GR_STATUS_INIT = 0x00 // disabled state
74058 +};
74059 +
74060 +/* Begin ACL declarations */
74061 +
74062 +/* Role flags */
74063 +
74064 +enum {
74065 + GR_ROLE_USER = 0x0001,
74066 + GR_ROLE_GROUP = 0x0002,
74067 + GR_ROLE_DEFAULT = 0x0004,
74068 + GR_ROLE_SPECIAL = 0x0008,
74069 + GR_ROLE_AUTH = 0x0010,
74070 + GR_ROLE_NOPW = 0x0020,
74071 + GR_ROLE_GOD = 0x0040,
74072 + GR_ROLE_LEARN = 0x0080,
74073 + GR_ROLE_TPE = 0x0100,
74074 + GR_ROLE_DOMAIN = 0x0200,
74075 + GR_ROLE_PAM = 0x0400,
74076 + GR_ROLE_PERSIST = 0x0800
74077 +};
74078 +
74079 +/* ACL Subject and Object mode flags */
74080 +enum {
74081 + GR_DELETED = 0x80000000
74082 +};
74083 +
74084 +/* ACL Object-only mode flags */
74085 +enum {
74086 + GR_READ = 0x00000001,
74087 + GR_APPEND = 0x00000002,
74088 + GR_WRITE = 0x00000004,
74089 + GR_EXEC = 0x00000008,
74090 + GR_FIND = 0x00000010,
74091 + GR_INHERIT = 0x00000020,
74092 + GR_SETID = 0x00000040,
74093 + GR_CREATE = 0x00000080,
74094 + GR_DELETE = 0x00000100,
74095 + GR_LINK = 0x00000200,
74096 + GR_AUDIT_READ = 0x00000400,
74097 + GR_AUDIT_APPEND = 0x00000800,
74098 + GR_AUDIT_WRITE = 0x00001000,
74099 + GR_AUDIT_EXEC = 0x00002000,
74100 + GR_AUDIT_FIND = 0x00004000,
74101 + GR_AUDIT_INHERIT= 0x00008000,
74102 + GR_AUDIT_SETID = 0x00010000,
74103 + GR_AUDIT_CREATE = 0x00020000,
74104 + GR_AUDIT_DELETE = 0x00040000,
74105 + GR_AUDIT_LINK = 0x00080000,
74106 + GR_PTRACERD = 0x00100000,
74107 + GR_NOPTRACE = 0x00200000,
74108 + GR_SUPPRESS = 0x00400000,
74109 + GR_NOLEARN = 0x00800000,
74110 + GR_INIT_TRANSFER= 0x01000000
74111 +};
74112 +
74113 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
74114 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
74115 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
74116 +
74117 +/* ACL subject-only mode flags */
74118 +enum {
74119 + GR_KILL = 0x00000001,
74120 + GR_VIEW = 0x00000002,
74121 + GR_PROTECTED = 0x00000004,
74122 + GR_LEARN = 0x00000008,
74123 + GR_OVERRIDE = 0x00000010,
74124 + /* just a placeholder, this mode is only used in userspace */
74125 + GR_DUMMY = 0x00000020,
74126 + GR_PROTSHM = 0x00000040,
74127 + GR_KILLPROC = 0x00000080,
74128 + GR_KILLIPPROC = 0x00000100,
74129 + /* just a placeholder, this mode is only used in userspace */
74130 + GR_NOTROJAN = 0x00000200,
74131 + GR_PROTPROCFD = 0x00000400,
74132 + GR_PROCACCT = 0x00000800,
74133 + GR_RELAXPTRACE = 0x00001000,
74134 + //GR_NESTED = 0x00002000,
74135 + GR_INHERITLEARN = 0x00004000,
74136 + GR_PROCFIND = 0x00008000,
74137 + GR_POVERRIDE = 0x00010000,
74138 + GR_KERNELAUTH = 0x00020000,
74139 + GR_ATSECURE = 0x00040000,
74140 + GR_SHMEXEC = 0x00080000
74141 +};
74142 +
74143 +enum {
74144 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
74145 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
74146 + GR_PAX_ENABLE_MPROTECT = 0x0004,
74147 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
74148 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
74149 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
74150 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
74151 + GR_PAX_DISABLE_MPROTECT = 0x0400,
74152 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
74153 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
74154 +};
74155 +
74156 +enum {
74157 + GR_ID_USER = 0x01,
74158 + GR_ID_GROUP = 0x02,
74159 +};
74160 +
74161 +enum {
74162 + GR_ID_ALLOW = 0x01,
74163 + GR_ID_DENY = 0x02,
74164 +};
74165 +
74166 +#define GR_CRASH_RES 31
74167 +#define GR_UIDTABLE_MAX 500
74168 +
74169 +/* begin resource learning section */
74170 +enum {
74171 + GR_RLIM_CPU_BUMP = 60,
74172 + GR_RLIM_FSIZE_BUMP = 50000,
74173 + GR_RLIM_DATA_BUMP = 10000,
74174 + GR_RLIM_STACK_BUMP = 1000,
74175 + GR_RLIM_CORE_BUMP = 10000,
74176 + GR_RLIM_RSS_BUMP = 500000,
74177 + GR_RLIM_NPROC_BUMP = 1,
74178 + GR_RLIM_NOFILE_BUMP = 5,
74179 + GR_RLIM_MEMLOCK_BUMP = 50000,
74180 + GR_RLIM_AS_BUMP = 500000,
74181 + GR_RLIM_LOCKS_BUMP = 2,
74182 + GR_RLIM_SIGPENDING_BUMP = 5,
74183 + GR_RLIM_MSGQUEUE_BUMP = 10000,
74184 + GR_RLIM_NICE_BUMP = 1,
74185 + GR_RLIM_RTPRIO_BUMP = 1,
74186 + GR_RLIM_RTTIME_BUMP = 1000000
74187 +};
74188 +
74189 +#endif
74190 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
74191 new file mode 100644
74192 index 0000000..d25522e
74193 --- /dev/null
74194 +++ b/include/linux/grinternal.h
74195 @@ -0,0 +1,229 @@
74196 +#ifndef __GRINTERNAL_H
74197 +#define __GRINTERNAL_H
74198 +
74199 +#ifdef CONFIG_GRKERNSEC
74200 +
74201 +#include <linux/fs.h>
74202 +#include <linux/mnt_namespace.h>
74203 +#include <linux/nsproxy.h>
74204 +#include <linux/gracl.h>
74205 +#include <linux/grdefs.h>
74206 +#include <linux/grmsg.h>
74207 +
74208 +void gr_add_learn_entry(const char *fmt, ...)
74209 + __attribute__ ((format (printf, 1, 2)));
74210 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
74211 + const struct vfsmount *mnt);
74212 +__u32 gr_check_create(const struct dentry *new_dentry,
74213 + const struct dentry *parent,
74214 + const struct vfsmount *mnt, const __u32 mode);
74215 +int gr_check_protected_task(const struct task_struct *task);
74216 +__u32 to_gr_audit(const __u32 reqmode);
74217 +int gr_set_acls(const int type);
74218 +int gr_acl_is_enabled(void);
74219 +char gr_roletype_to_char(void);
74220 +
74221 +void gr_handle_alertkill(struct task_struct *task);
74222 +char *gr_to_filename(const struct dentry *dentry,
74223 + const struct vfsmount *mnt);
74224 +char *gr_to_filename1(const struct dentry *dentry,
74225 + const struct vfsmount *mnt);
74226 +char *gr_to_filename2(const struct dentry *dentry,
74227 + const struct vfsmount *mnt);
74228 +char *gr_to_filename3(const struct dentry *dentry,
74229 + const struct vfsmount *mnt);
74230 +
74231 +extern int grsec_enable_ptrace_readexec;
74232 +extern int grsec_enable_harden_ptrace;
74233 +extern int grsec_enable_link;
74234 +extern int grsec_enable_fifo;
74235 +extern int grsec_enable_execve;
74236 +extern int grsec_enable_shm;
74237 +extern int grsec_enable_execlog;
74238 +extern int grsec_enable_signal;
74239 +extern int grsec_enable_audit_ptrace;
74240 +extern int grsec_enable_forkfail;
74241 +extern int grsec_enable_time;
74242 +extern int grsec_enable_rofs;
74243 +extern int grsec_deny_new_usb;
74244 +extern int grsec_enable_chroot_shmat;
74245 +extern int grsec_enable_chroot_mount;
74246 +extern int grsec_enable_chroot_double;
74247 +extern int grsec_enable_chroot_pivot;
74248 +extern int grsec_enable_chroot_chdir;
74249 +extern int grsec_enable_chroot_chmod;
74250 +extern int grsec_enable_chroot_mknod;
74251 +extern int grsec_enable_chroot_fchdir;
74252 +extern int grsec_enable_chroot_nice;
74253 +extern int grsec_enable_chroot_execlog;
74254 +extern int grsec_enable_chroot_caps;
74255 +extern int grsec_enable_chroot_sysctl;
74256 +extern int grsec_enable_chroot_unix;
74257 +extern int grsec_enable_symlinkown;
74258 +extern kgid_t grsec_symlinkown_gid;
74259 +extern int grsec_enable_tpe;
74260 +extern kgid_t grsec_tpe_gid;
74261 +extern int grsec_enable_tpe_all;
74262 +extern int grsec_enable_tpe_invert;
74263 +extern int grsec_enable_socket_all;
74264 +extern kgid_t grsec_socket_all_gid;
74265 +extern int grsec_enable_socket_client;
74266 +extern kgid_t grsec_socket_client_gid;
74267 +extern int grsec_enable_socket_server;
74268 +extern kgid_t grsec_socket_server_gid;
74269 +extern kgid_t grsec_audit_gid;
74270 +extern int grsec_enable_group;
74271 +extern int grsec_enable_log_rwxmaps;
74272 +extern int grsec_enable_mount;
74273 +extern int grsec_enable_chdir;
74274 +extern int grsec_resource_logging;
74275 +extern int grsec_enable_blackhole;
74276 +extern int grsec_lastack_retries;
74277 +extern int grsec_enable_brute;
74278 +extern int grsec_enable_harden_ipc;
74279 +extern int grsec_lock;
74280 +
74281 +extern spinlock_t grsec_alert_lock;
74282 +extern unsigned long grsec_alert_wtime;
74283 +extern unsigned long grsec_alert_fyet;
74284 +
74285 +extern spinlock_t grsec_audit_lock;
74286 +
74287 +extern rwlock_t grsec_exec_file_lock;
74288 +
74289 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
74290 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
74291 + (tsk)->exec_file->f_path.mnt) : "/")
74292 +
74293 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
74294 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
74295 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74296 +
74297 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
74298 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
74299 + (tsk)->exec_file->f_path.mnt) : "/")
74300 +
74301 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74302 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74303 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74304 +
74305 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74306 +
74307 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74308 +
74309 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74310 +{
74311 + if (file1 && file2) {
74312 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74313 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74314 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74315 + return true;
74316 + }
74317 +
74318 + return false;
74319 +}
74320 +
74321 +#define GR_CHROOT_CAPS {{ \
74322 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74323 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74324 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74325 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74326 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74327 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74328 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74329 +
74330 +#define security_learn(normal_msg,args...) \
74331 +({ \
74332 + read_lock(&grsec_exec_file_lock); \
74333 + gr_add_learn_entry(normal_msg "\n", ## args); \
74334 + read_unlock(&grsec_exec_file_lock); \
74335 +})
74336 +
74337 +enum {
74338 + GR_DO_AUDIT,
74339 + GR_DONT_AUDIT,
74340 + /* used for non-audit messages that we shouldn't kill the task on */
74341 + GR_DONT_AUDIT_GOOD
74342 +};
74343 +
74344 +enum {
74345 + GR_TTYSNIFF,
74346 + GR_RBAC,
74347 + GR_RBAC_STR,
74348 + GR_STR_RBAC,
74349 + GR_RBAC_MODE2,
74350 + GR_RBAC_MODE3,
74351 + GR_FILENAME,
74352 + GR_SYSCTL_HIDDEN,
74353 + GR_NOARGS,
74354 + GR_ONE_INT,
74355 + GR_ONE_INT_TWO_STR,
74356 + GR_ONE_STR,
74357 + GR_STR_INT,
74358 + GR_TWO_STR_INT,
74359 + GR_TWO_INT,
74360 + GR_TWO_U64,
74361 + GR_THREE_INT,
74362 + GR_FIVE_INT_TWO_STR,
74363 + GR_TWO_STR,
74364 + GR_THREE_STR,
74365 + GR_FOUR_STR,
74366 + GR_STR_FILENAME,
74367 + GR_FILENAME_STR,
74368 + GR_FILENAME_TWO_INT,
74369 + GR_FILENAME_TWO_INT_STR,
74370 + GR_TEXTREL,
74371 + GR_PTRACE,
74372 + GR_RESOURCE,
74373 + GR_CAP,
74374 + GR_SIG,
74375 + GR_SIG2,
74376 + GR_CRASH1,
74377 + GR_CRASH2,
74378 + GR_PSACCT,
74379 + GR_RWXMAP,
74380 + GR_RWXMAPVMA
74381 +};
74382 +
74383 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74384 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74385 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74386 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74387 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74388 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74389 +#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)
74390 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74391 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74392 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74393 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74394 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74395 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74396 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74397 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74398 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74399 +#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)
74400 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74401 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74402 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74403 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74404 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74405 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74406 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74407 +#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)
74408 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74409 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74410 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74411 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74412 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74413 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74414 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74415 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74416 +#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)
74417 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74418 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74419 +
74420 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74421 +
74422 +#endif
74423 +
74424 +#endif
74425 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74426 new file mode 100644
74427 index 0000000..378a81a
74428 --- /dev/null
74429 +++ b/include/linux/grmsg.h
74430 @@ -0,0 +1,114 @@
74431 +#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"
74432 +#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"
74433 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74434 +#define GR_STOPMOD_MSG "denied modification of module state by "
74435 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74436 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74437 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74438 +#define GR_IOPL_MSG "denied use of iopl() by "
74439 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74440 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74441 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74442 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74443 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74444 +#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"
74445 +#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"
74446 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74447 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74448 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74449 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74450 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74451 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74452 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74453 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74454 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74455 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74456 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74457 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74458 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74459 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74460 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74461 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74462 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74463 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74464 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74465 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74466 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74467 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74468 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74469 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74470 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74471 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74472 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74473 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74474 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74475 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74476 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74477 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74478 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74479 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74480 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74481 +#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"
74482 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74483 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74484 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74485 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74486 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74487 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74488 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74489 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74490 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74491 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74492 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74493 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74494 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74495 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74496 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74497 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74498 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74499 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74500 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74501 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74502 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74503 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74504 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74505 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74506 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74507 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74508 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74509 +#define GR_TIME_MSG "time set by "
74510 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74511 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74512 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74513 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74514 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74515 +#define GR_BIND_MSG "denied bind() by "
74516 +#define GR_CONNECT_MSG "denied connect() by "
74517 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74518 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74519 +#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"
74520 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74521 +#define GR_CAP_ACL_MSG "use of %s denied for "
74522 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74523 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74524 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74525 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74526 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74527 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74528 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74529 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74530 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74531 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74532 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74533 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74534 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74535 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74536 +#define GR_VM86_MSG "denied use of vm86 by "
74537 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74538 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74539 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74540 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74541 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74542 +#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 "
74543 +#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 "
74544 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
74545 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74546 new file mode 100644
74547 index 0000000..b2edfb1
74548 --- /dev/null
74549 +++ b/include/linux/grsecurity.h
74550 @@ -0,0 +1,243 @@
74551 +#ifndef GR_SECURITY_H
74552 +#define GR_SECURITY_H
74553 +#include <linux/fs.h>
74554 +#include <linux/fs_struct.h>
74555 +#include <linux/binfmts.h>
74556 +#include <linux/gracl.h>
74557 +
74558 +/* notify of brain-dead configs */
74559 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74560 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74561 +#endif
74562 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74563 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74564 +#endif
74565 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74566 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74567 +#endif
74568 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74569 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74570 +#endif
74571 +
74572 +int gr_handle_new_usb(void);
74573 +
74574 +void gr_handle_brute_attach(unsigned long mm_flags);
74575 +void gr_handle_brute_check(void);
74576 +void gr_handle_kernel_exploit(void);
74577 +
74578 +char gr_roletype_to_char(void);
74579 +
74580 +int gr_acl_enable_at_secure(void);
74581 +
74582 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74583 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74584 +
74585 +void gr_del_task_from_ip_table(struct task_struct *p);
74586 +
74587 +int gr_pid_is_chrooted(struct task_struct *p);
74588 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74589 +int gr_handle_chroot_nice(void);
74590 +int gr_handle_chroot_sysctl(const int op);
74591 +int gr_handle_chroot_setpriority(struct task_struct *p,
74592 + const int niceval);
74593 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74594 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74595 + const struct vfsmount *mnt);
74596 +void gr_handle_chroot_chdir(const struct path *path);
74597 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74598 + const struct vfsmount *mnt, const int mode);
74599 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74600 + const struct vfsmount *mnt, const int mode);
74601 +int gr_handle_chroot_mount(const struct dentry *dentry,
74602 + const struct vfsmount *mnt,
74603 + const char *dev_name);
74604 +int gr_handle_chroot_pivot(void);
74605 +int gr_handle_chroot_unix(const pid_t pid);
74606 +
74607 +int gr_handle_rawio(const struct inode *inode);
74608 +
74609 +void gr_handle_ioperm(void);
74610 +void gr_handle_iopl(void);
74611 +
74612 +umode_t gr_acl_umask(void);
74613 +
74614 +int gr_tpe_allow(const struct file *file);
74615 +
74616 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74617 +void gr_clear_chroot_entries(struct task_struct *task);
74618 +
74619 +void gr_log_forkfail(const int retval);
74620 +void gr_log_timechange(void);
74621 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74622 +void gr_log_chdir(const struct dentry *dentry,
74623 + const struct vfsmount *mnt);
74624 +void gr_log_chroot_exec(const struct dentry *dentry,
74625 + const struct vfsmount *mnt);
74626 +void gr_log_remount(const char *devname, const int retval);
74627 +void gr_log_unmount(const char *devname, const int retval);
74628 +void gr_log_mount(const char *from, const char *to, const int retval);
74629 +void gr_log_textrel(struct vm_area_struct *vma);
74630 +void gr_log_ptgnustack(struct file *file);
74631 +void gr_log_rwxmmap(struct file *file);
74632 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74633 +
74634 +int gr_handle_follow_link(const struct inode *parent,
74635 + const struct inode *inode,
74636 + const struct dentry *dentry,
74637 + const struct vfsmount *mnt);
74638 +int gr_handle_fifo(const struct dentry *dentry,
74639 + const struct vfsmount *mnt,
74640 + const struct dentry *dir, const int flag,
74641 + const int acc_mode);
74642 +int gr_handle_hardlink(const struct dentry *dentry,
74643 + const struct vfsmount *mnt,
74644 + struct inode *inode,
74645 + const int mode, const struct filename *to);
74646 +
74647 +int gr_is_capable(const int cap);
74648 +int gr_is_capable_nolog(const int cap);
74649 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74650 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74651 +
74652 +void gr_copy_label(struct task_struct *tsk);
74653 +void gr_handle_crash(struct task_struct *task, const int sig);
74654 +int gr_handle_signal(const struct task_struct *p, const int sig);
74655 +int gr_check_crash_uid(const kuid_t uid);
74656 +int gr_check_protected_task(const struct task_struct *task);
74657 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74658 +int gr_acl_handle_mmap(const struct file *file,
74659 + const unsigned long prot);
74660 +int gr_acl_handle_mprotect(const struct file *file,
74661 + const unsigned long prot);
74662 +int gr_check_hidden_task(const struct task_struct *tsk);
74663 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74664 + const struct vfsmount *mnt);
74665 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74666 + const struct vfsmount *mnt);
74667 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74668 + const struct vfsmount *mnt, const int fmode);
74669 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74670 + const struct vfsmount *mnt, umode_t *mode);
74671 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74672 + const struct vfsmount *mnt);
74673 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74674 + const struct vfsmount *mnt);
74675 +int gr_handle_ptrace(struct task_struct *task, const long request);
74676 +int gr_handle_proc_ptrace(struct task_struct *task);
74677 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74678 + const struct vfsmount *mnt);
74679 +int gr_check_crash_exec(const struct file *filp);
74680 +int gr_acl_is_enabled(void);
74681 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74682 + const kgid_t gid);
74683 +int gr_set_proc_label(const struct dentry *dentry,
74684 + const struct vfsmount *mnt,
74685 + const int unsafe_flags);
74686 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74687 + const struct vfsmount *mnt);
74688 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74689 + const struct vfsmount *mnt, int acc_mode);
74690 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74691 + const struct dentry *p_dentry,
74692 + const struct vfsmount *p_mnt,
74693 + int open_flags, int acc_mode, const int imode);
74694 +void gr_handle_create(const struct dentry *dentry,
74695 + const struct vfsmount *mnt);
74696 +void gr_handle_proc_create(const struct dentry *dentry,
74697 + const struct inode *inode);
74698 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74699 + const struct dentry *parent_dentry,
74700 + const struct vfsmount *parent_mnt,
74701 + const int mode);
74702 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74703 + const struct dentry *parent_dentry,
74704 + const struct vfsmount *parent_mnt);
74705 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74706 + const struct vfsmount *mnt);
74707 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74708 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74709 + const struct vfsmount *mnt);
74710 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74711 + const struct dentry *parent_dentry,
74712 + const struct vfsmount *parent_mnt,
74713 + const struct filename *from);
74714 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74715 + const struct dentry *parent_dentry,
74716 + const struct vfsmount *parent_mnt,
74717 + const struct dentry *old_dentry,
74718 + const struct vfsmount *old_mnt, const struct filename *to);
74719 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74720 +int gr_acl_handle_rename(struct dentry *new_dentry,
74721 + struct dentry *parent_dentry,
74722 + const struct vfsmount *parent_mnt,
74723 + struct dentry *old_dentry,
74724 + struct inode *old_parent_inode,
74725 + struct vfsmount *old_mnt, const struct filename *newname);
74726 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74727 + struct dentry *old_dentry,
74728 + struct dentry *new_dentry,
74729 + struct vfsmount *mnt, const __u8 replace);
74730 +__u32 gr_check_link(const struct dentry *new_dentry,
74731 + const struct dentry *parent_dentry,
74732 + const struct vfsmount *parent_mnt,
74733 + const struct dentry *old_dentry,
74734 + const struct vfsmount *old_mnt);
74735 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74736 + const unsigned int namelen, const ino_t ino);
74737 +
74738 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74739 + const struct vfsmount *mnt);
74740 +void gr_acl_handle_exit(void);
74741 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74742 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74743 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74744 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74745 +void gr_audit_ptrace(struct task_struct *task);
74746 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74747 +void gr_put_exec_file(struct task_struct *task);
74748 +
74749 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74750 +
74751 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74752 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74753 + const unsigned long wanted, const int gt);
74754 +#else
74755 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74756 + const unsigned long wanted, const int gt)
74757 +{
74758 +}
74759 +#endif
74760 +
74761 +#ifdef CONFIG_GRKERNSEC_RESLOG
74762 +extern void gr_log_resource(const struct task_struct *task, const int res,
74763 + const unsigned long wanted, const int gt);
74764 +#else
74765 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74766 + const unsigned long wanted, const int gt)
74767 +{
74768 +}
74769 +#endif
74770 +
74771 +#ifdef CONFIG_GRKERNSEC
74772 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74773 +void gr_handle_vm86(void);
74774 +void gr_handle_mem_readwrite(u64 from, u64 to);
74775 +
74776 +void gr_log_badprocpid(const char *entry);
74777 +
74778 +extern int grsec_enable_dmesg;
74779 +extern int grsec_disable_privio;
74780 +
74781 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74782 +extern kgid_t grsec_proc_gid;
74783 +#endif
74784 +
74785 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74786 +extern int grsec_enable_chroot_findtask;
74787 +#endif
74788 +#ifdef CONFIG_GRKERNSEC_SETXID
74789 +extern int grsec_enable_setxid;
74790 +#endif
74791 +#endif
74792 +
74793 +#endif
74794 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74795 new file mode 100644
74796 index 0000000..e7ffaaf
74797 --- /dev/null
74798 +++ b/include/linux/grsock.h
74799 @@ -0,0 +1,19 @@
74800 +#ifndef __GRSOCK_H
74801 +#define __GRSOCK_H
74802 +
74803 +extern void gr_attach_curr_ip(const struct sock *sk);
74804 +extern int gr_handle_sock_all(const int family, const int type,
74805 + const int protocol);
74806 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74807 +extern int gr_handle_sock_server_other(const struct sock *sck);
74808 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74809 +extern int gr_search_connect(struct socket * sock,
74810 + struct sockaddr_in * addr);
74811 +extern int gr_search_bind(struct socket * sock,
74812 + struct sockaddr_in * addr);
74813 +extern int gr_search_listen(struct socket * sock);
74814 +extern int gr_search_accept(struct socket * sock);
74815 +extern int gr_search_socket(const int domain, const int type,
74816 + const int protocol);
74817 +
74818 +#endif
74819 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74820 index 7fb31da..08b5114 100644
74821 --- a/include/linux/highmem.h
74822 +++ b/include/linux/highmem.h
74823 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74824 kunmap_atomic(kaddr);
74825 }
74826
74827 +static inline void sanitize_highpage(struct page *page)
74828 +{
74829 + void *kaddr;
74830 + unsigned long flags;
74831 +
74832 + local_irq_save(flags);
74833 + kaddr = kmap_atomic(page);
74834 + clear_page(kaddr);
74835 + kunmap_atomic(kaddr);
74836 + local_irq_restore(flags);
74837 +}
74838 +
74839 static inline void zero_user_segments(struct page *page,
74840 unsigned start1, unsigned end1,
74841 unsigned start2, unsigned end2)
74842 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74843 index 1c7b89a..7f52502 100644
74844 --- a/include/linux/hwmon-sysfs.h
74845 +++ b/include/linux/hwmon-sysfs.h
74846 @@ -25,7 +25,8 @@
74847 struct sensor_device_attribute{
74848 struct device_attribute dev_attr;
74849 int index;
74850 -};
74851 +} __do_const;
74852 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74853 #define to_sensor_dev_attr(_dev_attr) \
74854 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74855
74856 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74857 struct device_attribute dev_attr;
74858 u8 index;
74859 u8 nr;
74860 -};
74861 +} __do_const;
74862 #define to_sensor_dev_attr_2(_dev_attr) \
74863 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74864
74865 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74866 index e988fa9..ff9f17e 100644
74867 --- a/include/linux/i2c.h
74868 +++ b/include/linux/i2c.h
74869 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74870 /* To determine what the adapter supports */
74871 u32 (*functionality) (struct i2c_adapter *);
74872 };
74873 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74874
74875 /**
74876 * struct i2c_bus_recovery_info - I2C bus recovery information
74877 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74878 index d23c3c2..eb63c81 100644
74879 --- a/include/linux/i2o.h
74880 +++ b/include/linux/i2o.h
74881 @@ -565,7 +565,7 @@ struct i2o_controller {
74882 struct i2o_device *exec; /* Executive */
74883 #if BITS_PER_LONG == 64
74884 spinlock_t context_list_lock; /* lock for context_list */
74885 - atomic_t context_list_counter; /* needed for unique contexts */
74886 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74887 struct list_head context_list; /* list of context id's
74888 and pointers */
74889 #endif
74890 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74891 index aff7ad8..3942bbd 100644
74892 --- a/include/linux/if_pppox.h
74893 +++ b/include/linux/if_pppox.h
74894 @@ -76,7 +76,7 @@ struct pppox_proto {
74895 int (*ioctl)(struct socket *sock, unsigned int cmd,
74896 unsigned long arg);
74897 struct module *owner;
74898 -};
74899 +} __do_const;
74900
74901 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74902 extern void unregister_pppox_proto(int proto_num);
74903 diff --git a/include/linux/init.h b/include/linux/init.h
74904 index e73f2b7..cc996e0 100644
74905 --- a/include/linux/init.h
74906 +++ b/include/linux/init.h
74907 @@ -39,9 +39,17 @@
74908 * Also note, that this data cannot be "const".
74909 */
74910
74911 +#define add_init_latent_entropy __latent_entropy
74912 +
74913 +#ifdef CONFIG_MEMORY_HOTPLUG
74914 +#define add_meminit_latent_entropy
74915 +#else
74916 +#define add_meminit_latent_entropy __latent_entropy
74917 +#endif
74918 +
74919 /* These are for everybody (although not all archs will actually
74920 discard it in modules) */
74921 -#define __init __section(.init.text) __cold notrace
74922 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74923 #define __initdata __section(.init.data)
74924 #define __initconst __constsection(.init.rodata)
74925 #define __exitdata __section(.exit.data)
74926 @@ -102,7 +110,7 @@
74927 #define __cpuexitconst
74928
74929 /* Used for MEMORY_HOTPLUG */
74930 -#define __meminit __section(.meminit.text) __cold notrace
74931 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74932 #define __meminitdata __section(.meminit.data)
74933 #define __meminitconst __constsection(.meminit.rodata)
74934 #define __memexit __section(.memexit.text) __exitused __cold notrace
74935 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74936 index 5cd0f09..c9f67cc 100644
74937 --- a/include/linux/init_task.h
74938 +++ b/include/linux/init_task.h
74939 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74940
74941 #define INIT_TASK_COMM "swapper"
74942
74943 +#ifdef CONFIG_X86
74944 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74945 +#else
74946 +#define INIT_TASK_THREAD_INFO
74947 +#endif
74948 +
74949 /*
74950 * INIT_TASK is used to set up the first task table, touch at
74951 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74952 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74953 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74954 .comm = INIT_TASK_COMM, \
74955 .thread = INIT_THREAD, \
74956 + INIT_TASK_THREAD_INFO \
74957 .fs = &init_fs, \
74958 .files = &init_files, \
74959 .signal = &init_signals, \
74960 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74961 index 5fa5afe..ac55b25 100644
74962 --- a/include/linux/interrupt.h
74963 +++ b/include/linux/interrupt.h
74964 @@ -430,7 +430,7 @@ enum
74965 /* map softirq index to softirq name. update 'softirq_to_name' in
74966 * kernel/softirq.c when adding a new softirq.
74967 */
74968 -extern char *softirq_to_name[NR_SOFTIRQS];
74969 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74970
74971 /* softirq mask and active fields moved to irq_cpustat_t in
74972 * asm/hardirq.h to get better cache usage. KAO
74973 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74974
74975 struct softirq_action
74976 {
74977 - void (*action)(struct softirq_action *);
74978 -};
74979 + void (*action)(void);
74980 +} __no_const;
74981
74982 asmlinkage void do_softirq(void);
74983 asmlinkage void __do_softirq(void);
74984 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74985 +extern void open_softirq(int nr, void (*action)(void));
74986 extern void softirq_init(void);
74987 extern void __raise_softirq_irqoff(unsigned int nr);
74988
74989 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74990 index 3aeb730..2177f39 100644
74991 --- a/include/linux/iommu.h
74992 +++ b/include/linux/iommu.h
74993 @@ -113,7 +113,7 @@ struct iommu_ops {
74994 u32 (*domain_get_windows)(struct iommu_domain *domain);
74995
74996 unsigned long pgsize_bitmap;
74997 -};
74998 +} __do_const;
74999
75000 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
75001 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
75002 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
75003 index 89b7c24..382af74 100644
75004 --- a/include/linux/ioport.h
75005 +++ b/include/linux/ioport.h
75006 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
75007 int adjust_resource(struct resource *res, resource_size_t start,
75008 resource_size_t size);
75009 resource_size_t resource_alignment(struct resource *res);
75010 -static inline resource_size_t resource_size(const struct resource *res)
75011 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
75012 {
75013 return res->end - res->start + 1;
75014 }
75015 diff --git a/include/linux/irq.h b/include/linux/irq.h
75016 index f04d3ba..bcf2cfb 100644
75017 --- a/include/linux/irq.h
75018 +++ b/include/linux/irq.h
75019 @@ -333,7 +333,8 @@ struct irq_chip {
75020 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
75021
75022 unsigned long flags;
75023 -};
75024 +} __do_const;
75025 +typedef struct irq_chip __no_const irq_chip_no_const;
75026
75027 /*
75028 * irq_chip specific flags
75029 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
75030 index 3e203eb..3fe68d0 100644
75031 --- a/include/linux/irqchip/arm-gic.h
75032 +++ b/include/linux/irqchip/arm-gic.h
75033 @@ -59,9 +59,11 @@
75034
75035 #ifndef __ASSEMBLY__
75036
75037 +#include <linux/irq.h>
75038 +
75039 struct device_node;
75040
75041 -extern struct irq_chip gic_arch_extn;
75042 +extern irq_chip_no_const gic_arch_extn;
75043
75044 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
75045 u32 offset, struct device_node *);
75046 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
75047 index 6883e19..e854fcb 100644
75048 --- a/include/linux/kallsyms.h
75049 +++ b/include/linux/kallsyms.h
75050 @@ -15,7 +15,8 @@
75051
75052 struct module;
75053
75054 -#ifdef CONFIG_KALLSYMS
75055 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
75056 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75057 /* Lookup the address for a symbol. Returns 0 if not found. */
75058 unsigned long kallsyms_lookup_name(const char *name);
75059
75060 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
75061 /* Stupid that this does nothing, but I didn't create this mess. */
75062 #define __print_symbol(fmt, addr)
75063 #endif /*CONFIG_KALLSYMS*/
75064 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
75065 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
75066 +extern unsigned long kallsyms_lookup_name(const char *name);
75067 +extern void __print_symbol(const char *fmt, unsigned long address);
75068 +extern int sprint_backtrace(char *buffer, unsigned long address);
75069 +extern int sprint_symbol(char *buffer, unsigned long address);
75070 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
75071 +const char *kallsyms_lookup(unsigned long addr,
75072 + unsigned long *symbolsize,
75073 + unsigned long *offset,
75074 + char **modname, char *namebuf);
75075 +extern int kallsyms_lookup_size_offset(unsigned long addr,
75076 + unsigned long *symbolsize,
75077 + unsigned long *offset);
75078 +#endif
75079
75080 /* This macro allows us to keep printk typechecking */
75081 static __printf(1, 2)
75082 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
75083 index 518a53a..5e28358 100644
75084 --- a/include/linux/key-type.h
75085 +++ b/include/linux/key-type.h
75086 @@ -125,7 +125,7 @@ struct key_type {
75087 /* internal fields */
75088 struct list_head link; /* link in types list */
75089 struct lock_class_key lock_class; /* key->sem lock class */
75090 -};
75091 +} __do_const;
75092
75093 extern struct key_type key_type_keyring;
75094
75095 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
75096 index c6e091b..a940adf 100644
75097 --- a/include/linux/kgdb.h
75098 +++ b/include/linux/kgdb.h
75099 @@ -52,7 +52,7 @@ extern int kgdb_connected;
75100 extern int kgdb_io_module_registered;
75101
75102 extern atomic_t kgdb_setting_breakpoint;
75103 -extern atomic_t kgdb_cpu_doing_single_step;
75104 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
75105
75106 extern struct task_struct *kgdb_usethread;
75107 extern struct task_struct *kgdb_contthread;
75108 @@ -254,7 +254,7 @@ struct kgdb_arch {
75109 void (*correct_hw_break)(void);
75110
75111 void (*enable_nmi)(bool on);
75112 -};
75113 +} __do_const;
75114
75115 /**
75116 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
75117 @@ -279,7 +279,7 @@ struct kgdb_io {
75118 void (*pre_exception) (void);
75119 void (*post_exception) (void);
75120 int is_console;
75121 -};
75122 +} __do_const;
75123
75124 extern struct kgdb_arch arch_kgdb_ops;
75125
75126 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
75127 index 0555cc6..40116ce 100644
75128 --- a/include/linux/kmod.h
75129 +++ b/include/linux/kmod.h
75130 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
75131 * usually useless though. */
75132 extern __printf(2, 3)
75133 int __request_module(bool wait, const char *name, ...);
75134 +extern __printf(3, 4)
75135 +int ___request_module(bool wait, char *param_name, const char *name, ...);
75136 #define request_module(mod...) __request_module(true, mod)
75137 #define request_module_nowait(mod...) __request_module(false, mod)
75138 #define try_then_request_module(x, mod...) \
75139 @@ -57,6 +59,9 @@ struct subprocess_info {
75140 struct work_struct work;
75141 struct completion *complete;
75142 char *path;
75143 +#ifdef CONFIG_GRKERNSEC
75144 + char *origpath;
75145 +#endif
75146 char **argv;
75147 char **envp;
75148 int wait;
75149 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
75150 index 939b112..ed6ed51 100644
75151 --- a/include/linux/kobject.h
75152 +++ b/include/linux/kobject.h
75153 @@ -111,7 +111,7 @@ struct kobj_type {
75154 struct attribute **default_attrs;
75155 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
75156 const void *(*namespace)(struct kobject *kobj);
75157 -};
75158 +} __do_const;
75159
75160 struct kobj_uevent_env {
75161 char *envp[UEVENT_NUM_ENVP];
75162 @@ -134,6 +134,7 @@ struct kobj_attribute {
75163 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
75164 const char *buf, size_t count);
75165 };
75166 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
75167
75168 extern const struct sysfs_ops kobj_sysfs_ops;
75169
75170 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
75171 index f66b065..c2c29b4 100644
75172 --- a/include/linux/kobject_ns.h
75173 +++ b/include/linux/kobject_ns.h
75174 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
75175 const void *(*netlink_ns)(struct sock *sk);
75176 const void *(*initial_ns)(void);
75177 void (*drop_ns)(void *);
75178 -};
75179 +} __do_const;
75180
75181 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
75182 int kobj_ns_type_registered(enum kobj_ns_type type);
75183 diff --git a/include/linux/kref.h b/include/linux/kref.h
75184 index 484604d..0f6c5b6 100644
75185 --- a/include/linux/kref.h
75186 +++ b/include/linux/kref.h
75187 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
75188 static inline int kref_sub(struct kref *kref, unsigned int count,
75189 void (*release)(struct kref *kref))
75190 {
75191 - WARN_ON(release == NULL);
75192 + BUG_ON(release == NULL);
75193
75194 if (atomic_sub_and_test((int) count, &kref->refcount)) {
75195 release(kref);
75196 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
75197 index a63d83e..77fd685 100644
75198 --- a/include/linux/kvm_host.h
75199 +++ b/include/linux/kvm_host.h
75200 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
75201 {
75202 }
75203 #endif
75204 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75205 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75206 struct module *module);
75207 void kvm_exit(void);
75208
75209 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
75210 struct kvm_guest_debug *dbg);
75211 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
75212
75213 -int kvm_arch_init(void *opaque);
75214 +int kvm_arch_init(const void *opaque);
75215 void kvm_arch_exit(void);
75216
75217 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
75218 diff --git a/include/linux/libata.h b/include/linux/libata.h
75219 index 4ea55bb..dcd2601 100644
75220 --- a/include/linux/libata.h
75221 +++ b/include/linux/libata.h
75222 @@ -924,7 +924,7 @@ struct ata_port_operations {
75223 * fields must be pointers.
75224 */
75225 const struct ata_port_operations *inherits;
75226 -};
75227 +} __do_const;
75228
75229 struct ata_port_info {
75230 unsigned long flags;
75231 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
75232 index d3e8ad2..a949f68 100644
75233 --- a/include/linux/linkage.h
75234 +++ b/include/linux/linkage.h
75235 @@ -31,6 +31,7 @@
75236 #endif
75237
75238 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
75239 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
75240 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
75241
75242 /*
75243 diff --git a/include/linux/list.h b/include/linux/list.h
75244 index f4d8a2f..38e6e46 100644
75245 --- a/include/linux/list.h
75246 +++ b/include/linux/list.h
75247 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
75248 extern void list_del(struct list_head *entry);
75249 #endif
75250
75251 +extern void __pax_list_add(struct list_head *new,
75252 + struct list_head *prev,
75253 + struct list_head *next);
75254 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
75255 +{
75256 + __pax_list_add(new, head, head->next);
75257 +}
75258 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
75259 +{
75260 + __pax_list_add(new, head->prev, head);
75261 +}
75262 +extern void pax_list_del(struct list_head *entry);
75263 +
75264 /**
75265 * list_replace - replace old entry by new one
75266 * @old : the element to be replaced
75267 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
75268 INIT_LIST_HEAD(entry);
75269 }
75270
75271 +extern void pax_list_del_init(struct list_head *entry);
75272 +
75273 /**
75274 * list_move - delete from one list and add as another's head
75275 * @list: the entry to move
75276 diff --git a/include/linux/math64.h b/include/linux/math64.h
75277 index 2913b86..8dcbb1e 100644
75278 --- a/include/linux/math64.h
75279 +++ b/include/linux/math64.h
75280 @@ -15,7 +15,7 @@
75281 * This is commonly provided by 32bit archs to provide an optimized 64bit
75282 * divide.
75283 */
75284 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75285 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75286 {
75287 *remainder = dividend % divisor;
75288 return dividend / divisor;
75289 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
75290 /**
75291 * div64_u64 - unsigned 64bit divide with 64bit divisor
75292 */
75293 -static inline u64 div64_u64(u64 dividend, u64 divisor)
75294 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
75295 {
75296 return dividend / divisor;
75297 }
75298 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
75299 #define div64_ul(x, y) div_u64((x), (y))
75300
75301 #ifndef div_u64_rem
75302 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75303 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75304 {
75305 *remainder = do_div(dividend, divisor);
75306 return dividend;
75307 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75308 * divide.
75309 */
75310 #ifndef div_u64
75311 -static inline u64 div_u64(u64 dividend, u32 divisor)
75312 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75313 {
75314 u32 remainder;
75315 return div_u64_rem(dividend, divisor, &remainder);
75316 diff --git a/include/linux/mm.h b/include/linux/mm.h
75317 index f022460..6ecf4f9 100644
75318 --- a/include/linux/mm.h
75319 +++ b/include/linux/mm.h
75320 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75321 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75322 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75323 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75324 +
75325 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75326 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75327 +#endif
75328 +
75329 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75330
75331 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
75332 @@ -208,8 +213,8 @@ struct vm_operations_struct {
75333 /* called by access_process_vm when get_user_pages() fails, typically
75334 * for use by special VMAs that can switch between memory and hardware
75335 */
75336 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75337 - void *buf, int len, int write);
75338 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75339 + void *buf, size_t len, int write);
75340 #ifdef CONFIG_NUMA
75341 /*
75342 * set_policy() op must add a reference to any non-NULL @new mempolicy
75343 @@ -239,6 +244,7 @@ struct vm_operations_struct {
75344 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75345 unsigned long size, pgoff_t pgoff);
75346 };
75347 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75348
75349 struct mmu_gather;
75350 struct inode;
75351 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75352 unsigned long *pfn);
75353 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75354 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75355 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75356 - void *buf, int len, int write);
75357 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75358 + void *buf, size_t len, int write);
75359
75360 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75361 loff_t const holebegin, loff_t const holelen)
75362 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75363 }
75364 #endif
75365
75366 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75367 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75368 - void *buf, int len, int write);
75369 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75370 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75371 + void *buf, size_t len, int write);
75372
75373 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75374 unsigned long start, unsigned long nr_pages,
75375 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75376 int set_page_dirty_lock(struct page *page);
75377 int clear_page_dirty_for_io(struct page *page);
75378
75379 -/* Is the vma a continuation of the stack vma above it? */
75380 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75381 -{
75382 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75383 -}
75384 -
75385 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75386 - unsigned long addr)
75387 -{
75388 - return (vma->vm_flags & VM_GROWSDOWN) &&
75389 - (vma->vm_start == addr) &&
75390 - !vma_growsdown(vma->vm_prev, addr);
75391 -}
75392 -
75393 -/* Is the vma a continuation of the stack vma below it? */
75394 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75395 -{
75396 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75397 -}
75398 -
75399 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75400 - unsigned long addr)
75401 -{
75402 - return (vma->vm_flags & VM_GROWSUP) &&
75403 - (vma->vm_end == addr) &&
75404 - !vma_growsup(vma->vm_next, addr);
75405 -}
75406 -
75407 extern pid_t
75408 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75409
75410 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75411 }
75412 #endif
75413
75414 +#ifdef CONFIG_MMU
75415 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75416 +#else
75417 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75418 +{
75419 + return __pgprot(0);
75420 +}
75421 +#endif
75422 +
75423 int vma_wants_writenotify(struct vm_area_struct *vma);
75424
75425 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75426 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75427 {
75428 return 0;
75429 }
75430 +
75431 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75432 + unsigned long address)
75433 +{
75434 + return 0;
75435 +}
75436 #else
75437 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75438 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75439 #endif
75440
75441 #ifdef __PAGETABLE_PMD_FOLDED
75442 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75443 {
75444 return 0;
75445 }
75446 +
75447 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75448 + unsigned long address)
75449 +{
75450 + return 0;
75451 +}
75452 #else
75453 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75454 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75455 #endif
75456
75457 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75458 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75459 NULL: pud_offset(pgd, address);
75460 }
75461
75462 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75463 +{
75464 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75465 + NULL: pud_offset(pgd, address);
75466 +}
75467 +
75468 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75469 {
75470 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75471 NULL: pmd_offset(pud, address);
75472 }
75473 +
75474 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75475 +{
75476 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75477 + NULL: pmd_offset(pud, address);
75478 +}
75479 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75480
75481 #if USE_SPLIT_PTLOCKS
75482 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75483 unsigned long len, unsigned long prot, unsigned long flags,
75484 unsigned long pgoff, unsigned long *populate);
75485 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75486 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75487
75488 #ifdef CONFIG_MMU
75489 extern int __mm_populate(unsigned long addr, unsigned long len,
75490 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75491 unsigned long high_limit;
75492 unsigned long align_mask;
75493 unsigned long align_offset;
75494 + unsigned long threadstack_offset;
75495 };
75496
75497 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75498 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75499 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75500 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75501
75502 /*
75503 * Search for an unmapped address range.
75504 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75505 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75506 */
75507 static inline unsigned long
75508 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75509 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75510 {
75511 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75512 return unmapped_area(info);
75513 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75514 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75515 struct vm_area_struct **pprev);
75516
75517 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75518 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75519 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75520 +
75521 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75522 NULL if none. Assume start_addr < end_addr. */
75523 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75524 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75525 return vma;
75526 }
75527
75528 -#ifdef CONFIG_MMU
75529 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75530 -#else
75531 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75532 -{
75533 - return __pgprot(0);
75534 -}
75535 -#endif
75536 -
75537 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75538 unsigned long change_prot_numa(struct vm_area_struct *vma,
75539 unsigned long start, unsigned long end);
75540 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75541 static inline void vm_stat_account(struct mm_struct *mm,
75542 unsigned long flags, struct file *file, long pages)
75543 {
75544 +
75545 +#ifdef CONFIG_PAX_RANDMMAP
75546 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75547 +#endif
75548 +
75549 mm->total_vm += pages;
75550 }
75551 #endif /* CONFIG_PROC_FS */
75552 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75553 extern int sysctl_memory_failure_early_kill;
75554 extern int sysctl_memory_failure_recovery;
75555 extern void shake_page(struct page *p, int access);
75556 -extern atomic_long_t num_poisoned_pages;
75557 +extern atomic_long_unchecked_t num_poisoned_pages;
75558 extern int soft_offline_page(struct page *page, int flags);
75559
75560 extern void dump_page(struct page *page);
75561 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75562 static inline void setup_nr_node_ids(void) {}
75563 #endif
75564
75565 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75566 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75567 +#else
75568 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75569 +#endif
75570 +
75571 #endif /* __KERNEL__ */
75572 #endif /* _LINUX_MM_H */
75573 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75574 index faf4b7c..1e70c6e 100644
75575 --- a/include/linux/mm_types.h
75576 +++ b/include/linux/mm_types.h
75577 @@ -289,6 +289,8 @@ struct vm_area_struct {
75578 #ifdef CONFIG_NUMA
75579 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75580 #endif
75581 +
75582 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75583 };
75584
75585 struct core_thread {
75586 @@ -435,6 +437,24 @@ struct mm_struct {
75587 int first_nid;
75588 #endif
75589 struct uprobes_state uprobes_state;
75590 +
75591 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75592 + unsigned long pax_flags;
75593 +#endif
75594 +
75595 +#ifdef CONFIG_PAX_DLRESOLVE
75596 + unsigned long call_dl_resolve;
75597 +#endif
75598 +
75599 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75600 + unsigned long call_syscall;
75601 +#endif
75602 +
75603 +#ifdef CONFIG_PAX_ASLR
75604 + unsigned long delta_mmap; /* randomized offset */
75605 + unsigned long delta_stack; /* randomized offset */
75606 +#endif
75607 +
75608 };
75609
75610 /* first nid will either be a valid NID or one of these values */
75611 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75612 index c5d5278..f0b68c8 100644
75613 --- a/include/linux/mmiotrace.h
75614 +++ b/include/linux/mmiotrace.h
75615 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75616 /* Called from ioremap.c */
75617 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75618 void __iomem *addr);
75619 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75620 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75621
75622 /* For anyone to insert markers. Remember trailing newline. */
75623 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75624 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75625 {
75626 }
75627
75628 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75629 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75630 {
75631 }
75632
75633 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75634 index af4a3b7..9ad8889 100644
75635 --- a/include/linux/mmzone.h
75636 +++ b/include/linux/mmzone.h
75637 @@ -396,7 +396,7 @@ struct zone {
75638 unsigned long flags; /* zone flags, see below */
75639
75640 /* Zone statistics */
75641 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75642 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75643
75644 /*
75645 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75646 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75647 index 45e9214..a7227d6 100644
75648 --- a/include/linux/mod_devicetable.h
75649 +++ b/include/linux/mod_devicetable.h
75650 @@ -13,7 +13,7 @@
75651 typedef unsigned long kernel_ulong_t;
75652 #endif
75653
75654 -#define PCI_ANY_ID (~0)
75655 +#define PCI_ANY_ID ((__u16)~0)
75656
75657 struct pci_device_id {
75658 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75659 @@ -139,7 +139,7 @@ struct usb_device_id {
75660 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75661 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75662
75663 -#define HID_ANY_ID (~0)
75664 +#define HID_ANY_ID (~0U)
75665 #define HID_BUS_ANY 0xffff
75666 #define HID_GROUP_ANY 0x0000
75667
75668 @@ -467,7 +467,7 @@ struct dmi_system_id {
75669 const char *ident;
75670 struct dmi_strmatch matches[4];
75671 void *driver_data;
75672 -};
75673 +} __do_const;
75674 /*
75675 * struct dmi_device_id appears during expansion of
75676 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75677 diff --git a/include/linux/module.h b/include/linux/module.h
75678 index 46f1ea0..a34ca37 100644
75679 --- a/include/linux/module.h
75680 +++ b/include/linux/module.h
75681 @@ -17,9 +17,11 @@
75682 #include <linux/moduleparam.h>
75683 #include <linux/tracepoint.h>
75684 #include <linux/export.h>
75685 +#include <linux/fs.h>
75686
75687 #include <linux/percpu.h>
75688 #include <asm/module.h>
75689 +#include <asm/pgtable.h>
75690
75691 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75692 #define MODULE_SIG_STRING "~Module signature appended~\n"
75693 @@ -54,12 +56,13 @@ struct module_attribute {
75694 int (*test)(struct module *);
75695 void (*free)(struct module *);
75696 };
75697 +typedef struct module_attribute __no_const module_attribute_no_const;
75698
75699 struct module_version_attribute {
75700 struct module_attribute mattr;
75701 const char *module_name;
75702 const char *version;
75703 -} __attribute__ ((__aligned__(sizeof(void *))));
75704 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75705
75706 extern ssize_t __modver_version_show(struct module_attribute *,
75707 struct module_kobject *, char *);
75708 @@ -232,7 +235,7 @@ struct module
75709
75710 /* Sysfs stuff. */
75711 struct module_kobject mkobj;
75712 - struct module_attribute *modinfo_attrs;
75713 + module_attribute_no_const *modinfo_attrs;
75714 const char *version;
75715 const char *srcversion;
75716 struct kobject *holders_dir;
75717 @@ -281,19 +284,16 @@ struct module
75718 int (*init)(void);
75719
75720 /* If this is non-NULL, vfree after init() returns */
75721 - void *module_init;
75722 + void *module_init_rx, *module_init_rw;
75723
75724 /* Here is the actual code + data, vfree'd on unload. */
75725 - void *module_core;
75726 + void *module_core_rx, *module_core_rw;
75727
75728 /* Here are the sizes of the init and core sections */
75729 - unsigned int init_size, core_size;
75730 + unsigned int init_size_rw, core_size_rw;
75731
75732 /* The size of the executable code in each section. */
75733 - unsigned int init_text_size, core_text_size;
75734 -
75735 - /* Size of RO sections of the module (text+rodata) */
75736 - unsigned int init_ro_size, core_ro_size;
75737 + unsigned int init_size_rx, core_size_rx;
75738
75739 /* Arch-specific module values */
75740 struct mod_arch_specific arch;
75741 @@ -349,6 +349,10 @@ struct module
75742 #ifdef CONFIG_EVENT_TRACING
75743 struct ftrace_event_call **trace_events;
75744 unsigned int num_trace_events;
75745 + struct file_operations trace_id;
75746 + struct file_operations trace_enable;
75747 + struct file_operations trace_format;
75748 + struct file_operations trace_filter;
75749 #endif
75750 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75751 unsigned int num_ftrace_callsites;
75752 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75753 bool is_module_percpu_address(unsigned long addr);
75754 bool is_module_text_address(unsigned long addr);
75755
75756 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75757 +{
75758 +
75759 +#ifdef CONFIG_PAX_KERNEXEC
75760 + if (ktla_ktva(addr) >= (unsigned long)start &&
75761 + ktla_ktva(addr) < (unsigned long)start + size)
75762 + return 1;
75763 +#endif
75764 +
75765 + return ((void *)addr >= start && (void *)addr < start + size);
75766 +}
75767 +
75768 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75769 +{
75770 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75771 +}
75772 +
75773 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75774 +{
75775 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75776 +}
75777 +
75778 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75779 +{
75780 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75781 +}
75782 +
75783 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75784 +{
75785 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75786 +}
75787 +
75788 static inline int within_module_core(unsigned long addr, const struct module *mod)
75789 {
75790 - return (unsigned long)mod->module_core <= addr &&
75791 - addr < (unsigned long)mod->module_core + mod->core_size;
75792 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75793 }
75794
75795 static inline int within_module_init(unsigned long addr, const struct module *mod)
75796 {
75797 - return (unsigned long)mod->module_init <= addr &&
75798 - addr < (unsigned long)mod->module_init + mod->init_size;
75799 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75800 }
75801
75802 /* Search for module by name: must hold module_mutex. */
75803 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75804 index 560ca53..ef621ef 100644
75805 --- a/include/linux/moduleloader.h
75806 +++ b/include/linux/moduleloader.h
75807 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75808 sections. Returns NULL on failure. */
75809 void *module_alloc(unsigned long size);
75810
75811 +#ifdef CONFIG_PAX_KERNEXEC
75812 +void *module_alloc_exec(unsigned long size);
75813 +#else
75814 +#define module_alloc_exec(x) module_alloc(x)
75815 +#endif
75816 +
75817 /* Free memory returned from module_alloc. */
75818 void module_free(struct module *mod, void *module_region);
75819
75820 +#ifdef CONFIG_PAX_KERNEXEC
75821 +void module_free_exec(struct module *mod, void *module_region);
75822 +#else
75823 +#define module_free_exec(x, y) module_free((x), (y))
75824 +#endif
75825 +
75826 /*
75827 * Apply the given relocation to the (simplified) ELF. Return -error
75828 * or 0.
75829 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75830 unsigned int relsec,
75831 struct module *me)
75832 {
75833 +#ifdef CONFIG_MODULES
75834 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75835 +#endif
75836 return -ENOEXEC;
75837 }
75838 #endif
75839 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75840 unsigned int relsec,
75841 struct module *me)
75842 {
75843 +#ifdef CONFIG_MODULES
75844 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75845 +#endif
75846 return -ENOEXEC;
75847 }
75848 #endif
75849 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75850 index 27d9da3..5d94aa3 100644
75851 --- a/include/linux/moduleparam.h
75852 +++ b/include/linux/moduleparam.h
75853 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75854 * @len is usually just sizeof(string).
75855 */
75856 #define module_param_string(name, string, len, perm) \
75857 - static const struct kparam_string __param_string_##name \
75858 + static const struct kparam_string __param_string_##name __used \
75859 = { len, string }; \
75860 __module_param_call(MODULE_PARAM_PREFIX, name, \
75861 &param_ops_string, \
75862 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75863 */
75864 #define module_param_array_named(name, array, type, nump, perm) \
75865 param_check_##type(name, &(array)[0]); \
75866 - static const struct kparam_array __param_arr_##name \
75867 + static const struct kparam_array __param_arr_##name __used \
75868 = { .max = ARRAY_SIZE(array), .num = nump, \
75869 .ops = &param_ops_##type, \
75870 .elemsize = sizeof(array[0]), .elem = array }; \
75871 diff --git a/include/linux/namei.h b/include/linux/namei.h
75872 index 5a5ff57..5ae5070 100644
75873 --- a/include/linux/namei.h
75874 +++ b/include/linux/namei.h
75875 @@ -19,7 +19,7 @@ struct nameidata {
75876 unsigned seq;
75877 int last_type;
75878 unsigned depth;
75879 - char *saved_names[MAX_NESTED_LINKS + 1];
75880 + const char *saved_names[MAX_NESTED_LINKS + 1];
75881 };
75882
75883 /*
75884 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75885
75886 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75887
75888 -static inline void nd_set_link(struct nameidata *nd, char *path)
75889 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75890 {
75891 nd->saved_names[nd->depth] = path;
75892 }
75893
75894 -static inline char *nd_get_link(struct nameidata *nd)
75895 +static inline const char *nd_get_link(const struct nameidata *nd)
75896 {
75897 return nd->saved_names[nd->depth];
75898 }
75899 diff --git a/include/linux/net.h b/include/linux/net.h
75900 index 4f27575..fc8a65f 100644
75901 --- a/include/linux/net.h
75902 +++ b/include/linux/net.h
75903 @@ -183,7 +183,7 @@ struct net_proto_family {
75904 int (*create)(struct net *net, struct socket *sock,
75905 int protocol, int kern);
75906 struct module *owner;
75907 -};
75908 +} __do_const;
75909
75910 struct iovec;
75911 struct kvec;
75912 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75913 index 9a41568..203d903 100644
75914 --- a/include/linux/netdevice.h
75915 +++ b/include/linux/netdevice.h
75916 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75917 int (*ndo_change_carrier)(struct net_device *dev,
75918 bool new_carrier);
75919 };
75920 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75921
75922 /*
75923 * The DEVICE structure.
75924 @@ -1131,7 +1132,7 @@ struct net_device {
75925 int iflink;
75926
75927 struct net_device_stats stats;
75928 - atomic_long_t rx_dropped; /* dropped packets by core network
75929 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75930 * Do not use this in drivers.
75931 */
75932
75933 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75934 index de70f7b..2675e91 100644
75935 --- a/include/linux/netfilter.h
75936 +++ b/include/linux/netfilter.h
75937 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75938 #endif
75939 /* Use the module struct to lock set/get code in place */
75940 struct module *owner;
75941 -};
75942 +} __do_const;
75943
75944 /* Function to register/unregister hook points. */
75945 int nf_register_hook(struct nf_hook_ops *reg);
75946 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75947 index d80e275..c3510b8 100644
75948 --- a/include/linux/netfilter/ipset/ip_set.h
75949 +++ b/include/linux/netfilter/ipset/ip_set.h
75950 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75951 /* Return true if "b" set is the same as "a"
75952 * according to the create set parameters */
75953 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75954 -};
75955 +} __do_const;
75956
75957 /* The core set type structure */
75958 struct ip_set_type {
75959 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75960 index cadb740..d7c37c0 100644
75961 --- a/include/linux/netfilter/nfnetlink.h
75962 +++ b/include/linux/netfilter/nfnetlink.h
75963 @@ -16,7 +16,7 @@ struct nfnl_callback {
75964 const struct nlattr * const cda[]);
75965 const struct nla_policy *policy; /* netlink attribute policy */
75966 const u_int16_t attr_count; /* number of nlattr's */
75967 -};
75968 +} __do_const;
75969
75970 struct nfnetlink_subsystem {
75971 const char *name;
75972 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75973 new file mode 100644
75974 index 0000000..33f4af8
75975 --- /dev/null
75976 +++ b/include/linux/netfilter/xt_gradm.h
75977 @@ -0,0 +1,9 @@
75978 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75979 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75980 +
75981 +struct xt_gradm_mtinfo {
75982 + __u16 flags;
75983 + __u16 invflags;
75984 +};
75985 +
75986 +#endif
75987 diff --git a/include/linux/nls.h b/include/linux/nls.h
75988 index 5dc635f..35f5e11 100644
75989 --- a/include/linux/nls.h
75990 +++ b/include/linux/nls.h
75991 @@ -31,7 +31,7 @@ struct nls_table {
75992 const unsigned char *charset2upper;
75993 struct module *owner;
75994 struct nls_table *next;
75995 -};
75996 +} __do_const;
75997
75998 /* this value hold the maximum octet of charset */
75999 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
76000 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
76001 index d14a4c3..a078786 100644
76002 --- a/include/linux/notifier.h
76003 +++ b/include/linux/notifier.h
76004 @@ -54,7 +54,8 @@ struct notifier_block {
76005 notifier_fn_t notifier_call;
76006 struct notifier_block __rcu *next;
76007 int priority;
76008 -};
76009 +} __do_const;
76010 +typedef struct notifier_block __no_const notifier_block_no_const;
76011
76012 struct atomic_notifier_head {
76013 spinlock_t lock;
76014 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
76015 index a4c5624..79d6d88 100644
76016 --- a/include/linux/oprofile.h
76017 +++ b/include/linux/oprofile.h
76018 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
76019 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
76020 char const * name, ulong * val);
76021
76022 -/** Create a file for read-only access to an atomic_t. */
76023 +/** Create a file for read-only access to an atomic_unchecked_t. */
76024 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
76025 - char const * name, atomic_t * val);
76026 + char const * name, atomic_unchecked_t * val);
76027
76028 /** create a directory */
76029 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
76030 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
76031 index 8db71dc..a76bf2c 100644
76032 --- a/include/linux/pci_hotplug.h
76033 +++ b/include/linux/pci_hotplug.h
76034 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
76035 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
76036 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
76037 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
76038 -};
76039 +} __do_const;
76040 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
76041
76042 /**
76043 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
76044 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
76045 index c43f6ea..2d4416f 100644
76046 --- a/include/linux/perf_event.h
76047 +++ b/include/linux/perf_event.h
76048 @@ -328,8 +328,8 @@ struct perf_event {
76049
76050 enum perf_event_active_state state;
76051 unsigned int attach_state;
76052 - local64_t count;
76053 - atomic64_t child_count;
76054 + local64_t count; /* PaX: fix it one day */
76055 + atomic64_unchecked_t child_count;
76056
76057 /*
76058 * These are the total time in nanoseconds that the event
76059 @@ -380,8 +380,8 @@ struct perf_event {
76060 * These accumulate total time (in nanoseconds) that children
76061 * events have been enabled and running, respectively.
76062 */
76063 - atomic64_t child_total_time_enabled;
76064 - atomic64_t child_total_time_running;
76065 + atomic64_unchecked_t child_total_time_enabled;
76066 + atomic64_unchecked_t child_total_time_running;
76067
76068 /*
76069 * Protect attach/detach and child_list:
76070 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
76071 entry->ip[entry->nr++] = ip;
76072 }
76073
76074 -extern int sysctl_perf_event_paranoid;
76075 +extern int sysctl_perf_event_legitimately_concerned;
76076 extern int sysctl_perf_event_mlock;
76077 extern int sysctl_perf_event_sample_rate;
76078 extern int sysctl_perf_cpu_time_max_percent;
76079 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
76080 loff_t *ppos);
76081
76082
76083 +static inline bool perf_paranoid_any(void)
76084 +{
76085 + return sysctl_perf_event_legitimately_concerned > 2;
76086 +}
76087 +
76088 static inline bool perf_paranoid_tracepoint_raw(void)
76089 {
76090 - return sysctl_perf_event_paranoid > -1;
76091 + return sysctl_perf_event_legitimately_concerned > -1;
76092 }
76093
76094 static inline bool perf_paranoid_cpu(void)
76095 {
76096 - return sysctl_perf_event_paranoid > 0;
76097 + return sysctl_perf_event_legitimately_concerned > 0;
76098 }
76099
76100 static inline bool perf_paranoid_kernel(void)
76101 {
76102 - return sysctl_perf_event_paranoid > 1;
76103 + return sysctl_perf_event_legitimately_concerned > 1;
76104 }
76105
76106 extern void perf_event_init(void);
76107 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
76108 struct device_attribute attr;
76109 u64 id;
76110 const char *event_str;
76111 -};
76112 +} __do_const;
76113
76114 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
76115 static struct perf_pmu_events_attr _var = { \
76116 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
76117 index b8809fe..ae4ccd0 100644
76118 --- a/include/linux/pipe_fs_i.h
76119 +++ b/include/linux/pipe_fs_i.h
76120 @@ -47,10 +47,10 @@ struct pipe_inode_info {
76121 struct mutex mutex;
76122 wait_queue_head_t wait;
76123 unsigned int nrbufs, curbuf, buffers;
76124 - unsigned int readers;
76125 - unsigned int writers;
76126 - unsigned int files;
76127 - unsigned int waiting_writers;
76128 + atomic_t readers;
76129 + atomic_t writers;
76130 + atomic_t files;
76131 + atomic_t waiting_writers;
76132 unsigned int r_counter;
76133 unsigned int w_counter;
76134 struct page *tmp_page;
76135 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
76136 index 5f28cae..3d23723 100644
76137 --- a/include/linux/platform_data/usb-ehci-s5p.h
76138 +++ b/include/linux/platform_data/usb-ehci-s5p.h
76139 @@ -14,7 +14,7 @@
76140 struct s5p_ehci_platdata {
76141 int (*phy_init)(struct platform_device *pdev, int type);
76142 int (*phy_exit)(struct platform_device *pdev, int type);
76143 -};
76144 +} __no_const;
76145
76146 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
76147
76148 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
76149 index c256c59..8ea94c7 100644
76150 --- a/include/linux/platform_data/usb-ohci-exynos.h
76151 +++ b/include/linux/platform_data/usb-ohci-exynos.h
76152 @@ -14,7 +14,7 @@
76153 struct exynos4_ohci_platdata {
76154 int (*phy_init)(struct platform_device *pdev, int type);
76155 int (*phy_exit)(struct platform_device *pdev, int type);
76156 -};
76157 +} __no_const;
76158
76159 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
76160
76161 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
76162 index 7c1d252..c5c773e 100644
76163 --- a/include/linux/pm_domain.h
76164 +++ b/include/linux/pm_domain.h
76165 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
76166
76167 struct gpd_cpu_data {
76168 unsigned int saved_exit_latency;
76169 - struct cpuidle_state *idle_state;
76170 + cpuidle_state_no_const *idle_state;
76171 };
76172
76173 struct generic_pm_domain {
76174 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
76175 index 6fa7cea..7bf6415 100644
76176 --- a/include/linux/pm_runtime.h
76177 +++ b/include/linux/pm_runtime.h
76178 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
76179
76180 static inline void pm_runtime_mark_last_busy(struct device *dev)
76181 {
76182 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
76183 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
76184 }
76185
76186 #else /* !CONFIG_PM_RUNTIME */
76187 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
76188 index 195aafc..49a7bc2 100644
76189 --- a/include/linux/pnp.h
76190 +++ b/include/linux/pnp.h
76191 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
76192 struct pnp_fixup {
76193 char id[7];
76194 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
76195 -};
76196 +} __do_const;
76197
76198 /* config parameters */
76199 #define PNP_CONFIG_NORMAL 0x0001
76200 diff --git a/include/linux/poison.h b/include/linux/poison.h
76201 index 2110a81..13a11bb 100644
76202 --- a/include/linux/poison.h
76203 +++ b/include/linux/poison.h
76204 @@ -19,8 +19,8 @@
76205 * under normal circumstances, used to verify that nobody uses
76206 * non-initialized list entries.
76207 */
76208 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
76209 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
76210 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
76211 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
76212
76213 /********** include/linux/timer.h **********/
76214 /*
76215 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
76216 index d8b187c3..9a9257a 100644
76217 --- a/include/linux/power/smartreflex.h
76218 +++ b/include/linux/power/smartreflex.h
76219 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
76220 int (*notify)(struct omap_sr *sr, u32 status);
76221 u8 notify_flags;
76222 u8 class_type;
76223 -};
76224 +} __do_const;
76225
76226 /**
76227 * struct omap_sr_nvalue_table - Smartreflex n-target value info
76228 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
76229 index 4ea1d37..80f4b33 100644
76230 --- a/include/linux/ppp-comp.h
76231 +++ b/include/linux/ppp-comp.h
76232 @@ -84,7 +84,7 @@ struct compressor {
76233 struct module *owner;
76234 /* Extra skb space needed by the compressor algorithm */
76235 unsigned int comp_extra;
76236 -};
76237 +} __do_const;
76238
76239 /*
76240 * The return value from decompress routine is the length of the
76241 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
76242 index f5d4723..a6ea2fa 100644
76243 --- a/include/linux/preempt.h
76244 +++ b/include/linux/preempt.h
76245 @@ -18,8 +18,13 @@
76246 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76247 #endif
76248
76249 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
76250 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76251 +
76252 #define inc_preempt_count() add_preempt_count(1)
76253 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
76254 #define dec_preempt_count() sub_preempt_count(1)
76255 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
76256
76257 #define preempt_count() (current_thread_info()->preempt_count)
76258
76259 @@ -64,6 +69,12 @@ do { \
76260 barrier(); \
76261 } while (0)
76262
76263 +#define raw_preempt_disable() \
76264 +do { \
76265 + raw_inc_preempt_count(); \
76266 + barrier(); \
76267 +} while (0)
76268 +
76269 #define sched_preempt_enable_no_resched() \
76270 do { \
76271 barrier(); \
76272 @@ -72,6 +83,12 @@ do { \
76273
76274 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
76275
76276 +#define raw_preempt_enable_no_resched() \
76277 +do { \
76278 + barrier(); \
76279 + raw_dec_preempt_count(); \
76280 +} while (0)
76281 +
76282 #define preempt_enable() \
76283 do { \
76284 preempt_enable_no_resched(); \
76285 @@ -116,8 +133,10 @@ do { \
76286 * region.
76287 */
76288 #define preempt_disable() barrier()
76289 +#define raw_preempt_disable() barrier()
76290 #define sched_preempt_enable_no_resched() barrier()
76291 #define preempt_enable_no_resched() barrier()
76292 +#define raw_preempt_enable_no_resched() barrier()
76293 #define preempt_enable() barrier()
76294
76295 #define preempt_disable_notrace() barrier()
76296 diff --git a/include/linux/printk.h b/include/linux/printk.h
76297 index 22c7052..ad3fa0a 100644
76298 --- a/include/linux/printk.h
76299 +++ b/include/linux/printk.h
76300 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
76301 void early_printk(const char *s, ...) { }
76302 #endif
76303
76304 +extern int kptr_restrict;
76305 +
76306 #ifdef CONFIG_PRINTK
76307 asmlinkage __printf(5, 0)
76308 int vprintk_emit(int facility, int level,
76309 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76310
76311 extern int printk_delay_msec;
76312 extern int dmesg_restrict;
76313 -extern int kptr_restrict;
76314
76315 extern void wake_up_klogd(void);
76316
76317 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76318 index 608e60a..c26f864 100644
76319 --- a/include/linux/proc_fs.h
76320 +++ b/include/linux/proc_fs.h
76321 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76322 return proc_create_data(name, mode, parent, proc_fops, NULL);
76323 }
76324
76325 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76326 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76327 +{
76328 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76329 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76330 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76331 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76332 +#else
76333 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76334 +#endif
76335 +}
76336 +
76337 +
76338 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76339 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76340 extern void *PDE_DATA(const struct inode *);
76341 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76342 index 34a1e10..03a6d03 100644
76343 --- a/include/linux/proc_ns.h
76344 +++ b/include/linux/proc_ns.h
76345 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76346 void (*put)(void *ns);
76347 int (*install)(struct nsproxy *nsproxy, void *ns);
76348 unsigned int (*inum)(void *ns);
76349 -};
76350 +} __do_const;
76351
76352 struct proc_ns {
76353 void *ns;
76354 diff --git a/include/linux/random.h b/include/linux/random.h
76355 index 6312dd9..2561947 100644
76356 --- a/include/linux/random.h
76357 +++ b/include/linux/random.h
76358 @@ -10,9 +10,19 @@
76359
76360
76361 extern void add_device_randomness(const void *, unsigned int);
76362 +
76363 +static inline void add_latent_entropy(void)
76364 +{
76365 +
76366 +#ifdef LATENT_ENTROPY_PLUGIN
76367 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76368 +#endif
76369 +
76370 +}
76371 +
76372 extern void add_input_randomness(unsigned int type, unsigned int code,
76373 - unsigned int value);
76374 -extern void add_interrupt_randomness(int irq, int irq_flags);
76375 + unsigned int value) __latent_entropy;
76376 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
76377
76378 extern void get_random_bytes(void *buf, int nbytes);
76379 extern void get_random_bytes_arch(void *buf, int nbytes);
76380 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
76381 u32 prandom_u32_state(struct rnd_state *);
76382 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76383
76384 +static inline unsigned long pax_get_random_long(void)
76385 +{
76386 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76387 +}
76388 +
76389 /*
76390 * Handle minimum values for seeds
76391 */
76392 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76393 index 4106721..132d42c 100644
76394 --- a/include/linux/rculist.h
76395 +++ b/include/linux/rculist.h
76396 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76397 struct list_head *prev, struct list_head *next);
76398 #endif
76399
76400 +extern void __pax_list_add_rcu(struct list_head *new,
76401 + struct list_head *prev, struct list_head *next);
76402 +
76403 /**
76404 * list_add_rcu - add a new entry to rcu-protected list
76405 * @new: new entry to be added
76406 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76407 __list_add_rcu(new, head, head->next);
76408 }
76409
76410 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76411 +{
76412 + __pax_list_add_rcu(new, head, head->next);
76413 +}
76414 +
76415 /**
76416 * list_add_tail_rcu - add a new entry to rcu-protected list
76417 * @new: new entry to be added
76418 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76419 __list_add_rcu(new, head->prev, head);
76420 }
76421
76422 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76423 + struct list_head *head)
76424 +{
76425 + __pax_list_add_rcu(new, head->prev, head);
76426 +}
76427 +
76428 /**
76429 * list_del_rcu - deletes entry from list without re-initialization
76430 * @entry: the element to delete from the list.
76431 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76432 entry->prev = LIST_POISON2;
76433 }
76434
76435 +extern void pax_list_del_rcu(struct list_head *entry);
76436 +
76437 /**
76438 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76439 * @n: the element to delete from the hash list.
76440 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76441 index 8e00f9f..9449b55 100644
76442 --- a/include/linux/reboot.h
76443 +++ b/include/linux/reboot.h
76444 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76445 * Architecture-specific implementations of sys_reboot commands.
76446 */
76447
76448 -extern void machine_restart(char *cmd);
76449 -extern void machine_halt(void);
76450 -extern void machine_power_off(void);
76451 +extern void machine_restart(char *cmd) __noreturn;
76452 +extern void machine_halt(void) __noreturn;
76453 +extern void machine_power_off(void) __noreturn;
76454
76455 extern void machine_shutdown(void);
76456 struct pt_regs;
76457 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76458 */
76459
76460 extern void kernel_restart_prepare(char *cmd);
76461 -extern void kernel_restart(char *cmd);
76462 -extern void kernel_halt(void);
76463 -extern void kernel_power_off(void);
76464 +extern void kernel_restart(char *cmd) __noreturn;
76465 +extern void kernel_halt(void) __noreturn;
76466 +extern void kernel_power_off(void) __noreturn;
76467
76468 extern int C_A_D; /* for sysctl */
76469 void ctrl_alt_del(void);
76470 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76471 * Emergency restart, callable from an interrupt handler.
76472 */
76473
76474 -extern void emergency_restart(void);
76475 +extern void emergency_restart(void) __noreturn;
76476 #include <asm/emergency-restart.h>
76477
76478 #endif /* _LINUX_REBOOT_H */
76479 diff --git a/include/linux/regset.h b/include/linux/regset.h
76480 index 8e0c9fe..ac4d221 100644
76481 --- a/include/linux/regset.h
76482 +++ b/include/linux/regset.h
76483 @@ -161,7 +161,8 @@ struct user_regset {
76484 unsigned int align;
76485 unsigned int bias;
76486 unsigned int core_note_type;
76487 -};
76488 +} __do_const;
76489 +typedef struct user_regset __no_const user_regset_no_const;
76490
76491 /**
76492 * struct user_regset_view - available regsets
76493 diff --git a/include/linux/relay.h b/include/linux/relay.h
76494 index d7c8359..818daf5 100644
76495 --- a/include/linux/relay.h
76496 +++ b/include/linux/relay.h
76497 @@ -157,7 +157,7 @@ struct rchan_callbacks
76498 * The callback should return 0 if successful, negative if not.
76499 */
76500 int (*remove_buf_file)(struct dentry *dentry);
76501 -};
76502 +} __no_const;
76503
76504 /*
76505 * CONFIG_RELAY kernel API, kernel/relay.c
76506 diff --git a/include/linux/rio.h b/include/linux/rio.h
76507 index b71d573..2f940bd 100644
76508 --- a/include/linux/rio.h
76509 +++ b/include/linux/rio.h
76510 @@ -355,7 +355,7 @@ struct rio_ops {
76511 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76512 u64 rstart, u32 size, u32 flags);
76513 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76514 -};
76515 +} __no_const;
76516
76517 #define RIO_RESOURCE_MEM 0x00000100
76518 #define RIO_RESOURCE_DOORBELL 0x00000200
76519 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76520 index 6dacb93..6174423 100644
76521 --- a/include/linux/rmap.h
76522 +++ b/include/linux/rmap.h
76523 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76524 void anon_vma_init(void); /* create anon_vma_cachep */
76525 int anon_vma_prepare(struct vm_area_struct *);
76526 void unlink_anon_vmas(struct vm_area_struct *);
76527 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76528 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76529 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76530 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76531
76532 static inline void anon_vma_merge(struct vm_area_struct *vma,
76533 struct vm_area_struct *next)
76534 diff --git a/include/linux/sched.h b/include/linux/sched.h
76535 index 078066d..d09659d 100644
76536 --- a/include/linux/sched.h
76537 +++ b/include/linux/sched.h
76538 @@ -62,6 +62,7 @@ struct bio_list;
76539 struct fs_struct;
76540 struct perf_event_context;
76541 struct blk_plug;
76542 +struct linux_binprm;
76543
76544 /*
76545 * List of flags we want to share for kernel threads,
76546 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76547 extern int in_sched_functions(unsigned long addr);
76548
76549 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76550 -extern signed long schedule_timeout(signed long timeout);
76551 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76552 extern signed long schedule_timeout_interruptible(signed long timeout);
76553 extern signed long schedule_timeout_killable(signed long timeout);
76554 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76555 @@ -314,6 +315,19 @@ struct nsproxy;
76556 struct user_namespace;
76557
76558 #ifdef CONFIG_MMU
76559 +
76560 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76561 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76562 +#else
76563 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76564 +{
76565 + return 0;
76566 +}
76567 +#endif
76568 +
76569 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76570 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76571 +
76572 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76573 extern unsigned long
76574 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76575 @@ -589,6 +603,17 @@ struct signal_struct {
76576 #ifdef CONFIG_TASKSTATS
76577 struct taskstats *stats;
76578 #endif
76579 +
76580 +#ifdef CONFIG_GRKERNSEC
76581 + u32 curr_ip;
76582 + u32 saved_ip;
76583 + u32 gr_saddr;
76584 + u32 gr_daddr;
76585 + u16 gr_sport;
76586 + u16 gr_dport;
76587 + u8 used_accept:1;
76588 +#endif
76589 +
76590 #ifdef CONFIG_AUDIT
76591 unsigned audit_tty;
76592 unsigned audit_tty_log_passwd;
76593 @@ -669,6 +694,14 @@ struct user_struct {
76594 struct key *session_keyring; /* UID's default session keyring */
76595 #endif
76596
76597 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76598 + unsigned char kernel_banned;
76599 +#endif
76600 +#ifdef CONFIG_GRKERNSEC_BRUTE
76601 + unsigned char suid_banned;
76602 + unsigned long suid_ban_expires;
76603 +#endif
76604 +
76605 /* Hash table maintenance information */
76606 struct hlist_node uidhash_node;
76607 kuid_t uid;
76608 @@ -1151,8 +1184,8 @@ struct task_struct {
76609 struct list_head thread_group;
76610
76611 struct completion *vfork_done; /* for vfork() */
76612 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76613 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76614 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76615 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76616
76617 cputime_t utime, stime, utimescaled, stimescaled;
76618 cputime_t gtime;
76619 @@ -1177,11 +1210,6 @@ struct task_struct {
76620 struct task_cputime cputime_expires;
76621 struct list_head cpu_timers[3];
76622
76623 -/* process credentials */
76624 - const struct cred __rcu *real_cred; /* objective and real subjective task
76625 - * credentials (COW) */
76626 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76627 - * credentials (COW) */
76628 char comm[TASK_COMM_LEN]; /* executable name excluding path
76629 - access with [gs]et_task_comm (which lock
76630 it with task_lock())
76631 @@ -1198,6 +1226,10 @@ struct task_struct {
76632 #endif
76633 /* CPU-specific state of this task */
76634 struct thread_struct thread;
76635 +/* thread_info moved to task_struct */
76636 +#ifdef CONFIG_X86
76637 + struct thread_info tinfo;
76638 +#endif
76639 /* filesystem information */
76640 struct fs_struct *fs;
76641 /* open file information */
76642 @@ -1271,6 +1303,10 @@ struct task_struct {
76643 gfp_t lockdep_reclaim_gfp;
76644 #endif
76645
76646 +/* process credentials */
76647 + const struct cred __rcu *real_cred; /* objective and real subjective task
76648 + * credentials (COW) */
76649 +
76650 /* journalling filesystem info */
76651 void *journal_info;
76652
76653 @@ -1309,6 +1345,10 @@ struct task_struct {
76654 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76655 struct list_head cg_list;
76656 #endif
76657 +
76658 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76659 + * credentials (COW) */
76660 +
76661 #ifdef CONFIG_FUTEX
76662 struct robust_list_head __user *robust_list;
76663 #ifdef CONFIG_COMPAT
76664 @@ -1406,8 +1446,78 @@ struct task_struct {
76665 unsigned int sequential_io;
76666 unsigned int sequential_io_avg;
76667 #endif
76668 +
76669 +#ifdef CONFIG_GRKERNSEC
76670 + /* grsecurity */
76671 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76672 + u64 exec_id;
76673 +#endif
76674 +#ifdef CONFIG_GRKERNSEC_SETXID
76675 + const struct cred *delayed_cred;
76676 +#endif
76677 + struct dentry *gr_chroot_dentry;
76678 + struct acl_subject_label *acl;
76679 + struct acl_subject_label *tmpacl;
76680 + struct acl_role_label *role;
76681 + struct file *exec_file;
76682 + unsigned long brute_expires;
76683 + u16 acl_role_id;
76684 + u8 inherited;
76685 + /* is this the task that authenticated to the special role */
76686 + u8 acl_sp_role;
76687 + u8 is_writable;
76688 + u8 brute;
76689 + u8 gr_is_chrooted;
76690 +#endif
76691 +
76692 };
76693
76694 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76695 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76696 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76697 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76698 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76699 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76700 +
76701 +#ifdef CONFIG_PAX_SOFTMODE
76702 +extern int pax_softmode;
76703 +#endif
76704 +
76705 +extern int pax_check_flags(unsigned long *);
76706 +
76707 +/* if tsk != current then task_lock must be held on it */
76708 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76709 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76710 +{
76711 + if (likely(tsk->mm))
76712 + return tsk->mm->pax_flags;
76713 + else
76714 + return 0UL;
76715 +}
76716 +
76717 +/* if tsk != current then task_lock must be held on it */
76718 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76719 +{
76720 + if (likely(tsk->mm)) {
76721 + tsk->mm->pax_flags = flags;
76722 + return 0;
76723 + }
76724 + return -EINVAL;
76725 +}
76726 +#endif
76727 +
76728 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76729 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76730 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76731 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76732 +#endif
76733 +
76734 +struct path;
76735 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76736 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76737 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76738 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76739 +
76740 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76741 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76742
76743 @@ -1466,7 +1576,7 @@ struct pid_namespace;
76744 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76745 struct pid_namespace *ns);
76746
76747 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76748 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76749 {
76750 return tsk->pid;
76751 }
76752 @@ -1916,7 +2026,9 @@ void yield(void);
76753 extern struct exec_domain default_exec_domain;
76754
76755 union thread_union {
76756 +#ifndef CONFIG_X86
76757 struct thread_info thread_info;
76758 +#endif
76759 unsigned long stack[THREAD_SIZE/sizeof(long)];
76760 };
76761
76762 @@ -1949,6 +2061,7 @@ extern struct pid_namespace init_pid_ns;
76763 */
76764
76765 extern struct task_struct *find_task_by_vpid(pid_t nr);
76766 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76767 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76768 struct pid_namespace *ns);
76769
76770 @@ -2113,7 +2226,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76771 extern void exit_itimers(struct signal_struct *);
76772 extern void flush_itimer_signals(void);
76773
76774 -extern void do_group_exit(int);
76775 +extern __noreturn void do_group_exit(int);
76776
76777 extern int allow_signal(int);
76778 extern int disallow_signal(int);
76779 @@ -2304,9 +2417,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76780
76781 #endif
76782
76783 -static inline int object_is_on_stack(void *obj)
76784 +static inline int object_starts_on_stack(void *obj)
76785 {
76786 - void *stack = task_stack_page(current);
76787 + const void *stack = task_stack_page(current);
76788
76789 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76790 }
76791 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76792 index bf8086b..962b035 100644
76793 --- a/include/linux/sched/sysctl.h
76794 +++ b/include/linux/sched/sysctl.h
76795 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76796 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76797
76798 extern int sysctl_max_map_count;
76799 +extern unsigned long sysctl_heap_stack_gap;
76800
76801 extern unsigned int sysctl_sched_latency;
76802 extern unsigned int sysctl_sched_min_granularity;
76803 diff --git a/include/linux/security.h b/include/linux/security.h
76804 index 7ce53ae..8ee24a5 100644
76805 --- a/include/linux/security.h
76806 +++ b/include/linux/security.h
76807 @@ -27,6 +27,7 @@
76808 #include <linux/slab.h>
76809 #include <linux/err.h>
76810 #include <linux/string.h>
76811 +#include <linux/grsecurity.h>
76812
76813 struct linux_binprm;
76814 struct cred;
76815 @@ -116,8 +117,6 @@ struct seq_file;
76816
76817 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76818
76819 -void reset_security_ops(void);
76820 -
76821 #ifdef CONFIG_MMU
76822 extern unsigned long mmap_min_addr;
76823 extern unsigned long dac_mmap_min_addr;
76824 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76825 index 4e32edc..f8f2d18 100644
76826 --- a/include/linux/seq_file.h
76827 +++ b/include/linux/seq_file.h
76828 @@ -26,6 +26,9 @@ struct seq_file {
76829 struct mutex lock;
76830 const struct seq_operations *op;
76831 int poll_event;
76832 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76833 + u64 exec_id;
76834 +#endif
76835 #ifdef CONFIG_USER_NS
76836 struct user_namespace *user_ns;
76837 #endif
76838 @@ -38,6 +41,7 @@ struct seq_operations {
76839 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76840 int (*show) (struct seq_file *m, void *v);
76841 };
76842 +typedef struct seq_operations __no_const seq_operations_no_const;
76843
76844 #define SEQ_SKIP 1
76845
76846 diff --git a/include/linux/shm.h b/include/linux/shm.h
76847 index 429c199..4d42e38 100644
76848 --- a/include/linux/shm.h
76849 +++ b/include/linux/shm.h
76850 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76851
76852 /* The task created the shm object. NULL if the task is dead. */
76853 struct task_struct *shm_creator;
76854 +#ifdef CONFIG_GRKERNSEC
76855 + time_t shm_createtime;
76856 + pid_t shm_lapid;
76857 +#endif
76858 };
76859
76860 /* shm_mode upper byte flags */
76861 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76862 index 6bd165b..4823435 100644
76863 --- a/include/linux/skbuff.h
76864 +++ b/include/linux/skbuff.h
76865 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76866 extern struct sk_buff *__alloc_skb(unsigned int size,
76867 gfp_t priority, int flags, int node);
76868 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76869 -static inline struct sk_buff *alloc_skb(unsigned int size,
76870 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76871 gfp_t priority)
76872 {
76873 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76874 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76875 */
76876 static inline int skb_queue_empty(const struct sk_buff_head *list)
76877 {
76878 - return list->next == (struct sk_buff *)list;
76879 + return list->next == (const struct sk_buff *)list;
76880 }
76881
76882 /**
76883 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76884 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76885 const struct sk_buff *skb)
76886 {
76887 - return skb->next == (struct sk_buff *)list;
76888 + return skb->next == (const struct sk_buff *)list;
76889 }
76890
76891 /**
76892 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76893 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76894 const struct sk_buff *skb)
76895 {
76896 - return skb->prev == (struct sk_buff *)list;
76897 + return skb->prev == (const struct sk_buff *)list;
76898 }
76899
76900 /**
76901 @@ -1755,7 +1755,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76902 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76903 */
76904 #ifndef NET_SKB_PAD
76905 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76906 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76907 #endif
76908
76909 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76910 @@ -2350,7 +2350,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76911 int noblock, int *err);
76912 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76913 struct poll_table_struct *wait);
76914 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76915 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76916 int offset, struct iovec *to,
76917 int size);
76918 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76919 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
76920 nf_bridge_put(skb->nf_bridge);
76921 skb->nf_bridge = NULL;
76922 #endif
76923 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76924 + skb->nf_trace = 0;
76925 +#endif
76926 }
76927
76928 static inline void nf_reset_trace(struct sk_buff *skb)
76929 diff --git a/include/linux/slab.h b/include/linux/slab.h
76930 index 6c5cc0e..9ca0fd6 100644
76931 --- a/include/linux/slab.h
76932 +++ b/include/linux/slab.h
76933 @@ -12,15 +12,29 @@
76934 #include <linux/gfp.h>
76935 #include <linux/types.h>
76936 #include <linux/workqueue.h>
76937 -
76938 +#include <linux/err.h>
76939
76940 /*
76941 * Flags to pass to kmem_cache_create().
76942 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76943 */
76944 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76945 +
76946 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76947 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76948 +#else
76949 +#define SLAB_USERCOPY 0x00000000UL
76950 +#endif
76951 +
76952 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76953 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76954 +
76955 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76956 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76957 +#else
76958 +#define SLAB_NO_SANITIZE 0x00000000UL
76959 +#endif
76960 +
76961 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76962 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76963 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76964 @@ -89,10 +103,13 @@
76965 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76966 * Both make kfree a no-op.
76967 */
76968 -#define ZERO_SIZE_PTR ((void *)16)
76969 +#define ZERO_SIZE_PTR \
76970 +({ \
76971 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76972 + (void *)(-MAX_ERRNO-1L); \
76973 +})
76974
76975 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76976 - (unsigned long)ZERO_SIZE_PTR)
76977 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76978
76979
76980 struct mem_cgroup;
76981 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76982 void kfree(const void *);
76983 void kzfree(const void *);
76984 size_t ksize(const void *);
76985 +const char *check_heap_object(const void *ptr, unsigned long n);
76986 +bool is_usercopy_object(const void *ptr);
76987
76988 /*
76989 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76990 @@ -164,7 +183,7 @@ struct kmem_cache {
76991 unsigned int align; /* Alignment as calculated */
76992 unsigned long flags; /* Active flags on the slab */
76993 const char *name; /* Slab name for sysfs */
76994 - int refcount; /* Use counter */
76995 + atomic_t refcount; /* Use counter */
76996 void (*ctor)(void *); /* Called on object slot creation */
76997 struct list_head list; /* List of all slab caches on the system */
76998 };
76999 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
77000 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77001 #endif
77002
77003 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77004 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
77005 +#endif
77006 +
77007 /*
77008 * Figure out which kmalloc slab an allocation of a certain size
77009 * belongs to.
77010 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77011 * 2 = 120 .. 192 bytes
77012 * n = 2^(n-1) .. 2^n -1
77013 */
77014 -static __always_inline int kmalloc_index(size_t size)
77015 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
77016 {
77017 if (!size)
77018 return 0;
77019 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
77020 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
77021 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
77022 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
77023 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
77024 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
77025 #define kmalloc_track_caller(size, flags) \
77026 __kmalloc_track_caller(size, flags, _RET_IP_)
77027 #else
77028 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
77029 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
77030 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
77031 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
77032 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
77033 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
77034 #define kmalloc_node_track_caller(size, flags, node) \
77035 __kmalloc_node_track_caller(size, flags, node, \
77036 _RET_IP_)
77037 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
77038 index cd40158..4e2f7af 100644
77039 --- a/include/linux/slab_def.h
77040 +++ b/include/linux/slab_def.h
77041 @@ -50,7 +50,7 @@ struct kmem_cache {
77042 /* 4) cache creation/removal */
77043 const char *name;
77044 struct list_head list;
77045 - int refcount;
77046 + atomic_t refcount;
77047 int object_size;
77048 int align;
77049
77050 @@ -66,10 +66,14 @@ struct kmem_cache {
77051 unsigned long node_allocs;
77052 unsigned long node_frees;
77053 unsigned long node_overflow;
77054 - atomic_t allochit;
77055 - atomic_t allocmiss;
77056 - atomic_t freehit;
77057 - atomic_t freemiss;
77058 + atomic_unchecked_t allochit;
77059 + atomic_unchecked_t allocmiss;
77060 + atomic_unchecked_t freehit;
77061 + atomic_unchecked_t freemiss;
77062 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77063 + atomic_unchecked_t sanitized;
77064 + atomic_unchecked_t not_sanitized;
77065 +#endif
77066
77067 /*
77068 * If debugging is enabled, then the allocator can add additional
77069 @@ -103,7 +107,7 @@ struct kmem_cache {
77070 };
77071
77072 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
77073 -void *__kmalloc(size_t size, gfp_t flags);
77074 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
77075
77076 #ifdef CONFIG_TRACING
77077 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
77078 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
77079 cachep = kmalloc_dma_caches[i];
77080 else
77081 #endif
77082 +
77083 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77084 + if (flags & GFP_USERCOPY)
77085 + cachep = kmalloc_usercopy_caches[i];
77086 + else
77087 +#endif
77088 +
77089 cachep = kmalloc_caches[i];
77090
77091 ret = kmem_cache_alloc_trace(cachep, flags, size);
77092 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
77093 }
77094
77095 #ifdef CONFIG_NUMA
77096 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
77097 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
77098 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
77099
77100 #ifdef CONFIG_TRACING
77101 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
77102 cachep = kmalloc_dma_caches[i];
77103 else
77104 #endif
77105 +
77106 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77107 + if (flags & GFP_USERCOPY)
77108 + cachep = kmalloc_usercopy_caches[i];
77109 + else
77110 +#endif
77111 +
77112 cachep = kmalloc_caches[i];
77113
77114 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
77115 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
77116 index 095a5a4..4b82027 100644
77117 --- a/include/linux/slob_def.h
77118 +++ b/include/linux/slob_def.h
77119 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
77120 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
77121 }
77122
77123 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
77124 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
77125
77126 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
77127 {
77128 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
77129 return __kmalloc_node(size, flags, NUMA_NO_NODE);
77130 }
77131
77132 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
77133 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
77134 {
77135 return kmalloc(size, flags);
77136 }
77137 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
77138 index 027276f..092bfe8 100644
77139 --- a/include/linux/slub_def.h
77140 +++ b/include/linux/slub_def.h
77141 @@ -80,7 +80,7 @@ struct kmem_cache {
77142 struct kmem_cache_order_objects max;
77143 struct kmem_cache_order_objects min;
77144 gfp_t allocflags; /* gfp flags to use on each alloc */
77145 - int refcount; /* Refcount for slab cache destroy */
77146 + atomic_t refcount; /* Refcount for slab cache destroy */
77147 void (*ctor)(void *);
77148 int inuse; /* Offset to metadata */
77149 int align; /* Alignment */
77150 @@ -105,7 +105,7 @@ struct kmem_cache {
77151 };
77152
77153 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
77154 -void *__kmalloc(size_t size, gfp_t flags);
77155 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
77156
77157 static __always_inline void *
77158 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
77159 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
77160 }
77161 #endif
77162
77163 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
77164 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
77165 {
77166 unsigned int order = get_order(size);
77167 return kmalloc_order_trace(size, flags, order);
77168 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
77169 }
77170
77171 #ifdef CONFIG_NUMA
77172 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
77173 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
77174 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
77175
77176 #ifdef CONFIG_TRACING
77177 diff --git a/include/linux/smp.h b/include/linux/smp.h
77178 index c181399..09d7b92 100644
77179 --- a/include/linux/smp.h
77180 +++ b/include/linux/smp.h
77181 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
77182 #endif
77183
77184 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
77185 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
77186 #define put_cpu() preempt_enable()
77187 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
77188
77189 /*
77190 * Callback to arch code if there's nosmp or maxcpus=0 on the
77191 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
77192 index 54f91d3..be2c379 100644
77193 --- a/include/linux/sock_diag.h
77194 +++ b/include/linux/sock_diag.h
77195 @@ -11,7 +11,7 @@ struct sock;
77196 struct sock_diag_handler {
77197 __u8 family;
77198 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
77199 -};
77200 +} __do_const;
77201
77202 int sock_diag_register(const struct sock_diag_handler *h);
77203 void sock_diag_unregister(const struct sock_diag_handler *h);
77204 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
77205 index 680f9a3..f13aeb0 100644
77206 --- a/include/linux/sonet.h
77207 +++ b/include/linux/sonet.h
77208 @@ -7,7 +7,7 @@
77209 #include <uapi/linux/sonet.h>
77210
77211 struct k_sonet_stats {
77212 -#define __HANDLE_ITEM(i) atomic_t i
77213 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
77214 __SONET_ITEMS
77215 #undef __HANDLE_ITEM
77216 };
77217 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
77218 index 07d8e53..dc934c9 100644
77219 --- a/include/linux/sunrpc/addr.h
77220 +++ b/include/linux/sunrpc/addr.h
77221 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
77222 {
77223 switch (sap->sa_family) {
77224 case AF_INET:
77225 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
77226 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
77227 case AF_INET6:
77228 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
77229 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
77230 }
77231 return 0;
77232 }
77233 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
77234 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
77235 const struct sockaddr *src)
77236 {
77237 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
77238 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
77239 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
77240
77241 dsin->sin_family = ssin->sin_family;
77242 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
77243 if (sa->sa_family != AF_INET6)
77244 return 0;
77245
77246 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
77247 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
77248 }
77249
77250 #endif /* _LINUX_SUNRPC_ADDR_H */
77251 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
77252 index bfe11be..12bc8c4 100644
77253 --- a/include/linux/sunrpc/clnt.h
77254 +++ b/include/linux/sunrpc/clnt.h
77255 @@ -96,7 +96,7 @@ struct rpc_procinfo {
77256 unsigned int p_timer; /* Which RTT timer to use */
77257 u32 p_statidx; /* Which procedure to account */
77258 const char * p_name; /* name of procedure */
77259 -};
77260 +} __do_const;
77261
77262 #ifdef __KERNEL__
77263
77264 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
77265 index 1f0216b..6a4fa50 100644
77266 --- a/include/linux/sunrpc/svc.h
77267 +++ b/include/linux/sunrpc/svc.h
77268 @@ -411,7 +411,7 @@ struct svc_procedure {
77269 unsigned int pc_count; /* call count */
77270 unsigned int pc_cachetype; /* cache info (NFS) */
77271 unsigned int pc_xdrressize; /* maximum size of XDR reply */
77272 -};
77273 +} __do_const;
77274
77275 /*
77276 * Function prototypes.
77277 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
77278 index 0b8e3e6..33e0a01 100644
77279 --- a/include/linux/sunrpc/svc_rdma.h
77280 +++ b/include/linux/sunrpc/svc_rdma.h
77281 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
77282 extern unsigned int svcrdma_max_requests;
77283 extern unsigned int svcrdma_max_req_size;
77284
77285 -extern atomic_t rdma_stat_recv;
77286 -extern atomic_t rdma_stat_read;
77287 -extern atomic_t rdma_stat_write;
77288 -extern atomic_t rdma_stat_sq_starve;
77289 -extern atomic_t rdma_stat_rq_starve;
77290 -extern atomic_t rdma_stat_rq_poll;
77291 -extern atomic_t rdma_stat_rq_prod;
77292 -extern atomic_t rdma_stat_sq_poll;
77293 -extern atomic_t rdma_stat_sq_prod;
77294 +extern atomic_unchecked_t rdma_stat_recv;
77295 +extern atomic_unchecked_t rdma_stat_read;
77296 +extern atomic_unchecked_t rdma_stat_write;
77297 +extern atomic_unchecked_t rdma_stat_sq_starve;
77298 +extern atomic_unchecked_t rdma_stat_rq_starve;
77299 +extern atomic_unchecked_t rdma_stat_rq_poll;
77300 +extern atomic_unchecked_t rdma_stat_rq_prod;
77301 +extern atomic_unchecked_t rdma_stat_sq_poll;
77302 +extern atomic_unchecked_t rdma_stat_sq_prod;
77303
77304 #define RPCRDMA_VERSION 1
77305
77306 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77307 index 8d71d65..f79586e 100644
77308 --- a/include/linux/sunrpc/svcauth.h
77309 +++ b/include/linux/sunrpc/svcauth.h
77310 @@ -120,7 +120,7 @@ struct auth_ops {
77311 int (*release)(struct svc_rqst *rq);
77312 void (*domain_release)(struct auth_domain *);
77313 int (*set_client)(struct svc_rqst *rq);
77314 -};
77315 +} __do_const;
77316
77317 #define SVC_GARBAGE 1
77318 #define SVC_SYSERR 2
77319 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77320 index a5ffd32..0935dea 100644
77321 --- a/include/linux/swiotlb.h
77322 +++ b/include/linux/swiotlb.h
77323 @@ -60,7 +60,8 @@ extern void
77324
77325 extern void
77326 swiotlb_free_coherent(struct device *hwdev, size_t size,
77327 - void *vaddr, dma_addr_t dma_handle);
77328 + void *vaddr, dma_addr_t dma_handle,
77329 + struct dma_attrs *attrs);
77330
77331 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77332 unsigned long offset, size_t size,
77333 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77334 index 84662ec..5271947 100644
77335 --- a/include/linux/syscalls.h
77336 +++ b/include/linux/syscalls.h
77337 @@ -97,8 +97,14 @@ struct sigaltstack;
77338 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77339
77340 #define __SC_DECL(t, a) t a
77341 +#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))
77342 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77343 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77344 +#define __SC_LONG(t, a) __typeof( \
77345 + __builtin_choose_expr( \
77346 + sizeof(t) > sizeof(int), \
77347 + (t) 0, \
77348 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77349 + )) a
77350 #define __SC_CAST(t, a) (t) a
77351 #define __SC_ARGS(t, a) a
77352 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77353 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77354 asmlinkage long sys_fsync(unsigned int fd);
77355 asmlinkage long sys_fdatasync(unsigned int fd);
77356 asmlinkage long sys_bdflush(int func, long data);
77357 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77358 - char __user *type, unsigned long flags,
77359 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77360 + const char __user *type, unsigned long flags,
77361 void __user *data);
77362 -asmlinkage long sys_umount(char __user *name, int flags);
77363 -asmlinkage long sys_oldumount(char __user *name);
77364 +asmlinkage long sys_umount(const char __user *name, int flags);
77365 +asmlinkage long sys_oldumount(const char __user *name);
77366 asmlinkage long sys_truncate(const char __user *path, long length);
77367 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77368 asmlinkage long sys_stat(const char __user *filename,
77369 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77370 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77371 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77372 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77373 - struct sockaddr __user *, int);
77374 + struct sockaddr __user *, int) __intentional_overflow(0);
77375 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77376 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77377 unsigned int vlen, unsigned flags);
77378 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77379 index 27b3b0b..e093dd9 100644
77380 --- a/include/linux/syscore_ops.h
77381 +++ b/include/linux/syscore_ops.h
77382 @@ -16,7 +16,7 @@ struct syscore_ops {
77383 int (*suspend)(void);
77384 void (*resume)(void);
77385 void (*shutdown)(void);
77386 -};
77387 +} __do_const;
77388
77389 extern void register_syscore_ops(struct syscore_ops *ops);
77390 extern void unregister_syscore_ops(struct syscore_ops *ops);
77391 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77392 index 14a8ff2..af52bad 100644
77393 --- a/include/linux/sysctl.h
77394 +++ b/include/linux/sysctl.h
77395 @@ -34,13 +34,13 @@ struct ctl_table_root;
77396 struct ctl_table_header;
77397 struct ctl_dir;
77398
77399 -typedef struct ctl_table ctl_table;
77400 -
77401 typedef int proc_handler (struct ctl_table *ctl, int write,
77402 void __user *buffer, size_t *lenp, loff_t *ppos);
77403
77404 extern int proc_dostring(struct ctl_table *, int,
77405 void __user *, size_t *, loff_t *);
77406 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77407 + void __user *, size_t *, loff_t *);
77408 extern int proc_dointvec(struct ctl_table *, int,
77409 void __user *, size_t *, loff_t *);
77410 extern int proc_dointvec_minmax(struct ctl_table *, int,
77411 @@ -115,7 +115,9 @@ struct ctl_table
77412 struct ctl_table_poll *poll;
77413 void *extra1;
77414 void *extra2;
77415 -};
77416 +} __do_const;
77417 +typedef struct ctl_table __no_const ctl_table_no_const;
77418 +typedef struct ctl_table ctl_table;
77419
77420 struct ctl_node {
77421 struct rb_node node;
77422 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77423 index 9e8a9b5..753de68 100644
77424 --- a/include/linux/sysfs.h
77425 +++ b/include/linux/sysfs.h
77426 @@ -33,7 +33,8 @@ struct attribute {
77427 struct lock_class_key *key;
77428 struct lock_class_key skey;
77429 #endif
77430 -};
77431 +} __do_const;
77432 +typedef struct attribute __no_const attribute_no_const;
77433
77434 /**
77435 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77436 @@ -62,7 +63,8 @@ struct attribute_group {
77437 struct attribute *, int);
77438 struct attribute **attrs;
77439 struct bin_attribute **bin_attrs;
77440 -};
77441 +} __do_const;
77442 +typedef struct attribute_group __no_const attribute_group_no_const;
77443
77444 /**
77445 * Use these macros to make defining attributes easier. See include/linux/device.h
77446 @@ -123,7 +125,8 @@ struct bin_attribute {
77447 char *, loff_t, size_t);
77448 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77449 struct vm_area_struct *vma);
77450 -};
77451 +} __do_const;
77452 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77453
77454 /**
77455 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77456 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77457 index 7faf933..9b85a0c 100644
77458 --- a/include/linux/sysrq.h
77459 +++ b/include/linux/sysrq.h
77460 @@ -16,6 +16,7 @@
77461
77462 #include <linux/errno.h>
77463 #include <linux/types.h>
77464 +#include <linux/compiler.h>
77465
77466 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77467 #define SYSRQ_DEFAULT_ENABLE 1
77468 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77469 char *help_msg;
77470 char *action_msg;
77471 int enable_mask;
77472 -};
77473 +} __do_const;
77474
77475 #ifdef CONFIG_MAGIC_SYSRQ
77476
77477 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77478 index e7e0473..7989295 100644
77479 --- a/include/linux/thread_info.h
77480 +++ b/include/linux/thread_info.h
77481 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77482 #error "no set_restore_sigmask() provided and default one won't work"
77483 #endif
77484
77485 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77486 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77487 +{
77488 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77489 + if (!__builtin_constant_p(n))
77490 +#endif
77491 + __check_object_size(ptr, n, to_user);
77492 +}
77493 +
77494 #endif /* __KERNEL__ */
77495
77496 #endif /* _LINUX_THREAD_INFO_H */
77497 diff --git a/include/linux/tty.h b/include/linux/tty.h
77498 index 01ac30e..bf18a71 100644
77499 --- a/include/linux/tty.h
77500 +++ b/include/linux/tty.h
77501 @@ -194,7 +194,7 @@ struct tty_port {
77502 const struct tty_port_operations *ops; /* Port operations */
77503 spinlock_t lock; /* Lock protecting tty field */
77504 int blocked_open; /* Waiting to open */
77505 - int count; /* Usage count */
77506 + atomic_t count; /* Usage count */
77507 wait_queue_head_t open_wait; /* Open waiters */
77508 wait_queue_head_t close_wait; /* Close waiters */
77509 wait_queue_head_t delta_msr_wait; /* Modem status change */
77510 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77511 struct tty_struct *tty, struct file *filp);
77512 static inline int tty_port_users(struct tty_port *port)
77513 {
77514 - return port->count + port->blocked_open;
77515 + return atomic_read(&port->count) + port->blocked_open;
77516 }
77517
77518 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77519 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77520 index 756a609..b302dd6 100644
77521 --- a/include/linux/tty_driver.h
77522 +++ b/include/linux/tty_driver.h
77523 @@ -285,7 +285,7 @@ struct tty_operations {
77524 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77525 #endif
77526 const struct file_operations *proc_fops;
77527 -};
77528 +} __do_const;
77529
77530 struct tty_driver {
77531 int magic; /* magic number for this structure */
77532 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77533 index a1b0489..f02e17c 100644
77534 --- a/include/linux/tty_ldisc.h
77535 +++ b/include/linux/tty_ldisc.h
77536 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77537
77538 struct module *owner;
77539
77540 - int refcount;
77541 + atomic_t refcount;
77542 };
77543
77544 struct tty_ldisc {
77545 diff --git a/include/linux/types.h b/include/linux/types.h
77546 index 4d118ba..c3ee9bf 100644
77547 --- a/include/linux/types.h
77548 +++ b/include/linux/types.h
77549 @@ -176,10 +176,26 @@ typedef struct {
77550 int counter;
77551 } atomic_t;
77552
77553 +#ifdef CONFIG_PAX_REFCOUNT
77554 +typedef struct {
77555 + int counter;
77556 +} atomic_unchecked_t;
77557 +#else
77558 +typedef atomic_t atomic_unchecked_t;
77559 +#endif
77560 +
77561 #ifdef CONFIG_64BIT
77562 typedef struct {
77563 long counter;
77564 } atomic64_t;
77565 +
77566 +#ifdef CONFIG_PAX_REFCOUNT
77567 +typedef struct {
77568 + long counter;
77569 +} atomic64_unchecked_t;
77570 +#else
77571 +typedef atomic64_t atomic64_unchecked_t;
77572 +#endif
77573 #endif
77574
77575 struct list_head {
77576 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77577 index 5ca0951..ab496a5 100644
77578 --- a/include/linux/uaccess.h
77579 +++ b/include/linux/uaccess.h
77580 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77581 long ret; \
77582 mm_segment_t old_fs = get_fs(); \
77583 \
77584 - set_fs(KERNEL_DS); \
77585 pagefault_disable(); \
77586 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77587 - pagefault_enable(); \
77588 + set_fs(KERNEL_DS); \
77589 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77590 set_fs(old_fs); \
77591 + pagefault_enable(); \
77592 ret; \
77593 })
77594
77595 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77596 index 8e522cbc..aa8572d 100644
77597 --- a/include/linux/uidgid.h
77598 +++ b/include/linux/uidgid.h
77599 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77600
77601 #endif /* CONFIG_USER_NS */
77602
77603 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77604 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77605 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77606 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77607 +
77608 #endif /* _LINUX_UIDGID_H */
77609 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77610 index 99c1b4d..562e6f3 100644
77611 --- a/include/linux/unaligned/access_ok.h
77612 +++ b/include/linux/unaligned/access_ok.h
77613 @@ -4,34 +4,34 @@
77614 #include <linux/kernel.h>
77615 #include <asm/byteorder.h>
77616
77617 -static inline u16 get_unaligned_le16(const void *p)
77618 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77619 {
77620 - return le16_to_cpup((__le16 *)p);
77621 + return le16_to_cpup((const __le16 *)p);
77622 }
77623
77624 -static inline u32 get_unaligned_le32(const void *p)
77625 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77626 {
77627 - return le32_to_cpup((__le32 *)p);
77628 + return le32_to_cpup((const __le32 *)p);
77629 }
77630
77631 -static inline u64 get_unaligned_le64(const void *p)
77632 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77633 {
77634 - return le64_to_cpup((__le64 *)p);
77635 + return le64_to_cpup((const __le64 *)p);
77636 }
77637
77638 -static inline u16 get_unaligned_be16(const void *p)
77639 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77640 {
77641 - return be16_to_cpup((__be16 *)p);
77642 + return be16_to_cpup((const __be16 *)p);
77643 }
77644
77645 -static inline u32 get_unaligned_be32(const void *p)
77646 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77647 {
77648 - return be32_to_cpup((__be32 *)p);
77649 + return be32_to_cpup((const __be32 *)p);
77650 }
77651
77652 -static inline u64 get_unaligned_be64(const void *p)
77653 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77654 {
77655 - return be64_to_cpup((__be64 *)p);
77656 + return be64_to_cpup((const __be64 *)p);
77657 }
77658
77659 static inline void put_unaligned_le16(u16 val, void *p)
77660 diff --git a/include/linux/usb.h b/include/linux/usb.h
77661 index 0eec268..4496526 100644
77662 --- a/include/linux/usb.h
77663 +++ b/include/linux/usb.h
77664 @@ -560,7 +560,7 @@ struct usb_device {
77665 int maxchild;
77666
77667 u32 quirks;
77668 - atomic_t urbnum;
77669 + atomic_unchecked_t urbnum;
77670
77671 unsigned long active_duration;
77672
77673 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77674
77675 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77676 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77677 - void *data, __u16 size, int timeout);
77678 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77679 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77680 void *data, int len, int *actual_length, int timeout);
77681 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77682 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77683 index e452ba6..78f8e80 100644
77684 --- a/include/linux/usb/renesas_usbhs.h
77685 +++ b/include/linux/usb/renesas_usbhs.h
77686 @@ -39,7 +39,7 @@ enum {
77687 */
77688 struct renesas_usbhs_driver_callback {
77689 int (*notify_hotplug)(struct platform_device *pdev);
77690 -};
77691 +} __no_const;
77692
77693 /*
77694 * callback functions for platform
77695 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77696 index 6f8fbcf..8259001 100644
77697 --- a/include/linux/vermagic.h
77698 +++ b/include/linux/vermagic.h
77699 @@ -25,9 +25,35 @@
77700 #define MODULE_ARCH_VERMAGIC ""
77701 #endif
77702
77703 +#ifdef CONFIG_PAX_REFCOUNT
77704 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77705 +#else
77706 +#define MODULE_PAX_REFCOUNT ""
77707 +#endif
77708 +
77709 +#ifdef CONSTIFY_PLUGIN
77710 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77711 +#else
77712 +#define MODULE_CONSTIFY_PLUGIN ""
77713 +#endif
77714 +
77715 +#ifdef STACKLEAK_PLUGIN
77716 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77717 +#else
77718 +#define MODULE_STACKLEAK_PLUGIN ""
77719 +#endif
77720 +
77721 +#ifdef CONFIG_GRKERNSEC
77722 +#define MODULE_GRSEC "GRSEC "
77723 +#else
77724 +#define MODULE_GRSEC ""
77725 +#endif
77726 +
77727 #define VERMAGIC_STRING \
77728 UTS_RELEASE " " \
77729 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77730 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77731 - MODULE_ARCH_VERMAGIC
77732 + MODULE_ARCH_VERMAGIC \
77733 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77734 + MODULE_GRSEC
77735
77736 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77737 index 4b8a891..c20e936 100644
77738 --- a/include/linux/vmalloc.h
77739 +++ b/include/linux/vmalloc.h
77740 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77741 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77742 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77743 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77744 +
77745 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77746 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77747 +#endif
77748 +
77749 /* bits [20..32] reserved for arch specific ioremap internals */
77750
77751 /*
77752 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77753 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77754 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77755 unsigned long start, unsigned long end, gfp_t gfp_mask,
77756 - pgprot_t prot, int node, const void *caller);
77757 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77758 extern void vfree(const void *addr);
77759
77760 extern void *vmap(struct page **pages, unsigned int count,
77761 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77762 extern void free_vm_area(struct vm_struct *area);
77763
77764 /* for /dev/kmem */
77765 -extern long vread(char *buf, char *addr, unsigned long count);
77766 -extern long vwrite(char *buf, char *addr, unsigned long count);
77767 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77768 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77769
77770 /*
77771 * Internals. Dont't use..
77772 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77773 index c586679..f06b389 100644
77774 --- a/include/linux/vmstat.h
77775 +++ b/include/linux/vmstat.h
77776 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77777 /*
77778 * Zone based page accounting with per cpu differentials.
77779 */
77780 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77781 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77782
77783 static inline void zone_page_state_add(long x, struct zone *zone,
77784 enum zone_stat_item item)
77785 {
77786 - atomic_long_add(x, &zone->vm_stat[item]);
77787 - atomic_long_add(x, &vm_stat[item]);
77788 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77789 + atomic_long_add_unchecked(x, &vm_stat[item]);
77790 }
77791
77792 static inline unsigned long global_page_state(enum zone_stat_item item)
77793 {
77794 - long x = atomic_long_read(&vm_stat[item]);
77795 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77796 #ifdef CONFIG_SMP
77797 if (x < 0)
77798 x = 0;
77799 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77800 static inline unsigned long zone_page_state(struct zone *zone,
77801 enum zone_stat_item item)
77802 {
77803 - long x = atomic_long_read(&zone->vm_stat[item]);
77804 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77805 #ifdef CONFIG_SMP
77806 if (x < 0)
77807 x = 0;
77808 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77809 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77810 enum zone_stat_item item)
77811 {
77812 - long x = atomic_long_read(&zone->vm_stat[item]);
77813 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77814
77815 #ifdef CONFIG_SMP
77816 int cpu;
77817 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77818
77819 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77820 {
77821 - atomic_long_inc(&zone->vm_stat[item]);
77822 - atomic_long_inc(&vm_stat[item]);
77823 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77824 + atomic_long_inc_unchecked(&vm_stat[item]);
77825 }
77826
77827 static inline void __inc_zone_page_state(struct page *page,
77828 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77829
77830 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77831 {
77832 - atomic_long_dec(&zone->vm_stat[item]);
77833 - atomic_long_dec(&vm_stat[item]);
77834 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77835 + atomic_long_dec_unchecked(&vm_stat[item]);
77836 }
77837
77838 static inline void __dec_zone_page_state(struct page *page,
77839 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77840 index fdbafc6..49dfe4f 100644
77841 --- a/include/linux/xattr.h
77842 +++ b/include/linux/xattr.h
77843 @@ -28,7 +28,7 @@ struct xattr_handler {
77844 size_t size, int handler_flags);
77845 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77846 size_t size, int flags, int handler_flags);
77847 -};
77848 +} __do_const;
77849
77850 struct xattr {
77851 char *name;
77852 @@ -37,6 +37,9 @@ struct xattr {
77853 };
77854
77855 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77856 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77857 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77858 +#endif
77859 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77860 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77861 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77862 diff --git a/include/linux/yam.h b/include/linux/yam.h
77863 index 7fe2822..512cdc2 100644
77864 --- a/include/linux/yam.h
77865 +++ b/include/linux/yam.h
77866 @@ -77,6 +77,6 @@ struct yamdrv_ioctl_cfg {
77867
77868 struct yamdrv_ioctl_mcs {
77869 int cmd;
77870 - int bitrate;
77871 + unsigned int bitrate;
77872 unsigned char bits[YAM_FPGA_SIZE];
77873 };
77874 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77875 index 9c5a6b4..09c9438 100644
77876 --- a/include/linux/zlib.h
77877 +++ b/include/linux/zlib.h
77878 @@ -31,6 +31,7 @@
77879 #define _ZLIB_H
77880
77881 #include <linux/zconf.h>
77882 +#include <linux/compiler.h>
77883
77884 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77885 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77886 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77887
77888 /* basic functions */
77889
77890 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77891 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77892 /*
77893 Returns the number of bytes that needs to be allocated for a per-
77894 stream workspace with the specified parameters. A pointer to this
77895 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77896 index c768c9f..bdcaa5a 100644
77897 --- a/include/media/v4l2-dev.h
77898 +++ b/include/media/v4l2-dev.h
77899 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77900 int (*mmap) (struct file *, struct vm_area_struct *);
77901 int (*open) (struct file *);
77902 int (*release) (struct file *);
77903 -};
77904 +} __do_const;
77905
77906 /*
77907 * Newer version of video_device, handled by videodev2.c
77908 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77909 index c9b1593..a572459 100644
77910 --- a/include/media/v4l2-device.h
77911 +++ b/include/media/v4l2-device.h
77912 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77913 this function returns 0. If the name ends with a digit (e.g. cx18),
77914 then the name will be set to cx18-0 since cx180 looks really odd. */
77915 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77916 - atomic_t *instance);
77917 + atomic_unchecked_t *instance);
77918
77919 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77920 Since the parent disappears this ensures that v4l2_dev doesn't have an
77921 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77922 index d9fa68f..45c88d1 100644
77923 --- a/include/net/9p/transport.h
77924 +++ b/include/net/9p/transport.h
77925 @@ -63,7 +63,7 @@ struct p9_trans_module {
77926 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77927 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77928 char *, char *, int , int, int, int);
77929 -};
77930 +} __do_const;
77931
77932 void v9fs_register_trans(struct p9_trans_module *m);
77933 void v9fs_unregister_trans(struct p9_trans_module *m);
77934 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77935 index 1a966af..2767cf6 100644
77936 --- a/include/net/bluetooth/l2cap.h
77937 +++ b/include/net/bluetooth/l2cap.h
77938 @@ -551,7 +551,7 @@ struct l2cap_ops {
77939 void (*defer) (struct l2cap_chan *chan);
77940 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77941 unsigned long len, int nb);
77942 -};
77943 +} __do_const;
77944
77945 struct l2cap_conn {
77946 struct hci_conn *hcon;
77947 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77948 index f2ae33d..c457cf0 100644
77949 --- a/include/net/caif/cfctrl.h
77950 +++ b/include/net/caif/cfctrl.h
77951 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77952 void (*radioset_rsp)(void);
77953 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77954 struct cflayer *client_layer);
77955 -};
77956 +} __no_const;
77957
77958 /* Link Setup Parameters for CAIF-Links. */
77959 struct cfctrl_link_param {
77960 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77961 struct cfctrl {
77962 struct cfsrvl serv;
77963 struct cfctrl_rsp res;
77964 - atomic_t req_seq_no;
77965 - atomic_t rsp_seq_no;
77966 + atomic_unchecked_t req_seq_no;
77967 + atomic_unchecked_t rsp_seq_no;
77968 struct list_head list;
77969 /* Protects from simultaneous access to first_req list */
77970 spinlock_t info_list_lock;
77971 diff --git a/include/net/flow.h b/include/net/flow.h
77972 index 628e11b..4c475df 100644
77973 --- a/include/net/flow.h
77974 +++ b/include/net/flow.h
77975 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77976
77977 extern void flow_cache_flush(void);
77978 extern void flow_cache_flush_deferred(void);
77979 -extern atomic_t flow_cache_genid;
77980 +extern atomic_unchecked_t flow_cache_genid;
77981
77982 #endif
77983 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77984 index 8e0b6c8..73cf605 100644
77985 --- a/include/net/genetlink.h
77986 +++ b/include/net/genetlink.h
77987 @@ -120,7 +120,7 @@ struct genl_ops {
77988 struct netlink_callback *cb);
77989 int (*done)(struct netlink_callback *cb);
77990 struct list_head ops_list;
77991 -};
77992 +} __do_const;
77993
77994 extern int __genl_register_family(struct genl_family *family);
77995
77996 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77997 index 734d9b5..48a9a4b 100644
77998 --- a/include/net/gro_cells.h
77999 +++ b/include/net/gro_cells.h
78000 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
78001 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
78002
78003 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
78004 - atomic_long_inc(&dev->rx_dropped);
78005 + atomic_long_inc_unchecked(&dev->rx_dropped);
78006 kfree_skb(skb);
78007 return;
78008 }
78009 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
78010 index de2c785..0588a6b 100644
78011 --- a/include/net/inet_connection_sock.h
78012 +++ b/include/net/inet_connection_sock.h
78013 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
78014 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
78015 int (*bind_conflict)(const struct sock *sk,
78016 const struct inet_bind_bucket *tb, bool relax);
78017 -};
78018 +} __do_const;
78019
78020 /** inet_connection_sock - INET connection oriented sock
78021 *
78022 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
78023 index 53f464d..0bd0b49 100644
78024 --- a/include/net/inetpeer.h
78025 +++ b/include/net/inetpeer.h
78026 @@ -47,8 +47,8 @@ struct inet_peer {
78027 */
78028 union {
78029 struct {
78030 - atomic_t rid; /* Frag reception counter */
78031 - atomic_t ip_id_count; /* IP ID for the next packet */
78032 + atomic_unchecked_t rid; /* Frag reception counter */
78033 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
78034 };
78035 struct rcu_head rcu;
78036 struct inet_peer *gc_next;
78037 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
78038 /* can be called with or without local BH being disabled */
78039 static inline int inet_getid(struct inet_peer *p, int more)
78040 {
78041 - int old, new;
78042 + int id;
78043 more++;
78044 inet_peer_refcheck(p);
78045 - do {
78046 - old = atomic_read(&p->ip_id_count);
78047 - new = old + more;
78048 - if (!new)
78049 - new = 1;
78050 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
78051 - return new;
78052 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
78053 + if (!id)
78054 + id = atomic_inc_return_unchecked(&p->ip_id_count);
78055 + return id;
78056 }
78057
78058 #endif /* _NET_INETPEER_H */
78059 diff --git a/include/net/ip.h b/include/net/ip.h
78060 index edfa591..a643b82 100644
78061 --- a/include/net/ip.h
78062 +++ b/include/net/ip.h
78063 @@ -202,7 +202,7 @@ extern struct local_ports {
78064 } sysctl_local_ports;
78065 extern void inet_get_local_port_range(int *low, int *high);
78066
78067 -extern unsigned long *sysctl_local_reserved_ports;
78068 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
78069 static inline int inet_is_reserved_local_port(int port)
78070 {
78071 return test_bit(port, sysctl_local_reserved_ports);
78072 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
78073 index cbf2be3..3683f6d 100644
78074 --- a/include/net/ip_fib.h
78075 +++ b/include/net/ip_fib.h
78076 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
78077
78078 #define FIB_RES_SADDR(net, res) \
78079 ((FIB_RES_NH(res).nh_saddr_genid == \
78080 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
78081 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
78082 FIB_RES_NH(res).nh_saddr : \
78083 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
78084 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
78085 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
78086 index f0d70f0..185f15b 100644
78087 --- a/include/net/ip_vs.h
78088 +++ b/include/net/ip_vs.h
78089 @@ -588,7 +588,7 @@ struct ip_vs_conn {
78090 struct ip_vs_conn *control; /* Master control connection */
78091 atomic_t n_control; /* Number of controlled ones */
78092 struct ip_vs_dest *dest; /* real server */
78093 - atomic_t in_pkts; /* incoming packet counter */
78094 + atomic_unchecked_t in_pkts; /* incoming packet counter */
78095
78096 /* packet transmitter for different forwarding methods. If it
78097 mangles the packet, it must return NF_DROP or better NF_STOLEN,
78098 @@ -737,7 +737,7 @@ struct ip_vs_dest {
78099 __be16 port; /* port number of the server */
78100 union nf_inet_addr addr; /* IP address of the server */
78101 volatile unsigned int flags; /* dest status flags */
78102 - atomic_t conn_flags; /* flags to copy to conn */
78103 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
78104 atomic_t weight; /* server weight */
78105
78106 atomic_t refcnt; /* reference counter */
78107 @@ -993,11 +993,11 @@ struct netns_ipvs {
78108 /* ip_vs_lblc */
78109 int sysctl_lblc_expiration;
78110 struct ctl_table_header *lblc_ctl_header;
78111 - struct ctl_table *lblc_ctl_table;
78112 + ctl_table_no_const *lblc_ctl_table;
78113 /* ip_vs_lblcr */
78114 int sysctl_lblcr_expiration;
78115 struct ctl_table_header *lblcr_ctl_header;
78116 - struct ctl_table *lblcr_ctl_table;
78117 + ctl_table_no_const *lblcr_ctl_table;
78118 /* ip_vs_est */
78119 struct list_head est_list; /* estimator list */
78120 spinlock_t est_lock;
78121 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
78122 index 80ffde3..968b0f4 100644
78123 --- a/include/net/irda/ircomm_tty.h
78124 +++ b/include/net/irda/ircomm_tty.h
78125 @@ -35,6 +35,7 @@
78126 #include <linux/termios.h>
78127 #include <linux/timer.h>
78128 #include <linux/tty.h> /* struct tty_struct */
78129 +#include <asm/local.h>
78130
78131 #include <net/irda/irias_object.h>
78132 #include <net/irda/ircomm_core.h>
78133 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
78134 index 714cc9a..ea05f3e 100644
78135 --- a/include/net/iucv/af_iucv.h
78136 +++ b/include/net/iucv/af_iucv.h
78137 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
78138 struct iucv_sock_list {
78139 struct hlist_head head;
78140 rwlock_t lock;
78141 - atomic_t autobind_name;
78142 + atomic_unchecked_t autobind_name;
78143 };
78144
78145 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
78146 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
78147 index df83f69..9b640b8 100644
78148 --- a/include/net/llc_c_ac.h
78149 +++ b/include/net/llc_c_ac.h
78150 @@ -87,7 +87,7 @@
78151 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
78152 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
78153
78154 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78155 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78156
78157 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
78158 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
78159 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
78160 index 6ca3113..f8026dd 100644
78161 --- a/include/net/llc_c_ev.h
78162 +++ b/include/net/llc_c_ev.h
78163 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
78164 return (struct llc_conn_state_ev *)skb->cb;
78165 }
78166
78167 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78168 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78169 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78170 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78171
78172 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
78173 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
78174 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
78175 index 0e79cfb..f46db31 100644
78176 --- a/include/net/llc_c_st.h
78177 +++ b/include/net/llc_c_st.h
78178 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
78179 u8 next_state;
78180 llc_conn_ev_qfyr_t *ev_qualifiers;
78181 llc_conn_action_t *ev_actions;
78182 -};
78183 +} __do_const;
78184
78185 struct llc_conn_state {
78186 u8 current_state;
78187 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
78188 index 37a3bbd..55a4241 100644
78189 --- a/include/net/llc_s_ac.h
78190 +++ b/include/net/llc_s_ac.h
78191 @@ -23,7 +23,7 @@
78192 #define SAP_ACT_TEST_IND 9
78193
78194 /* All action functions must look like this */
78195 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78196 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78197
78198 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
78199 struct sk_buff *skb);
78200 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
78201 index 567c681..cd73ac0 100644
78202 --- a/include/net/llc_s_st.h
78203 +++ b/include/net/llc_s_st.h
78204 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
78205 llc_sap_ev_t ev;
78206 u8 next_state;
78207 llc_sap_action_t *ev_actions;
78208 -};
78209 +} __do_const;
78210
78211 struct llc_sap_state {
78212 u8 curr_state;
78213 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
78214 index 551ba6a..11c99c1 100644
78215 --- a/include/net/mac80211.h
78216 +++ b/include/net/mac80211.h
78217 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
78218 void (*add_sta_debugfs)(void *priv, void *priv_sta,
78219 struct dentry *dir);
78220 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
78221 -};
78222 +} __do_const;
78223
78224 static inline int rate_supported(struct ieee80211_sta *sta,
78225 enum ieee80211_band band,
78226 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
78227 index 7e748ad..5c6229b 100644
78228 --- a/include/net/neighbour.h
78229 +++ b/include/net/neighbour.h
78230 @@ -123,7 +123,7 @@ struct neigh_ops {
78231 void (*error_report)(struct neighbour *, struct sk_buff *);
78232 int (*output)(struct neighbour *, struct sk_buff *);
78233 int (*connected_output)(struct neighbour *, struct sk_buff *);
78234 -};
78235 +} __do_const;
78236
78237 struct pneigh_entry {
78238 struct pneigh_entry *next;
78239 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
78240 index 84e37b1..8eba19a 100644
78241 --- a/include/net/net_namespace.h
78242 +++ b/include/net/net_namespace.h
78243 @@ -119,8 +119,8 @@ struct net {
78244 struct netns_ipvs *ipvs;
78245 #endif
78246 struct sock *diag_nlsk;
78247 - atomic_t rt_genid;
78248 - atomic_t fnhe_genid;
78249 + atomic_unchecked_t rt_genid;
78250 + atomic_unchecked_t fnhe_genid;
78251 };
78252
78253 /*
78254 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
78255 #define __net_init __init
78256 #define __net_exit __exit_refok
78257 #define __net_initdata __initdata
78258 +#ifdef CONSTIFY_PLUGIN
78259 #define __net_initconst __initconst
78260 +#else
78261 +#define __net_initconst __initdata
78262 +#endif
78263 #endif
78264
78265 struct pernet_operations {
78266 @@ -287,7 +291,7 @@ struct pernet_operations {
78267 void (*exit_batch)(struct list_head *net_exit_list);
78268 int *id;
78269 size_t size;
78270 -};
78271 +} __do_const;
78272
78273 /*
78274 * Use these carefully. If you implement a network device and it
78275 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
78276
78277 static inline int rt_genid(struct net *net)
78278 {
78279 - return atomic_read(&net->rt_genid);
78280 + return atomic_read_unchecked(&net->rt_genid);
78281 }
78282
78283 static inline void rt_genid_bump(struct net *net)
78284 {
78285 - atomic_inc(&net->rt_genid);
78286 + atomic_inc_unchecked(&net->rt_genid);
78287 }
78288
78289 static inline int fnhe_genid(struct net *net)
78290 {
78291 - return atomic_read(&net->fnhe_genid);
78292 + return atomic_read_unchecked(&net->fnhe_genid);
78293 }
78294
78295 static inline void fnhe_genid_bump(struct net *net)
78296 {
78297 - atomic_inc(&net->fnhe_genid);
78298 + atomic_inc_unchecked(&net->fnhe_genid);
78299 }
78300
78301 #endif /* __NET_NET_NAMESPACE_H */
78302 diff --git a/include/net/netdma.h b/include/net/netdma.h
78303 index 8ba8ce2..99b7fff 100644
78304 --- a/include/net/netdma.h
78305 +++ b/include/net/netdma.h
78306 @@ -24,7 +24,7 @@
78307 #include <linux/dmaengine.h>
78308 #include <linux/skbuff.h>
78309
78310 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78311 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78312 struct sk_buff *skb, int offset, struct iovec *to,
78313 size_t len, struct dma_pinned_list *pinned_list);
78314
78315 diff --git a/include/net/netlink.h b/include/net/netlink.h
78316 index 9690b0f..87aded7 100644
78317 --- a/include/net/netlink.h
78318 +++ b/include/net/netlink.h
78319 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78320 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78321 {
78322 if (mark)
78323 - skb_trim(skb, (unsigned char *) mark - skb->data);
78324 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78325 }
78326
78327 /**
78328 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78329 index c9c0c53..53f24c3 100644
78330 --- a/include/net/netns/conntrack.h
78331 +++ b/include/net/netns/conntrack.h
78332 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78333 struct nf_proto_net {
78334 #ifdef CONFIG_SYSCTL
78335 struct ctl_table_header *ctl_table_header;
78336 - struct ctl_table *ctl_table;
78337 + ctl_table_no_const *ctl_table;
78338 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78339 struct ctl_table_header *ctl_compat_header;
78340 - struct ctl_table *ctl_compat_table;
78341 + ctl_table_no_const *ctl_compat_table;
78342 #endif
78343 #endif
78344 unsigned int users;
78345 @@ -58,7 +58,7 @@ struct nf_ip_net {
78346 struct nf_icmp_net icmpv6;
78347 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78348 struct ctl_table_header *ctl_table_header;
78349 - struct ctl_table *ctl_table;
78350 + ctl_table_no_const *ctl_table;
78351 #endif
78352 };
78353
78354 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78355 index 2ba9de8..47bd6c7 100644
78356 --- a/include/net/netns/ipv4.h
78357 +++ b/include/net/netns/ipv4.h
78358 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78359 kgid_t sysctl_ping_group_range[2];
78360 long sysctl_tcp_mem[3];
78361
78362 - atomic_t dev_addr_genid;
78363 + atomic_unchecked_t dev_addr_genid;
78364
78365 #ifdef CONFIG_IP_MROUTE
78366 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78367 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78368 index 005e2c2..023d340 100644
78369 --- a/include/net/netns/ipv6.h
78370 +++ b/include/net/netns/ipv6.h
78371 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78372 struct fib_rules_ops *mr6_rules_ops;
78373 #endif
78374 #endif
78375 - atomic_t dev_addr_genid;
78376 + atomic_unchecked_t dev_addr_genid;
78377 };
78378
78379 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78380 diff --git a/include/net/ping.h b/include/net/ping.h
78381 index 5db0224..0d65365 100644
78382 --- a/include/net/ping.h
78383 +++ b/include/net/ping.h
78384 @@ -55,7 +55,7 @@ struct ping_iter_state {
78385 extern struct proto ping_prot;
78386 extern struct ping_table ping_table;
78387 #if IS_ENABLED(CONFIG_IPV6)
78388 -extern struct pingv6_ops pingv6_ops;
78389 +extern struct pingv6_ops *pingv6_ops;
78390 #endif
78391
78392 struct pingfakehdr {
78393 diff --git a/include/net/protocol.h b/include/net/protocol.h
78394 index 047c047..b9dad15 100644
78395 --- a/include/net/protocol.h
78396 +++ b/include/net/protocol.h
78397 @@ -44,7 +44,7 @@ struct net_protocol {
78398 void (*err_handler)(struct sk_buff *skb, u32 info);
78399 unsigned int no_policy:1,
78400 netns_ok:1;
78401 -};
78402 +} __do_const;
78403
78404 #if IS_ENABLED(CONFIG_IPV6)
78405 struct inet6_protocol {
78406 @@ -57,7 +57,7 @@ struct inet6_protocol {
78407 u8 type, u8 code, int offset,
78408 __be32 info);
78409 unsigned int flags; /* INET6_PROTO_xxx */
78410 -};
78411 +} __do_const;
78412
78413 #define INET6_PROTO_NOPOLICY 0x1
78414 #define INET6_PROTO_FINAL 0x2
78415 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78416 index 7026648..584cc8c 100644
78417 --- a/include/net/rtnetlink.h
78418 +++ b/include/net/rtnetlink.h
78419 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78420 const struct net_device *dev);
78421 unsigned int (*get_num_tx_queues)(void);
78422 unsigned int (*get_num_rx_queues)(void);
78423 -};
78424 +} __do_const;
78425
78426 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78427 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78428 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78429 index 2a82d13..62a31c2 100644
78430 --- a/include/net/sctp/sm.h
78431 +++ b/include/net/sctp/sm.h
78432 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78433 typedef struct {
78434 sctp_state_fn_t *fn;
78435 const char *name;
78436 -} sctp_sm_table_entry_t;
78437 +} __do_const sctp_sm_table_entry_t;
78438
78439 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78440 * currently in use.
78441 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78442 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78443
78444 /* Extern declarations for major data structures. */
78445 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78446 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78447
78448
78449 /* Get the size of a DATA chunk payload. */
78450 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78451 index e745c92..3641448 100644
78452 --- a/include/net/sctp/structs.h
78453 +++ b/include/net/sctp/structs.h
78454 @@ -516,7 +516,7 @@ struct sctp_pf {
78455 struct sctp_association *asoc);
78456 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78457 struct sctp_af *af;
78458 -};
78459 +} __do_const;
78460
78461
78462 /* Structure to track chunk fragments that have been acked, but peer
78463 diff --git a/include/net/sock.h b/include/net/sock.h
78464 index 04e148f..3b1c7e0 100644
78465 --- a/include/net/sock.h
78466 +++ b/include/net/sock.h
78467 @@ -332,7 +332,7 @@ struct sock {
78468 unsigned int sk_napi_id;
78469 unsigned int sk_ll_usec;
78470 #endif
78471 - atomic_t sk_drops;
78472 + atomic_unchecked_t sk_drops;
78473 int sk_rcvbuf;
78474
78475 struct sk_filter __rcu *sk_filter;
78476 @@ -1805,7 +1805,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78477 }
78478
78479 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78480 - char __user *from, char *to,
78481 + char __user *from, unsigned char *to,
78482 int copy, int offset)
78483 {
78484 if (skb->ip_summed == CHECKSUM_NONE) {
78485 @@ -2067,7 +2067,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78486 }
78487 }
78488
78489 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78490 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78491
78492 /**
78493 * sk_page_frag - return an appropriate page_frag
78494 diff --git a/include/net/tcp.h b/include/net/tcp.h
78495 index 46cb8a4..32b7b4a 100644
78496 --- a/include/net/tcp.h
78497 +++ b/include/net/tcp.h
78498 @@ -522,7 +522,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78499 extern void tcp_xmit_retransmit_queue(struct sock *);
78500 extern void tcp_simple_retransmit(struct sock *);
78501 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78502 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78503 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78504
78505 extern void tcp_send_probe0(struct sock *);
78506 extern void tcp_send_partial(struct sock *);
78507 @@ -695,8 +695,8 @@ struct tcp_skb_cb {
78508 struct inet6_skb_parm h6;
78509 #endif
78510 } header; /* For incoming frames */
78511 - __u32 seq; /* Starting sequence number */
78512 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78513 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78514 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78515 __u32 when; /* used to compute rtt's */
78516 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78517
78518 @@ -710,7 +710,7 @@ struct tcp_skb_cb {
78519
78520 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78521 /* 1 byte hole */
78522 - __u32 ack_seq; /* Sequence number ACK'd */
78523 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78524 };
78525
78526 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78527 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78528 index e823786..53b0608 100644
78529 --- a/include/net/xfrm.h
78530 +++ b/include/net/xfrm.h
78531 @@ -287,7 +287,6 @@ struct xfrm_dst;
78532 struct xfrm_policy_afinfo {
78533 unsigned short family;
78534 struct dst_ops *dst_ops;
78535 - void (*garbage_collect)(struct net *net);
78536 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78537 const xfrm_address_t *saddr,
78538 const xfrm_address_t *daddr);
78539 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78540 struct net_device *dev,
78541 const struct flowi *fl);
78542 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78543 -};
78544 +} __do_const;
78545
78546 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78547 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78548 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78549 int (*transport_finish)(struct sk_buff *skb,
78550 int async);
78551 void (*local_error)(struct sk_buff *skb, u32 mtu);
78552 -};
78553 +} __do_const;
78554
78555 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78556 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78557 @@ -427,7 +426,7 @@ struct xfrm_mode {
78558 struct module *owner;
78559 unsigned int encap;
78560 int flags;
78561 -};
78562 +} __do_const;
78563
78564 /* Flags for xfrm_mode. */
78565 enum {
78566 @@ -524,7 +523,7 @@ struct xfrm_policy {
78567 struct timer_list timer;
78568
78569 struct flow_cache_object flo;
78570 - atomic_t genid;
78571 + atomic_unchecked_t genid;
78572 u32 priority;
78573 u32 index;
78574 struct xfrm_mark mark;
78575 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78576 }
78577
78578 extern void xfrm_garbage_collect(struct net *net);
78579 +extern void xfrm_garbage_collect_deferred(struct net *net);
78580
78581 #else
78582
78583 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78584 static inline void xfrm_garbage_collect(struct net *net)
78585 {
78586 }
78587 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78588 +{
78589 +}
78590 #endif
78591
78592 static __inline__
78593 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78594 index 1a046b1..ee0bef0 100644
78595 --- a/include/rdma/iw_cm.h
78596 +++ b/include/rdma/iw_cm.h
78597 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78598 int backlog);
78599
78600 int (*destroy_listen)(struct iw_cm_id *cm_id);
78601 -};
78602 +} __no_const;
78603
78604 /**
78605 * iw_create_cm_id - Create an IW CM identifier.
78606 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78607 index e1379b4..67eafbe 100644
78608 --- a/include/scsi/libfc.h
78609 +++ b/include/scsi/libfc.h
78610 @@ -762,6 +762,7 @@ struct libfc_function_template {
78611 */
78612 void (*disc_stop_final) (struct fc_lport *);
78613 };
78614 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78615
78616 /**
78617 * struct fc_disc - Discovery context
78618 @@ -866,7 +867,7 @@ struct fc_lport {
78619 struct fc_vport *vport;
78620
78621 /* Operational Information */
78622 - struct libfc_function_template tt;
78623 + libfc_function_template_no_const tt;
78624 u8 link_up;
78625 u8 qfull;
78626 enum fc_lport_state state;
78627 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78628 index a44954c..5da04b2 100644
78629 --- a/include/scsi/scsi_device.h
78630 +++ b/include/scsi/scsi_device.h
78631 @@ -172,9 +172,9 @@ struct scsi_device {
78632 unsigned int max_device_blocked; /* what device_blocked counts down from */
78633 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78634
78635 - atomic_t iorequest_cnt;
78636 - atomic_t iodone_cnt;
78637 - atomic_t ioerr_cnt;
78638 + atomic_unchecked_t iorequest_cnt;
78639 + atomic_unchecked_t iodone_cnt;
78640 + atomic_unchecked_t ioerr_cnt;
78641
78642 struct device sdev_gendev,
78643 sdev_dev;
78644 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78645 index b797e8f..8e2c3aa 100644
78646 --- a/include/scsi/scsi_transport_fc.h
78647 +++ b/include/scsi/scsi_transport_fc.h
78648 @@ -751,7 +751,8 @@ struct fc_function_template {
78649 unsigned long show_host_system_hostname:1;
78650
78651 unsigned long disable_target_scan:1;
78652 -};
78653 +} __do_const;
78654 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78655
78656
78657 /**
78658 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78659 index 9031a26..750d592 100644
78660 --- a/include/sound/compress_driver.h
78661 +++ b/include/sound/compress_driver.h
78662 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78663 struct snd_compr_caps *caps);
78664 int (*get_codec_caps) (struct snd_compr_stream *stream,
78665 struct snd_compr_codec_caps *codec);
78666 -};
78667 +} __no_const;
78668
78669 /**
78670 * struct snd_compr: Compressed device
78671 diff --git a/include/sound/soc.h b/include/sound/soc.h
78672 index 6eabee7..58afb50 100644
78673 --- a/include/sound/soc.h
78674 +++ b/include/sound/soc.h
78675 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78676 /* probe ordering - for components with runtime dependencies */
78677 int probe_order;
78678 int remove_order;
78679 -};
78680 +} __do_const;
78681
78682 /* SoC platform interface */
78683 struct snd_soc_platform_driver {
78684 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78685 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78686 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78687 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78688 -};
78689 +} __do_const;
78690
78691 struct snd_soc_platform {
78692 const char *name;
78693 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78694 index e34fc90..ecefa2c 100644
78695 --- a/include/target/target_core_base.h
78696 +++ b/include/target/target_core_base.h
78697 @@ -643,7 +643,7 @@ struct se_device {
78698 spinlock_t stats_lock;
78699 /* Active commands on this virtual SE device */
78700 atomic_t simple_cmds;
78701 - atomic_t dev_ordered_id;
78702 + atomic_unchecked_t dev_ordered_id;
78703 atomic_t dev_ordered_sync;
78704 atomic_t dev_qf_count;
78705 int export_count;
78706 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78707 new file mode 100644
78708 index 0000000..fb634b7
78709 --- /dev/null
78710 +++ b/include/trace/events/fs.h
78711 @@ -0,0 +1,53 @@
78712 +#undef TRACE_SYSTEM
78713 +#define TRACE_SYSTEM fs
78714 +
78715 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78716 +#define _TRACE_FS_H
78717 +
78718 +#include <linux/fs.h>
78719 +#include <linux/tracepoint.h>
78720 +
78721 +TRACE_EVENT(do_sys_open,
78722 +
78723 + TP_PROTO(const char *filename, int flags, int mode),
78724 +
78725 + TP_ARGS(filename, flags, mode),
78726 +
78727 + TP_STRUCT__entry(
78728 + __string( filename, filename )
78729 + __field( int, flags )
78730 + __field( int, mode )
78731 + ),
78732 +
78733 + TP_fast_assign(
78734 + __assign_str(filename, filename);
78735 + __entry->flags = flags;
78736 + __entry->mode = mode;
78737 + ),
78738 +
78739 + TP_printk("\"%s\" %x %o",
78740 + __get_str(filename), __entry->flags, __entry->mode)
78741 +);
78742 +
78743 +TRACE_EVENT(open_exec,
78744 +
78745 + TP_PROTO(const char *filename),
78746 +
78747 + TP_ARGS(filename),
78748 +
78749 + TP_STRUCT__entry(
78750 + __string( filename, filename )
78751 + ),
78752 +
78753 + TP_fast_assign(
78754 + __assign_str(filename, filename);
78755 + ),
78756 +
78757 + TP_printk("\"%s\"",
78758 + __get_str(filename))
78759 +);
78760 +
78761 +#endif /* _TRACE_FS_H */
78762 +
78763 +/* This part must be outside protection */
78764 +#include <trace/define_trace.h>
78765 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78766 index 1c09820..7f5ec79 100644
78767 --- a/include/trace/events/irq.h
78768 +++ b/include/trace/events/irq.h
78769 @@ -36,7 +36,7 @@ struct softirq_action;
78770 */
78771 TRACE_EVENT(irq_handler_entry,
78772
78773 - TP_PROTO(int irq, struct irqaction *action),
78774 + TP_PROTO(int irq, const struct irqaction *action),
78775
78776 TP_ARGS(irq, action),
78777
78778 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78779 */
78780 TRACE_EVENT(irq_handler_exit,
78781
78782 - TP_PROTO(int irq, struct irqaction *action, int ret),
78783 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78784
78785 TP_ARGS(irq, action, ret),
78786
78787 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78788 index 7caf44c..23c6f27 100644
78789 --- a/include/uapi/linux/a.out.h
78790 +++ b/include/uapi/linux/a.out.h
78791 @@ -39,6 +39,14 @@ enum machine_type {
78792 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78793 };
78794
78795 +/* Constants for the N_FLAGS field */
78796 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78797 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78798 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78799 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78800 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78801 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78802 +
78803 #if !defined (N_MAGIC)
78804 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78805 #endif
78806 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78807 index d876736..ccce5c0 100644
78808 --- a/include/uapi/linux/byteorder/little_endian.h
78809 +++ b/include/uapi/linux/byteorder/little_endian.h
78810 @@ -42,51 +42,51 @@
78811
78812 static inline __le64 __cpu_to_le64p(const __u64 *p)
78813 {
78814 - return (__force __le64)*p;
78815 + return (__force const __le64)*p;
78816 }
78817 -static inline __u64 __le64_to_cpup(const __le64 *p)
78818 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78819 {
78820 - return (__force __u64)*p;
78821 + return (__force const __u64)*p;
78822 }
78823 static inline __le32 __cpu_to_le32p(const __u32 *p)
78824 {
78825 - return (__force __le32)*p;
78826 + return (__force const __le32)*p;
78827 }
78828 static inline __u32 __le32_to_cpup(const __le32 *p)
78829 {
78830 - return (__force __u32)*p;
78831 + return (__force const __u32)*p;
78832 }
78833 static inline __le16 __cpu_to_le16p(const __u16 *p)
78834 {
78835 - return (__force __le16)*p;
78836 + return (__force const __le16)*p;
78837 }
78838 static inline __u16 __le16_to_cpup(const __le16 *p)
78839 {
78840 - return (__force __u16)*p;
78841 + return (__force const __u16)*p;
78842 }
78843 static inline __be64 __cpu_to_be64p(const __u64 *p)
78844 {
78845 - return (__force __be64)__swab64p(p);
78846 + return (__force const __be64)__swab64p(p);
78847 }
78848 static inline __u64 __be64_to_cpup(const __be64 *p)
78849 {
78850 - return __swab64p((__u64 *)p);
78851 + return __swab64p((const __u64 *)p);
78852 }
78853 static inline __be32 __cpu_to_be32p(const __u32 *p)
78854 {
78855 - return (__force __be32)__swab32p(p);
78856 + return (__force const __be32)__swab32p(p);
78857 }
78858 -static inline __u32 __be32_to_cpup(const __be32 *p)
78859 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78860 {
78861 - return __swab32p((__u32 *)p);
78862 + return __swab32p((const __u32 *)p);
78863 }
78864 static inline __be16 __cpu_to_be16p(const __u16 *p)
78865 {
78866 - return (__force __be16)__swab16p(p);
78867 + return (__force const __be16)__swab16p(p);
78868 }
78869 static inline __u16 __be16_to_cpup(const __be16 *p)
78870 {
78871 - return __swab16p((__u16 *)p);
78872 + return __swab16p((const __u16 *)p);
78873 }
78874 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78875 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78876 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78877 index ef6103b..d4e65dd 100644
78878 --- a/include/uapi/linux/elf.h
78879 +++ b/include/uapi/linux/elf.h
78880 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78881 #define PT_GNU_EH_FRAME 0x6474e550
78882
78883 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78884 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78885 +
78886 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78887 +
78888 +/* Constants for the e_flags field */
78889 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78890 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78891 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78892 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78893 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78894 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78895
78896 /*
78897 * Extended Numbering
78898 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78899 #define DT_DEBUG 21
78900 #define DT_TEXTREL 22
78901 #define DT_JMPREL 23
78902 +#define DT_FLAGS 30
78903 + #define DF_TEXTREL 0x00000004
78904 #define DT_ENCODING 32
78905 #define OLD_DT_LOOS 0x60000000
78906 #define DT_LOOS 0x6000000d
78907 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78908 #define PF_W 0x2
78909 #define PF_X 0x1
78910
78911 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78912 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78913 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78914 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78915 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78916 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78917 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78918 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78919 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78920 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78921 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78922 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78923 +
78924 typedef struct elf32_phdr{
78925 Elf32_Word p_type;
78926 Elf32_Off p_offset;
78927 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78928 #define EI_OSABI 7
78929 #define EI_PAD 8
78930
78931 +#define EI_PAX 14
78932 +
78933 #define ELFMAG0 0x7f /* EI_MAG */
78934 #define ELFMAG1 'E'
78935 #define ELFMAG2 'L'
78936 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78937 index aa169c4..6a2771d 100644
78938 --- a/include/uapi/linux/personality.h
78939 +++ b/include/uapi/linux/personality.h
78940 @@ -30,6 +30,7 @@ enum {
78941 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78942 ADDR_NO_RANDOMIZE | \
78943 ADDR_COMPAT_LAYOUT | \
78944 + ADDR_LIMIT_3GB | \
78945 MMAP_PAGE_ZERO)
78946
78947 /*
78948 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78949 index 7530e74..e714828 100644
78950 --- a/include/uapi/linux/screen_info.h
78951 +++ b/include/uapi/linux/screen_info.h
78952 @@ -43,7 +43,8 @@ struct screen_info {
78953 __u16 pages; /* 0x32 */
78954 __u16 vesa_attributes; /* 0x34 */
78955 __u32 capabilities; /* 0x36 */
78956 - __u8 _reserved[6]; /* 0x3a */
78957 + __u16 vesapm_size; /* 0x3a */
78958 + __u8 _reserved[4]; /* 0x3c */
78959 } __attribute__((packed));
78960
78961 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78962 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78963 index 0e011eb..82681b1 100644
78964 --- a/include/uapi/linux/swab.h
78965 +++ b/include/uapi/linux/swab.h
78966 @@ -43,7 +43,7 @@
78967 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78968 */
78969
78970 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78971 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78972 {
78973 #ifdef __HAVE_BUILTIN_BSWAP16__
78974 return __builtin_bswap16(val);
78975 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78976 #endif
78977 }
78978
78979 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78980 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78981 {
78982 #ifdef __HAVE_BUILTIN_BSWAP32__
78983 return __builtin_bswap32(val);
78984 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78985 #endif
78986 }
78987
78988 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78989 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78990 {
78991 #ifdef __HAVE_BUILTIN_BSWAP64__
78992 return __builtin_bswap64(val);
78993 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78994 index 6d67213..8dab561 100644
78995 --- a/include/uapi/linux/sysctl.h
78996 +++ b/include/uapi/linux/sysctl.h
78997 @@ -155,7 +155,11 @@ enum
78998 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78999 };
79000
79001 -
79002 +#ifdef CONFIG_PAX_SOFTMODE
79003 +enum {
79004 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
79005 +};
79006 +#endif
79007
79008 /* CTL_VM names: */
79009 enum
79010 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
79011 index e4629b9..6958086 100644
79012 --- a/include/uapi/linux/xattr.h
79013 +++ b/include/uapi/linux/xattr.h
79014 @@ -63,5 +63,9 @@
79015 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
79016 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
79017
79018 +/* User namespace */
79019 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
79020 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
79021 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
79022
79023 #endif /* _UAPI_LINUX_XATTR_H */
79024 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
79025 index f9466fa..f4e2b81 100644
79026 --- a/include/video/udlfb.h
79027 +++ b/include/video/udlfb.h
79028 @@ -53,10 +53,10 @@ struct dlfb_data {
79029 u32 pseudo_palette[256];
79030 int blank_mode; /*one of FB_BLANK_ */
79031 /* blit-only rendering path metrics, exposed through sysfs */
79032 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79033 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
79034 - atomic_t bytes_sent; /* to usb, after compression including overhead */
79035 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
79036 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79037 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
79038 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
79039 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
79040 };
79041
79042 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
79043 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
79044 index 30f5362..8ed8ac9 100644
79045 --- a/include/video/uvesafb.h
79046 +++ b/include/video/uvesafb.h
79047 @@ -122,6 +122,7 @@ struct uvesafb_par {
79048 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
79049 u8 pmi_setpal; /* PMI for palette changes */
79050 u16 *pmi_base; /* protected mode interface location */
79051 + u8 *pmi_code; /* protected mode code location */
79052 void *pmi_start;
79053 void *pmi_pal;
79054 u8 *vbe_state_orig; /*
79055 diff --git a/init/Kconfig b/init/Kconfig
79056 index fed81b5..0d3b964 100644
79057 --- a/init/Kconfig
79058 +++ b/init/Kconfig
79059 @@ -1069,6 +1069,7 @@ endif # CGROUPS
79060
79061 config CHECKPOINT_RESTORE
79062 bool "Checkpoint/restore support" if EXPERT
79063 + depends on !GRKERNSEC
79064 default n
79065 help
79066 Enables additional kernel features in a sake of checkpoint/restore.
79067 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
79068
79069 config COMPAT_BRK
79070 bool "Disable heap randomization"
79071 - default y
79072 + default n
79073 help
79074 Randomizing heap placement makes heap exploits harder, but it
79075 also breaks ancient binaries (including anything libc5 based).
79076 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
79077 config STOP_MACHINE
79078 bool
79079 default y
79080 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
79081 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
79082 help
79083 Need stop_machine() primitive.
79084
79085 diff --git a/init/Makefile b/init/Makefile
79086 index 7bc47ee..6da2dc7 100644
79087 --- a/init/Makefile
79088 +++ b/init/Makefile
79089 @@ -2,6 +2,9 @@
79090 # Makefile for the linux kernel.
79091 #
79092
79093 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
79094 +asflags-y := $(GCC_PLUGINS_AFLAGS)
79095 +
79096 obj-y := main.o version.o mounts.o
79097 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
79098 obj-y += noinitramfs.o
79099 diff --git a/init/do_mounts.c b/init/do_mounts.c
79100 index 816014c..c2054db 100644
79101 --- a/init/do_mounts.c
79102 +++ b/init/do_mounts.c
79103 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
79104 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
79105 {
79106 struct super_block *s;
79107 - int err = sys_mount(name, "/root", fs, flags, data);
79108 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
79109 if (err)
79110 return err;
79111
79112 - sys_chdir("/root");
79113 + sys_chdir((const char __force_user *)"/root");
79114 s = current->fs->pwd.dentry->d_sb;
79115 ROOT_DEV = s->s_dev;
79116 printk(KERN_INFO
79117 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
79118 va_start(args, fmt);
79119 vsprintf(buf, fmt, args);
79120 va_end(args);
79121 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
79122 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
79123 if (fd >= 0) {
79124 sys_ioctl(fd, FDEJECT, 0);
79125 sys_close(fd);
79126 }
79127 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
79128 - fd = sys_open("/dev/console", O_RDWR, 0);
79129 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
79130 if (fd >= 0) {
79131 sys_ioctl(fd, TCGETS, (long)&termios);
79132 termios.c_lflag &= ~ICANON;
79133 sys_ioctl(fd, TCSETSF, (long)&termios);
79134 - sys_read(fd, &c, 1);
79135 + sys_read(fd, (char __user *)&c, 1);
79136 termios.c_lflag |= ICANON;
79137 sys_ioctl(fd, TCSETSF, (long)&termios);
79138 sys_close(fd);
79139 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
79140 mount_root();
79141 out:
79142 devtmpfs_mount("dev");
79143 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79144 - sys_chroot(".");
79145 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79146 + sys_chroot((const char __force_user *)".");
79147 }
79148 diff --git a/init/do_mounts.h b/init/do_mounts.h
79149 index f5b978a..69dbfe8 100644
79150 --- a/init/do_mounts.h
79151 +++ b/init/do_mounts.h
79152 @@ -15,15 +15,15 @@ extern int root_mountflags;
79153
79154 static inline int create_dev(char *name, dev_t dev)
79155 {
79156 - sys_unlink(name);
79157 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
79158 + sys_unlink((char __force_user *)name);
79159 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
79160 }
79161
79162 #if BITS_PER_LONG == 32
79163 static inline u32 bstat(char *name)
79164 {
79165 struct stat64 stat;
79166 - if (sys_stat64(name, &stat) != 0)
79167 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
79168 return 0;
79169 if (!S_ISBLK(stat.st_mode))
79170 return 0;
79171 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
79172 static inline u32 bstat(char *name)
79173 {
79174 struct stat stat;
79175 - if (sys_newstat(name, &stat) != 0)
79176 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
79177 return 0;
79178 if (!S_ISBLK(stat.st_mode))
79179 return 0;
79180 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
79181 index 3e0878e..8a9d7a0 100644
79182 --- a/init/do_mounts_initrd.c
79183 +++ b/init/do_mounts_initrd.c
79184 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
79185 {
79186 sys_unshare(CLONE_FS | CLONE_FILES);
79187 /* stdin/stdout/stderr for /linuxrc */
79188 - sys_open("/dev/console", O_RDWR, 0);
79189 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
79190 sys_dup(0);
79191 sys_dup(0);
79192 /* move initrd over / and chdir/chroot in initrd root */
79193 - sys_chdir("/root");
79194 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79195 - sys_chroot(".");
79196 + sys_chdir((const char __force_user *)"/root");
79197 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79198 + sys_chroot((const char __force_user *)".");
79199 sys_setsid();
79200 return 0;
79201 }
79202 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
79203 create_dev("/dev/root.old", Root_RAM0);
79204 /* mount initrd on rootfs' /root */
79205 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
79206 - sys_mkdir("/old", 0700);
79207 - sys_chdir("/old");
79208 + sys_mkdir((const char __force_user *)"/old", 0700);
79209 + sys_chdir((const char __force_user *)"/old");
79210
79211 /* try loading default modules from initrd */
79212 load_default_modules();
79213 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
79214 current->flags &= ~PF_FREEZER_SKIP;
79215
79216 /* move initrd to rootfs' /old */
79217 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
79218 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
79219 /* switch root and cwd back to / of rootfs */
79220 - sys_chroot("..");
79221 + sys_chroot((const char __force_user *)"..");
79222
79223 if (new_decode_dev(real_root_dev) == Root_RAM0) {
79224 - sys_chdir("/old");
79225 + sys_chdir((const char __force_user *)"/old");
79226 return;
79227 }
79228
79229 - sys_chdir("/");
79230 + sys_chdir((const char __force_user *)"/");
79231 ROOT_DEV = new_decode_dev(real_root_dev);
79232 mount_root();
79233
79234 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
79235 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
79236 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
79237 if (!error)
79238 printk("okay\n");
79239 else {
79240 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
79241 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
79242 if (error == -ENOENT)
79243 printk("/initrd does not exist. Ignored.\n");
79244 else
79245 printk("failed\n");
79246 printk(KERN_NOTICE "Unmounting old root\n");
79247 - sys_umount("/old", MNT_DETACH);
79248 + sys_umount((char __force_user *)"/old", MNT_DETACH);
79249 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
79250 if (fd < 0) {
79251 error = fd;
79252 @@ -127,11 +127,11 @@ int __init initrd_load(void)
79253 * mounted in the normal path.
79254 */
79255 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
79256 - sys_unlink("/initrd.image");
79257 + sys_unlink((const char __force_user *)"/initrd.image");
79258 handle_initrd();
79259 return 1;
79260 }
79261 }
79262 - sys_unlink("/initrd.image");
79263 + sys_unlink((const char __force_user *)"/initrd.image");
79264 return 0;
79265 }
79266 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
79267 index 8cb6db5..d729f50 100644
79268 --- a/init/do_mounts_md.c
79269 +++ b/init/do_mounts_md.c
79270 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
79271 partitioned ? "_d" : "", minor,
79272 md_setup_args[ent].device_names);
79273
79274 - fd = sys_open(name, 0, 0);
79275 + fd = sys_open((char __force_user *)name, 0, 0);
79276 if (fd < 0) {
79277 printk(KERN_ERR "md: open failed - cannot start "
79278 "array %s\n", name);
79279 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
79280 * array without it
79281 */
79282 sys_close(fd);
79283 - fd = sys_open(name, 0, 0);
79284 + fd = sys_open((char __force_user *)name, 0, 0);
79285 sys_ioctl(fd, BLKRRPART, 0);
79286 }
79287 sys_close(fd);
79288 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
79289
79290 wait_for_device_probe();
79291
79292 - fd = sys_open("/dev/md0", 0, 0);
79293 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
79294 if (fd >= 0) {
79295 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
79296 sys_close(fd);
79297 diff --git a/init/init_task.c b/init/init_task.c
79298 index ba0a7f36..2bcf1d5 100644
79299 --- a/init/init_task.c
79300 +++ b/init/init_task.c
79301 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
79302 * Initial thread structure. Alignment of this is handled by a special
79303 * linker map entry.
79304 */
79305 +#ifdef CONFIG_X86
79306 +union thread_union init_thread_union __init_task_data;
79307 +#else
79308 union thread_union init_thread_union __init_task_data =
79309 { INIT_THREAD_INFO(init_task) };
79310 +#endif
79311 diff --git a/init/initramfs.c b/init/initramfs.c
79312 index a67ef9d..2d17ed9 100644
79313 --- a/init/initramfs.c
79314 +++ b/init/initramfs.c
79315 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79316 }
79317 }
79318
79319 -static long __init do_utime(char *filename, time_t mtime)
79320 +static long __init do_utime(char __force_user *filename, time_t mtime)
79321 {
79322 struct timespec t[2];
79323
79324 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79325 struct dir_entry *de, *tmp;
79326 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79327 list_del(&de->list);
79328 - do_utime(de->name, de->mtime);
79329 + do_utime((char __force_user *)de->name, de->mtime);
79330 kfree(de->name);
79331 kfree(de);
79332 }
79333 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79334 if (nlink >= 2) {
79335 char *old = find_link(major, minor, ino, mode, collected);
79336 if (old)
79337 - return (sys_link(old, collected) < 0) ? -1 : 1;
79338 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79339 }
79340 return 0;
79341 }
79342 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79343 {
79344 struct stat st;
79345
79346 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79347 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79348 if (S_ISDIR(st.st_mode))
79349 - sys_rmdir(path);
79350 + sys_rmdir((char __force_user *)path);
79351 else
79352 - sys_unlink(path);
79353 + sys_unlink((char __force_user *)path);
79354 }
79355 }
79356
79357 @@ -315,7 +315,7 @@ static int __init do_name(void)
79358 int openflags = O_WRONLY|O_CREAT;
79359 if (ml != 1)
79360 openflags |= O_TRUNC;
79361 - wfd = sys_open(collected, openflags, mode);
79362 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79363
79364 if (wfd >= 0) {
79365 sys_fchown(wfd, uid, gid);
79366 @@ -327,17 +327,17 @@ static int __init do_name(void)
79367 }
79368 }
79369 } else if (S_ISDIR(mode)) {
79370 - sys_mkdir(collected, mode);
79371 - sys_chown(collected, uid, gid);
79372 - sys_chmod(collected, mode);
79373 + sys_mkdir((char __force_user *)collected, mode);
79374 + sys_chown((char __force_user *)collected, uid, gid);
79375 + sys_chmod((char __force_user *)collected, mode);
79376 dir_add(collected, mtime);
79377 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79378 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79379 if (maybe_link() == 0) {
79380 - sys_mknod(collected, mode, rdev);
79381 - sys_chown(collected, uid, gid);
79382 - sys_chmod(collected, mode);
79383 - do_utime(collected, mtime);
79384 + sys_mknod((char __force_user *)collected, mode, rdev);
79385 + sys_chown((char __force_user *)collected, uid, gid);
79386 + sys_chmod((char __force_user *)collected, mode);
79387 + do_utime((char __force_user *)collected, mtime);
79388 }
79389 }
79390 return 0;
79391 @@ -346,15 +346,15 @@ static int __init do_name(void)
79392 static int __init do_copy(void)
79393 {
79394 if (count >= body_len) {
79395 - sys_write(wfd, victim, body_len);
79396 + sys_write(wfd, (char __force_user *)victim, body_len);
79397 sys_close(wfd);
79398 - do_utime(vcollected, mtime);
79399 + do_utime((char __force_user *)vcollected, mtime);
79400 kfree(vcollected);
79401 eat(body_len);
79402 state = SkipIt;
79403 return 0;
79404 } else {
79405 - sys_write(wfd, victim, count);
79406 + sys_write(wfd, (char __force_user *)victim, count);
79407 body_len -= count;
79408 eat(count);
79409 return 1;
79410 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79411 {
79412 collected[N_ALIGN(name_len) + body_len] = '\0';
79413 clean_path(collected, 0);
79414 - sys_symlink(collected + N_ALIGN(name_len), collected);
79415 - sys_lchown(collected, uid, gid);
79416 - do_utime(collected, mtime);
79417 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79418 + sys_lchown((char __force_user *)collected, uid, gid);
79419 + do_utime((char __force_user *)collected, mtime);
79420 state = SkipIt;
79421 next_state = Reset;
79422 return 0;
79423 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79424 {
79425 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79426 if (err)
79427 - panic(err); /* Failed to decompress INTERNAL initramfs */
79428 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79429 if (initrd_start) {
79430 #ifdef CONFIG_BLK_DEV_RAM
79431 int fd;
79432 diff --git a/init/main.c b/init/main.c
79433 index 586cd33..c054108 100644
79434 --- a/init/main.c
79435 +++ b/init/main.c
79436 @@ -102,6 +102,8 @@ static inline void mark_rodata_ro(void) { }
79437 extern void tc_init(void);
79438 #endif
79439
79440 +extern void grsecurity_init(void);
79441 +
79442 /*
79443 * Debug helper: via this flag we know that we are in 'early bootup code'
79444 * where only the boot processor is running with IRQ disabled. This means
79445 @@ -155,6 +157,74 @@ static int __init set_reset_devices(char *str)
79446
79447 __setup("reset_devices", set_reset_devices);
79448
79449 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79450 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79451 +static int __init setup_grsec_proc_gid(char *str)
79452 +{
79453 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79454 + return 1;
79455 +}
79456 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79457 +#endif
79458 +
79459 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79460 +unsigned long pax_user_shadow_base __read_only;
79461 +EXPORT_SYMBOL(pax_user_shadow_base);
79462 +extern char pax_enter_kernel_user[];
79463 +extern char pax_exit_kernel_user[];
79464 +#endif
79465 +
79466 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79467 +static int __init setup_pax_nouderef(char *str)
79468 +{
79469 +#ifdef CONFIG_X86_32
79470 + unsigned int cpu;
79471 + struct desc_struct *gdt;
79472 +
79473 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79474 + gdt = get_cpu_gdt_table(cpu);
79475 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79476 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79477 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79478 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79479 + }
79480 + loadsegment(ds, __KERNEL_DS);
79481 + loadsegment(es, __KERNEL_DS);
79482 + loadsegment(ss, __KERNEL_DS);
79483 +#else
79484 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79485 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79486 + clone_pgd_mask = ~(pgdval_t)0UL;
79487 + pax_user_shadow_base = 0UL;
79488 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79489 +#endif
79490 +
79491 + return 0;
79492 +}
79493 +early_param("pax_nouderef", setup_pax_nouderef);
79494 +
79495 +#ifdef CONFIG_X86_64
79496 +static int __init setup_pax_weakuderef(char *str)
79497 +{
79498 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79499 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79500 + return 1;
79501 +}
79502 +__setup("pax_weakuderef", setup_pax_weakuderef);
79503 +#endif
79504 +#endif
79505 +
79506 +#ifdef CONFIG_PAX_SOFTMODE
79507 +int pax_softmode;
79508 +
79509 +static int __init setup_pax_softmode(char *str)
79510 +{
79511 + get_option(&str, &pax_softmode);
79512 + return 1;
79513 +}
79514 +__setup("pax_softmode=", setup_pax_softmode);
79515 +#endif
79516 +
79517 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79518 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79519 static const char *panic_later, *panic_param;
79520 @@ -680,25 +750,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79521 {
79522 int count = preempt_count();
79523 int ret;
79524 - char msgbuf[64];
79525 + const char *msg1 = "", *msg2 = "";
79526
79527 if (initcall_debug)
79528 ret = do_one_initcall_debug(fn);
79529 else
79530 ret = fn();
79531
79532 - msgbuf[0] = 0;
79533 -
79534 if (preempt_count() != count) {
79535 - sprintf(msgbuf, "preemption imbalance ");
79536 + msg1 = " preemption imbalance";
79537 preempt_count() = count;
79538 }
79539 if (irqs_disabled()) {
79540 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79541 + msg2 = " disabled interrupts";
79542 local_irq_enable();
79543 }
79544 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79545 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79546
79547 + add_latent_entropy();
79548 return ret;
79549 }
79550
79551 @@ -805,10 +874,14 @@ static int run_init_process(const char *init_filename)
79552 {
79553 argv_init[0] = init_filename;
79554 return do_execve(init_filename,
79555 - (const char __user *const __user *)argv_init,
79556 - (const char __user *const __user *)envp_init);
79557 + (const char __user *const __force_user *)argv_init,
79558 + (const char __user *const __force_user *)envp_init);
79559 }
79560
79561 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
79562 +extern int gr_init_ran;
79563 +#endif
79564 +
79565 static noinline void __init kernel_init_freeable(void);
79566
79567 static int __ref kernel_init(void *unused)
79568 @@ -829,6 +902,11 @@ static int __ref kernel_init(void *unused)
79569 pr_err("Failed to execute %s\n", ramdisk_execute_command);
79570 }
79571
79572 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
79573 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
79574 + gr_init_ran = 1;
79575 +#endif
79576 +
79577 /*
79578 * We try each of these until one succeeds.
79579 *
79580 @@ -883,7 +961,7 @@ static noinline void __init kernel_init_freeable(void)
79581 do_basic_setup();
79582
79583 /* Open the /dev/console on the rootfs, this should never fail */
79584 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79585 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79586 pr_err("Warning: unable to open an initial console.\n");
79587
79588 (void) sys_dup(0);
79589 @@ -896,11 +974,13 @@ static noinline void __init kernel_init_freeable(void)
79590 if (!ramdisk_execute_command)
79591 ramdisk_execute_command = "/init";
79592
79593 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79594 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79595 ramdisk_execute_command = NULL;
79596 prepare_namespace();
79597 }
79598
79599 + grsecurity_init();
79600 +
79601 /*
79602 * Ok, we have completed the initial bootup, and
79603 * we're essentially up and running. Get rid of the
79604 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79605 index 130dfec..cc88451 100644
79606 --- a/ipc/ipc_sysctl.c
79607 +++ b/ipc/ipc_sysctl.c
79608 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79609 static int proc_ipc_dointvec(ctl_table *table, int write,
79610 void __user *buffer, size_t *lenp, loff_t *ppos)
79611 {
79612 - struct ctl_table ipc_table;
79613 + ctl_table_no_const ipc_table;
79614
79615 memcpy(&ipc_table, table, sizeof(ipc_table));
79616 ipc_table.data = get_ipc(table);
79617 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79618 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79619 void __user *buffer, size_t *lenp, loff_t *ppos)
79620 {
79621 - struct ctl_table ipc_table;
79622 + ctl_table_no_const ipc_table;
79623
79624 memcpy(&ipc_table, table, sizeof(ipc_table));
79625 ipc_table.data = get_ipc(table);
79626 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79627 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79628 void __user *buffer, size_t *lenp, loff_t *ppos)
79629 {
79630 - struct ctl_table ipc_table;
79631 + ctl_table_no_const ipc_table;
79632 size_t lenp_bef = *lenp;
79633 int rc;
79634
79635 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79636 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79637 void __user *buffer, size_t *lenp, loff_t *ppos)
79638 {
79639 - struct ctl_table ipc_table;
79640 + ctl_table_no_const ipc_table;
79641 memcpy(&ipc_table, table, sizeof(ipc_table));
79642 ipc_table.data = get_ipc(table);
79643
79644 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79645 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79646 void __user *buffer, size_t *lenp, loff_t *ppos)
79647 {
79648 - struct ctl_table ipc_table;
79649 + ctl_table_no_const ipc_table;
79650 size_t lenp_bef = *lenp;
79651 int oldval;
79652 int rc;
79653 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79654 index 383d638..943fdbb 100644
79655 --- a/ipc/mq_sysctl.c
79656 +++ b/ipc/mq_sysctl.c
79657 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79658 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79659 void __user *buffer, size_t *lenp, loff_t *ppos)
79660 {
79661 - struct ctl_table mq_table;
79662 + ctl_table_no_const mq_table;
79663 memcpy(&mq_table, table, sizeof(mq_table));
79664 mq_table.data = get_mq(table);
79665
79666 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79667 index ae1996d..a35f2cc 100644
79668 --- a/ipc/mqueue.c
79669 +++ b/ipc/mqueue.c
79670 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79671 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79672 info->attr.mq_msgsize);
79673
79674 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79675 spin_lock(&mq_lock);
79676 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79677 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79678 diff --git a/ipc/msg.c b/ipc/msg.c
79679 index 558aa91..359e718 100644
79680 --- a/ipc/msg.c
79681 +++ b/ipc/msg.c
79682 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79683 return security_msg_queue_associate(msq, msgflg);
79684 }
79685
79686 +static struct ipc_ops msg_ops = {
79687 + .getnew = newque,
79688 + .associate = msg_security,
79689 + .more_checks = NULL
79690 +};
79691 +
79692 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79693 {
79694 struct ipc_namespace *ns;
79695 - struct ipc_ops msg_ops;
79696 struct ipc_params msg_params;
79697
79698 ns = current->nsproxy->ipc_ns;
79699
79700 - msg_ops.getnew = newque;
79701 - msg_ops.associate = msg_security;
79702 - msg_ops.more_checks = NULL;
79703 -
79704 msg_params.key = key;
79705 msg_params.flg = msgflg;
79706
79707 diff --git a/ipc/sem.c b/ipc/sem.c
79708 index 8e2bf30..a711151 100644
79709 --- a/ipc/sem.c
79710 +++ b/ipc/sem.c
79711 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79712 return 0;
79713 }
79714
79715 +static struct ipc_ops sem_ops = {
79716 + .getnew = newary,
79717 + .associate = sem_security,
79718 + .more_checks = sem_more_checks
79719 +};
79720 +
79721 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79722 {
79723 struct ipc_namespace *ns;
79724 - struct ipc_ops sem_ops;
79725 struct ipc_params sem_params;
79726
79727 ns = current->nsproxy->ipc_ns;
79728 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79729 if (nsems < 0 || nsems > ns->sc_semmsl)
79730 return -EINVAL;
79731
79732 - sem_ops.getnew = newary;
79733 - sem_ops.associate = sem_security;
79734 - sem_ops.more_checks = sem_more_checks;
79735 -
79736 sem_params.key = key;
79737 sem_params.flg = semflg;
79738 sem_params.u.nsems = nsems;
79739 diff --git a/ipc/shm.c b/ipc/shm.c
79740 index d697396..40e887d 100644
79741 --- a/ipc/shm.c
79742 +++ b/ipc/shm.c
79743 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79744 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79745 #endif
79746
79747 +#ifdef CONFIG_GRKERNSEC
79748 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79749 + const time_t shm_createtime, const kuid_t cuid,
79750 + const int shmid);
79751 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79752 + const time_t shm_createtime);
79753 +#endif
79754 +
79755 void shm_init_ns(struct ipc_namespace *ns)
79756 {
79757 ns->shm_ctlmax = SHMMAX;
79758 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79759 shp->shm_lprid = 0;
79760 shp->shm_atim = shp->shm_dtim = 0;
79761 shp->shm_ctim = get_seconds();
79762 +#ifdef CONFIG_GRKERNSEC
79763 + {
79764 + struct timespec timeval;
79765 + do_posix_clock_monotonic_gettime(&timeval);
79766 +
79767 + shp->shm_createtime = timeval.tv_sec;
79768 + }
79769 +#endif
79770 shp->shm_segsz = size;
79771 shp->shm_nattch = 0;
79772 shp->shm_file = file;
79773 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79774 return 0;
79775 }
79776
79777 +static struct ipc_ops shm_ops = {
79778 + .getnew = newseg,
79779 + .associate = shm_security,
79780 + .more_checks = shm_more_checks
79781 +};
79782 +
79783 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79784 {
79785 struct ipc_namespace *ns;
79786 - struct ipc_ops shm_ops;
79787 struct ipc_params shm_params;
79788
79789 ns = current->nsproxy->ipc_ns;
79790
79791 - shm_ops.getnew = newseg;
79792 - shm_ops.associate = shm_security;
79793 - shm_ops.more_checks = shm_more_checks;
79794 -
79795 shm_params.key = key;
79796 shm_params.flg = shmflg;
79797 shm_params.u.size = size;
79798 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79799 f_mode = FMODE_READ | FMODE_WRITE;
79800 }
79801 if (shmflg & SHM_EXEC) {
79802 +
79803 +#ifdef CONFIG_PAX_MPROTECT
79804 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79805 + goto out;
79806 +#endif
79807 +
79808 prot |= PROT_EXEC;
79809 acc_mode |= S_IXUGO;
79810 }
79811 @@ -1100,10 +1123,22 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79812 if (err)
79813 goto out_unlock;
79814
79815 +#ifdef CONFIG_GRKERNSEC
79816 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79817 + shp->shm_perm.cuid, shmid) ||
79818 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79819 + err = -EACCES;
79820 + goto out_unlock;
79821 + }
79822 +#endif
79823 +
79824 ipc_lock_object(&shp->shm_perm);
79825 path = shp->shm_file->f_path;
79826 path_get(&path);
79827 shp->shm_nattch++;
79828 +#ifdef CONFIG_GRKERNSEC
79829 + shp->shm_lapid = current->pid;
79830 +#endif
79831 size = i_size_read(path.dentry->d_inode);
79832 ipc_unlock_object(&shp->shm_perm);
79833 rcu_read_unlock();
79834 diff --git a/ipc/util.c b/ipc/util.c
79835 index fdb8ae7..f1cb373 100644
79836 --- a/ipc/util.c
79837 +++ b/ipc/util.c
79838 @@ -56,6 +56,8 @@ struct ipc_proc_iface {
79839 int (*show)(struct seq_file *, void *);
79840 };
79841
79842 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
79843 +
79844 static void ipc_memory_notifier(struct work_struct *work)
79845 {
79846 ipcns_notify(IPCNS_MEMCHANGED);
79847 @@ -545,6 +547,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
79848 granted_mode >>= 6;
79849 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
79850 granted_mode >>= 3;
79851 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
79852 + return -1;
79853 +
79854 /* is there some bit set in requested_mode but not in granted_mode? */
79855 if ((requested_mode & ~granted_mode & 0007) &&
79856 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
79857 diff --git a/kernel/acct.c b/kernel/acct.c
79858 index 8d6e145..33e0b1e 100644
79859 --- a/kernel/acct.c
79860 +++ b/kernel/acct.c
79861 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79862 */
79863 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79864 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79865 - file->f_op->write(file, (char *)&ac,
79866 + file->f_op->write(file, (char __force_user *)&ac,
79867 sizeof(acct_t), &file->f_pos);
79868 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79869 set_fs(fs);
79870 diff --git a/kernel/audit.c b/kernel/audit.c
79871 index 7b0e23a..f4d172f 100644
79872 --- a/kernel/audit.c
79873 +++ b/kernel/audit.c
79874 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79875 3) suppressed due to audit_rate_limit
79876 4) suppressed due to audit_backlog_limit
79877 */
79878 -static atomic_t audit_lost = ATOMIC_INIT(0);
79879 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79880
79881 /* The netlink socket. */
79882 static struct sock *audit_sock;
79883 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79884 unsigned long now;
79885 int print;
79886
79887 - atomic_inc(&audit_lost);
79888 + atomic_inc_unchecked(&audit_lost);
79889
79890 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79891
79892 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79893 printk(KERN_WARNING
79894 "audit: audit_lost=%d audit_rate_limit=%d "
79895 "audit_backlog_limit=%d\n",
79896 - atomic_read(&audit_lost),
79897 + atomic_read_unchecked(&audit_lost),
79898 audit_rate_limit,
79899 audit_backlog_limit);
79900 audit_panic(message);
79901 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79902
79903 switch (msg_type) {
79904 case AUDIT_GET:
79905 + status_set.mask = 0;
79906 status_set.enabled = audit_enabled;
79907 status_set.failure = audit_failure;
79908 status_set.pid = audit_pid;
79909 status_set.rate_limit = audit_rate_limit;
79910 status_set.backlog_limit = audit_backlog_limit;
79911 - status_set.lost = atomic_read(&audit_lost);
79912 + status_set.lost = atomic_read_unchecked(&audit_lost);
79913 status_set.backlog = skb_queue_len(&audit_skb_queue);
79914 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79915 &status_set, sizeof(status_set));
79916 break;
79917 case AUDIT_SET:
79918 - if (nlh->nlmsg_len < sizeof(struct audit_status))
79919 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
79920 return -EINVAL;
79921 status_get = (struct audit_status *)data;
79922 if (status_get->mask & AUDIT_STATUS_ENABLED) {
79923 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79924
79925 memset(&s, 0, sizeof(s));
79926 /* guard against past and future API changes */
79927 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
79928 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
79929 if ((s.enabled != 0 && s.enabled != 1) ||
79930 (s.log_passwd != 0 && s.log_passwd != 1))
79931 return -EINVAL;
79932 @@ -1251,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
79933 int i, avail, new_len;
79934 unsigned char *ptr;
79935 struct sk_buff *skb;
79936 - static const unsigned char *hex = "0123456789ABCDEF";
79937 + static const unsigned char hex[] = "0123456789ABCDEF";
79938
79939 if (!ab)
79940 return;
79941 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79942 index 9845cb3..3ec9369 100644
79943 --- a/kernel/auditsc.c
79944 +++ b/kernel/auditsc.c
79945 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79946 }
79947
79948 /* global counter which is incremented every time something logs in */
79949 -static atomic_t session_id = ATOMIC_INIT(0);
79950 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79951
79952 /**
79953 * audit_set_loginuid - set current task's audit_context loginuid
79954 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79955 return -EPERM;
79956 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79957
79958 - sessionid = atomic_inc_return(&session_id);
79959 + sessionid = atomic_inc_return_unchecked(&session_id);
79960 if (context && context->in_syscall) {
79961 struct audit_buffer *ab;
79962
79963 diff --git a/kernel/capability.c b/kernel/capability.c
79964 index f6c2ce5..982c0f9 100644
79965 --- a/kernel/capability.c
79966 +++ b/kernel/capability.c
79967 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79968 * before modification is attempted and the application
79969 * fails.
79970 */
79971 + if (tocopy > ARRAY_SIZE(kdata))
79972 + return -EFAULT;
79973 +
79974 if (copy_to_user(dataptr, kdata, tocopy
79975 * sizeof(struct __user_cap_data_struct))) {
79976 return -EFAULT;
79977 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79978 int ret;
79979
79980 rcu_read_lock();
79981 - ret = security_capable(__task_cred(t), ns, cap);
79982 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79983 + gr_task_is_capable(t, __task_cred(t), cap);
79984 rcu_read_unlock();
79985
79986 - return (ret == 0);
79987 + return ret;
79988 }
79989
79990 /**
79991 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79992 int ret;
79993
79994 rcu_read_lock();
79995 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79996 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79997 rcu_read_unlock();
79998
79999 - return (ret == 0);
80000 + return ret;
80001 }
80002
80003 /**
80004 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
80005 BUG();
80006 }
80007
80008 - if (security_capable(current_cred(), ns, cap) == 0) {
80009 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
80010 current->flags |= PF_SUPERPRIV;
80011 return true;
80012 }
80013 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
80014 }
80015 EXPORT_SYMBOL(ns_capable);
80016
80017 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
80018 +{
80019 + if (unlikely(!cap_valid(cap))) {
80020 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
80021 + BUG();
80022 + }
80023 +
80024 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
80025 + current->flags |= PF_SUPERPRIV;
80026 + return true;
80027 + }
80028 + return false;
80029 +}
80030 +EXPORT_SYMBOL(ns_capable_nolog);
80031 +
80032 /**
80033 * file_ns_capable - Determine if the file's opener had a capability in effect
80034 * @file: The file we want to check
80035 @@ -432,6 +451,12 @@ bool capable(int cap)
80036 }
80037 EXPORT_SYMBOL(capable);
80038
80039 +bool capable_nolog(int cap)
80040 +{
80041 + return ns_capable_nolog(&init_user_ns, cap);
80042 +}
80043 +EXPORT_SYMBOL(capable_nolog);
80044 +
80045 /**
80046 * nsown_capable - Check superior capability to one's own user_ns
80047 * @cap: The capability in question
80048 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
80049
80050 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80051 }
80052 +
80053 +bool inode_capable_nolog(const struct inode *inode, int cap)
80054 +{
80055 + struct user_namespace *ns = current_user_ns();
80056 +
80057 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80058 +}
80059 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
80060 index d22f597..35f58e2 100644
80061 --- a/kernel/cgroup.c
80062 +++ b/kernel/cgroup.c
80063 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
80064 struct css_set *cset = link->cset;
80065 struct task_struct *task;
80066 int count = 0;
80067 - seq_printf(seq, "css_set %p\n", cset);
80068 + seq_printf(seq, "css_set %pK\n", cset);
80069 list_for_each_entry(task, &cset->tasks, cg_list) {
80070 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
80071 seq_puts(seq, " ...\n");
80072 diff --git a/kernel/compat.c b/kernel/compat.c
80073 index 0a09e48..f44f3f0 100644
80074 --- a/kernel/compat.c
80075 +++ b/kernel/compat.c
80076 @@ -13,6 +13,7 @@
80077
80078 #include <linux/linkage.h>
80079 #include <linux/compat.h>
80080 +#include <linux/module.h>
80081 #include <linux/errno.h>
80082 #include <linux/time.h>
80083 #include <linux/signal.h>
80084 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
80085 mm_segment_t oldfs;
80086 long ret;
80087
80088 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
80089 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
80090 oldfs = get_fs();
80091 set_fs(KERNEL_DS);
80092 ret = hrtimer_nanosleep_restart(restart);
80093 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
80094 oldfs = get_fs();
80095 set_fs(KERNEL_DS);
80096 ret = hrtimer_nanosleep(&tu,
80097 - rmtp ? (struct timespec __user *)&rmt : NULL,
80098 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
80099 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
80100 set_fs(oldfs);
80101
80102 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
80103 mm_segment_t old_fs = get_fs();
80104
80105 set_fs(KERNEL_DS);
80106 - ret = sys_sigpending((old_sigset_t __user *) &s);
80107 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
80108 set_fs(old_fs);
80109 if (ret == 0)
80110 ret = put_user(s, set);
80111 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
80112 mm_segment_t old_fs = get_fs();
80113
80114 set_fs(KERNEL_DS);
80115 - ret = sys_old_getrlimit(resource, &r);
80116 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
80117 set_fs(old_fs);
80118
80119 if (!ret) {
80120 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
80121 set_fs (KERNEL_DS);
80122 ret = sys_wait4(pid,
80123 (stat_addr ?
80124 - (unsigned int __user *) &status : NULL),
80125 - options, (struct rusage __user *) &r);
80126 + (unsigned int __force_user *) &status : NULL),
80127 + options, (struct rusage __force_user *) &r);
80128 set_fs (old_fs);
80129
80130 if (ret > 0) {
80131 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
80132 memset(&info, 0, sizeof(info));
80133
80134 set_fs(KERNEL_DS);
80135 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
80136 - uru ? (struct rusage __user *)&ru : NULL);
80137 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
80138 + uru ? (struct rusage __force_user *)&ru : NULL);
80139 set_fs(old_fs);
80140
80141 if ((ret < 0) || (info.si_signo == 0))
80142 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
80143 oldfs = get_fs();
80144 set_fs(KERNEL_DS);
80145 err = sys_timer_settime(timer_id, flags,
80146 - (struct itimerspec __user *) &newts,
80147 - (struct itimerspec __user *) &oldts);
80148 + (struct itimerspec __force_user *) &newts,
80149 + (struct itimerspec __force_user *) &oldts);
80150 set_fs(oldfs);
80151 if (!err && old && put_compat_itimerspec(old, &oldts))
80152 return -EFAULT;
80153 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
80154 oldfs = get_fs();
80155 set_fs(KERNEL_DS);
80156 err = sys_timer_gettime(timer_id,
80157 - (struct itimerspec __user *) &ts);
80158 + (struct itimerspec __force_user *) &ts);
80159 set_fs(oldfs);
80160 if (!err && put_compat_itimerspec(setting, &ts))
80161 return -EFAULT;
80162 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
80163 oldfs = get_fs();
80164 set_fs(KERNEL_DS);
80165 err = sys_clock_settime(which_clock,
80166 - (struct timespec __user *) &ts);
80167 + (struct timespec __force_user *) &ts);
80168 set_fs(oldfs);
80169 return err;
80170 }
80171 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
80172 oldfs = get_fs();
80173 set_fs(KERNEL_DS);
80174 err = sys_clock_gettime(which_clock,
80175 - (struct timespec __user *) &ts);
80176 + (struct timespec __force_user *) &ts);
80177 set_fs(oldfs);
80178 if (!err && put_compat_timespec(&ts, tp))
80179 return -EFAULT;
80180 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
80181
80182 oldfs = get_fs();
80183 set_fs(KERNEL_DS);
80184 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
80185 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
80186 set_fs(oldfs);
80187
80188 err = compat_put_timex(utp, &txc);
80189 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
80190 oldfs = get_fs();
80191 set_fs(KERNEL_DS);
80192 err = sys_clock_getres(which_clock,
80193 - (struct timespec __user *) &ts);
80194 + (struct timespec __force_user *) &ts);
80195 set_fs(oldfs);
80196 if (!err && tp && put_compat_timespec(&ts, tp))
80197 return -EFAULT;
80198 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
80199 long err;
80200 mm_segment_t oldfs;
80201 struct timespec tu;
80202 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
80203 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
80204
80205 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
80206 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
80207 oldfs = get_fs();
80208 set_fs(KERNEL_DS);
80209 err = clock_nanosleep_restart(restart);
80210 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
80211 oldfs = get_fs();
80212 set_fs(KERNEL_DS);
80213 err = sys_clock_nanosleep(which_clock, flags,
80214 - (struct timespec __user *) &in,
80215 - (struct timespec __user *) &out);
80216 + (struct timespec __force_user *) &in,
80217 + (struct timespec __force_user *) &out);
80218 set_fs(oldfs);
80219
80220 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
80221 diff --git a/kernel/configs.c b/kernel/configs.c
80222 index c18b1f1..b9a0132 100644
80223 --- a/kernel/configs.c
80224 +++ b/kernel/configs.c
80225 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
80226 struct proc_dir_entry *entry;
80227
80228 /* create the current config file */
80229 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
80230 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
80231 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
80232 + &ikconfig_file_ops);
80233 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80234 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
80235 + &ikconfig_file_ops);
80236 +#endif
80237 +#else
80238 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
80239 &ikconfig_file_ops);
80240 +#endif
80241 +
80242 if (!entry)
80243 return -ENOMEM;
80244
80245 diff --git a/kernel/cred.c b/kernel/cred.c
80246 index e0573a4..3874e41 100644
80247 --- a/kernel/cred.c
80248 +++ b/kernel/cred.c
80249 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
80250 validate_creds(cred);
80251 alter_cred_subscribers(cred, -1);
80252 put_cred(cred);
80253 +
80254 +#ifdef CONFIG_GRKERNSEC_SETXID
80255 + cred = (struct cred *) tsk->delayed_cred;
80256 + if (cred != NULL) {
80257 + tsk->delayed_cred = NULL;
80258 + validate_creds(cred);
80259 + alter_cred_subscribers(cred, -1);
80260 + put_cred(cred);
80261 + }
80262 +#endif
80263 }
80264
80265 /**
80266 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
80267 * Always returns 0 thus allowing this function to be tail-called at the end
80268 * of, say, sys_setgid().
80269 */
80270 -int commit_creds(struct cred *new)
80271 +static int __commit_creds(struct cred *new)
80272 {
80273 struct task_struct *task = current;
80274 const struct cred *old = task->real_cred;
80275 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
80276
80277 get_cred(new); /* we will require a ref for the subj creds too */
80278
80279 + gr_set_role_label(task, new->uid, new->gid);
80280 +
80281 /* dumpability changes */
80282 if (!uid_eq(old->euid, new->euid) ||
80283 !gid_eq(old->egid, new->egid) ||
80284 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
80285 put_cred(old);
80286 return 0;
80287 }
80288 +#ifdef CONFIG_GRKERNSEC_SETXID
80289 +extern int set_user(struct cred *new);
80290 +
80291 +void gr_delayed_cred_worker(void)
80292 +{
80293 + const struct cred *new = current->delayed_cred;
80294 + struct cred *ncred;
80295 +
80296 + current->delayed_cred = NULL;
80297 +
80298 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
80299 + // from doing get_cred on it when queueing this
80300 + put_cred(new);
80301 + return;
80302 + } else if (new == NULL)
80303 + return;
80304 +
80305 + ncred = prepare_creds();
80306 + if (!ncred)
80307 + goto die;
80308 + // uids
80309 + ncred->uid = new->uid;
80310 + ncred->euid = new->euid;
80311 + ncred->suid = new->suid;
80312 + ncred->fsuid = new->fsuid;
80313 + // gids
80314 + ncred->gid = new->gid;
80315 + ncred->egid = new->egid;
80316 + ncred->sgid = new->sgid;
80317 + ncred->fsgid = new->fsgid;
80318 + // groups
80319 + if (set_groups(ncred, new->group_info) < 0) {
80320 + abort_creds(ncred);
80321 + goto die;
80322 + }
80323 + // caps
80324 + ncred->securebits = new->securebits;
80325 + ncred->cap_inheritable = new->cap_inheritable;
80326 + ncred->cap_permitted = new->cap_permitted;
80327 + ncred->cap_effective = new->cap_effective;
80328 + ncred->cap_bset = new->cap_bset;
80329 +
80330 + if (set_user(ncred)) {
80331 + abort_creds(ncred);
80332 + goto die;
80333 + }
80334 +
80335 + // from doing get_cred on it when queueing this
80336 + put_cred(new);
80337 +
80338 + __commit_creds(ncred);
80339 + return;
80340 +die:
80341 + // from doing get_cred on it when queueing this
80342 + put_cred(new);
80343 + do_group_exit(SIGKILL);
80344 +}
80345 +#endif
80346 +
80347 +int commit_creds(struct cred *new)
80348 +{
80349 +#ifdef CONFIG_GRKERNSEC_SETXID
80350 + int ret;
80351 + int schedule_it = 0;
80352 + struct task_struct *t;
80353 +
80354 + /* we won't get called with tasklist_lock held for writing
80355 + and interrupts disabled as the cred struct in that case is
80356 + init_cred
80357 + */
80358 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80359 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80360 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80361 + schedule_it = 1;
80362 + }
80363 + ret = __commit_creds(new);
80364 + if (schedule_it) {
80365 + rcu_read_lock();
80366 + read_lock(&tasklist_lock);
80367 + for (t = next_thread(current); t != current;
80368 + t = next_thread(t)) {
80369 + if (t->delayed_cred == NULL) {
80370 + t->delayed_cred = get_cred(new);
80371 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80372 + set_tsk_need_resched(t);
80373 + }
80374 + }
80375 + read_unlock(&tasklist_lock);
80376 + rcu_read_unlock();
80377 + }
80378 + return ret;
80379 +#else
80380 + return __commit_creds(new);
80381 +#endif
80382 +}
80383 +
80384 EXPORT_SYMBOL(commit_creds);
80385
80386 /**
80387 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80388 index 0506d44..2c20034 100644
80389 --- a/kernel/debug/debug_core.c
80390 +++ b/kernel/debug/debug_core.c
80391 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80392 */
80393 static atomic_t masters_in_kgdb;
80394 static atomic_t slaves_in_kgdb;
80395 -static atomic_t kgdb_break_tasklet_var;
80396 +static atomic_unchecked_t kgdb_break_tasklet_var;
80397 atomic_t kgdb_setting_breakpoint;
80398
80399 struct task_struct *kgdb_usethread;
80400 @@ -133,7 +133,7 @@ int kgdb_single_step;
80401 static pid_t kgdb_sstep_pid;
80402
80403 /* to keep track of the CPU which is doing the single stepping*/
80404 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80405 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80406
80407 /*
80408 * If you are debugging a problem where roundup (the collection of
80409 @@ -541,7 +541,7 @@ return_normal:
80410 * kernel will only try for the value of sstep_tries before
80411 * giving up and continuing on.
80412 */
80413 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
80414 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
80415 (kgdb_info[cpu].task &&
80416 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
80417 atomic_set(&kgdb_active, -1);
80418 @@ -635,8 +635,8 @@ cpu_master_loop:
80419 }
80420
80421 kgdb_restore:
80422 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
80423 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
80424 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
80425 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
80426 if (kgdb_info[sstep_cpu].task)
80427 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
80428 else
80429 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
80430 static void kgdb_tasklet_bpt(unsigned long ing)
80431 {
80432 kgdb_breakpoint();
80433 - atomic_set(&kgdb_break_tasklet_var, 0);
80434 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
80435 }
80436
80437 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80438
80439 void kgdb_schedule_breakpoint(void)
80440 {
80441 - if (atomic_read(&kgdb_break_tasklet_var) ||
80442 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80443 atomic_read(&kgdb_active) != -1 ||
80444 atomic_read(&kgdb_setting_breakpoint))
80445 return;
80446 - atomic_inc(&kgdb_break_tasklet_var);
80447 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80448 tasklet_schedule(&kgdb_tasklet_breakpoint);
80449 }
80450 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80451 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80452 index 00eb8f7..d7e3244 100644
80453 --- a/kernel/debug/kdb/kdb_main.c
80454 +++ b/kernel/debug/kdb/kdb_main.c
80455 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80456 continue;
80457
80458 kdb_printf("%-20s%8u 0x%p ", mod->name,
80459 - mod->core_size, (void *)mod);
80460 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80461 #ifdef CONFIG_MODULE_UNLOAD
80462 kdb_printf("%4ld ", module_refcount(mod));
80463 #endif
80464 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80465 kdb_printf(" (Loading)");
80466 else
80467 kdb_printf(" (Live)");
80468 - kdb_printf(" 0x%p", mod->module_core);
80469 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80470
80471 #ifdef CONFIG_MODULE_UNLOAD
80472 {
80473 diff --git a/kernel/events/core.c b/kernel/events/core.c
80474 index f86599e..b18b180 100644
80475 --- a/kernel/events/core.c
80476 +++ b/kernel/events/core.c
80477 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80478 * 0 - disallow raw tracepoint access for unpriv
80479 * 1 - disallow cpu events for unpriv
80480 * 2 - disallow kernel profiling for unpriv
80481 + * 3 - disallow all unpriv perf event use
80482 */
80483 -int sysctl_perf_event_paranoid __read_mostly = 1;
80484 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80485 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80486 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80487 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80488 +#else
80489 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80490 +#endif
80491
80492 /* Minimum for 512 kiB + 1 user control page */
80493 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80494 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80495 update_perf_cpu_limits();
80496 }
80497
80498 -static atomic64_t perf_event_id;
80499 +static atomic64_unchecked_t perf_event_id;
80500
80501 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80502 enum event_type_t event_type);
80503 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80504
80505 static inline u64 perf_event_count(struct perf_event *event)
80506 {
80507 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80508 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80509 }
80510
80511 static u64 perf_event_read(struct perf_event *event)
80512 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80513 mutex_lock(&event->child_mutex);
80514 total += perf_event_read(event);
80515 *enabled += event->total_time_enabled +
80516 - atomic64_read(&event->child_total_time_enabled);
80517 + atomic64_read_unchecked(&event->child_total_time_enabled);
80518 *running += event->total_time_running +
80519 - atomic64_read(&event->child_total_time_running);
80520 + atomic64_read_unchecked(&event->child_total_time_running);
80521
80522 list_for_each_entry(child, &event->child_list, child_list) {
80523 total += perf_event_read(child);
80524 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80525 userpg->offset -= local64_read(&event->hw.prev_count);
80526
80527 userpg->time_enabled = enabled +
80528 - atomic64_read(&event->child_total_time_enabled);
80529 + atomic64_read_unchecked(&event->child_total_time_enabled);
80530
80531 userpg->time_running = running +
80532 - atomic64_read(&event->child_total_time_running);
80533 + atomic64_read_unchecked(&event->child_total_time_running);
80534
80535 arch_perf_update_userpage(userpg, now);
80536
80537 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80538
80539 /* Data. */
80540 sp = perf_user_stack_pointer(regs);
80541 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80542 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80543 dyn_size = dump_size - rem;
80544
80545 perf_output_skip(handle, rem);
80546 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80547 values[n++] = perf_event_count(event);
80548 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80549 values[n++] = enabled +
80550 - atomic64_read(&event->child_total_time_enabled);
80551 + atomic64_read_unchecked(&event->child_total_time_enabled);
80552 }
80553 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80554 values[n++] = running +
80555 - atomic64_read(&event->child_total_time_running);
80556 + atomic64_read_unchecked(&event->child_total_time_running);
80557 }
80558 if (read_format & PERF_FORMAT_ID)
80559 values[n++] = primary_event_id(event);
80560 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80561 * need to add enough zero bytes after the string to handle
80562 * the 64bit alignment we do later.
80563 */
80564 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80565 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80566 if (!buf) {
80567 name = strncpy(tmp, "//enomem", sizeof(tmp));
80568 goto got_name;
80569 }
80570 - name = d_path(&file->f_path, buf, PATH_MAX);
80571 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80572 if (IS_ERR(name)) {
80573 name = strncpy(tmp, "//toolong", sizeof(tmp));
80574 goto got_name;
80575 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80576 event->parent = parent_event;
80577
80578 event->ns = get_pid_ns(task_active_pid_ns(current));
80579 - event->id = atomic64_inc_return(&perf_event_id);
80580 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80581
80582 event->state = PERF_EVENT_STATE_INACTIVE;
80583
80584 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80585 if (flags & ~PERF_FLAG_ALL)
80586 return -EINVAL;
80587
80588 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80589 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80590 + return -EACCES;
80591 +#endif
80592 +
80593 err = perf_copy_attr(attr_uptr, &attr);
80594 if (err)
80595 return err;
80596 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80597 /*
80598 * Add back the child's count to the parent's count:
80599 */
80600 - atomic64_add(child_val, &parent_event->child_count);
80601 - atomic64_add(child_event->total_time_enabled,
80602 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80603 + atomic64_add_unchecked(child_event->total_time_enabled,
80604 &parent_event->child_total_time_enabled);
80605 - atomic64_add(child_event->total_time_running,
80606 + atomic64_add_unchecked(child_event->total_time_running,
80607 &parent_event->child_total_time_running);
80608
80609 /*
80610 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80611 index ca65997..60df03d 100644
80612 --- a/kernel/events/internal.h
80613 +++ b/kernel/events/internal.h
80614 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80615 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80616 }
80617
80618 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80619 -static inline unsigned int \
80620 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80621 +static inline unsigned long \
80622 func_name(struct perf_output_handle *handle, \
80623 - const void *buf, unsigned int len) \
80624 + const void user *buf, unsigned long len) \
80625 { \
80626 unsigned long size, written; \
80627 \
80628 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80629 return n;
80630 }
80631
80632 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80633 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80634
80635 #define MEMCPY_SKIP(dst, src, n) (n)
80636
80637 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80638 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80639
80640 #ifndef arch_perf_out_copy_user
80641 #define arch_perf_out_copy_user __copy_from_user_inatomic
80642 #endif
80643
80644 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80645 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80646
80647 /* Callchain handling */
80648 extern struct perf_callchain_entry *
80649 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80650 index ad8e1bd..fed7ba9 100644
80651 --- a/kernel/events/uprobes.c
80652 +++ b/kernel/events/uprobes.c
80653 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80654 {
80655 struct page *page;
80656 uprobe_opcode_t opcode;
80657 - int result;
80658 + long result;
80659
80660 pagefault_disable();
80661 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80662 diff --git a/kernel/exit.c b/kernel/exit.c
80663 index a949819..a5f127d 100644
80664 --- a/kernel/exit.c
80665 +++ b/kernel/exit.c
80666 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80667 struct task_struct *leader;
80668 int zap_leader;
80669 repeat:
80670 +#ifdef CONFIG_NET
80671 + gr_del_task_from_ip_table(p);
80672 +#endif
80673 +
80674 /* don't need to get the RCU readlock here - the process is dead and
80675 * can't be modifying its own credentials. But shut RCU-lockdep up */
80676 rcu_read_lock();
80677 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80678 * know it'll be handled, so that they don't get converted to
80679 * SIGKILL or just silently dropped.
80680 */
80681 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80682 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80683 recalc_sigpending();
80684 spin_unlock_irq(&current->sighand->siglock);
80685 return 0;
80686 @@ -698,6 +702,8 @@ void do_exit(long code)
80687 struct task_struct *tsk = current;
80688 int group_dead;
80689
80690 + set_fs(USER_DS);
80691 +
80692 profile_task_exit(tsk);
80693
80694 WARN_ON(blk_needs_flush_plug(tsk));
80695 @@ -714,7 +720,6 @@ void do_exit(long code)
80696 * mm_release()->clear_child_tid() from writing to a user-controlled
80697 * kernel address.
80698 */
80699 - set_fs(USER_DS);
80700
80701 ptrace_event(PTRACE_EVENT_EXIT, code);
80702
80703 @@ -773,6 +778,9 @@ void do_exit(long code)
80704 tsk->exit_code = code;
80705 taskstats_exit(tsk, group_dead);
80706
80707 + gr_acl_handle_psacct(tsk, code);
80708 + gr_acl_handle_exit();
80709 +
80710 exit_mm(tsk);
80711
80712 if (group_dead)
80713 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80714 * Take down every thread in the group. This is called by fatal signals
80715 * as well as by sys_exit_group (below).
80716 */
80717 -void
80718 +__noreturn void
80719 do_group_exit(int exit_code)
80720 {
80721 struct signal_struct *sig = current->signal;
80722 diff --git a/kernel/fork.c b/kernel/fork.c
80723 index 200a7a2..43e52da 100644
80724 --- a/kernel/fork.c
80725 +++ b/kernel/fork.c
80726 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80727 *stackend = STACK_END_MAGIC; /* for overflow detection */
80728
80729 #ifdef CONFIG_CC_STACKPROTECTOR
80730 - tsk->stack_canary = get_random_int();
80731 + tsk->stack_canary = pax_get_random_long();
80732 #endif
80733
80734 /*
80735 @@ -345,13 +345,81 @@ free_tsk:
80736 }
80737
80738 #ifdef CONFIG_MMU
80739 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80740 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80741 {
80742 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80743 - struct rb_node **rb_link, *rb_parent;
80744 - int retval;
80745 + struct vm_area_struct *tmp;
80746 unsigned long charge;
80747 struct mempolicy *pol;
80748 + struct file *file;
80749 +
80750 + charge = 0;
80751 + if (mpnt->vm_flags & VM_ACCOUNT) {
80752 + unsigned long len = vma_pages(mpnt);
80753 +
80754 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80755 + goto fail_nomem;
80756 + charge = len;
80757 + }
80758 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80759 + if (!tmp)
80760 + goto fail_nomem;
80761 + *tmp = *mpnt;
80762 + tmp->vm_mm = mm;
80763 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80764 + pol = mpol_dup(vma_policy(mpnt));
80765 + if (IS_ERR(pol))
80766 + goto fail_nomem_policy;
80767 + vma_set_policy(tmp, pol);
80768 + if (anon_vma_fork(tmp, mpnt))
80769 + goto fail_nomem_anon_vma_fork;
80770 + tmp->vm_flags &= ~VM_LOCKED;
80771 + tmp->vm_next = tmp->vm_prev = NULL;
80772 + tmp->vm_mirror = NULL;
80773 + file = tmp->vm_file;
80774 + if (file) {
80775 + struct inode *inode = file_inode(file);
80776 + struct address_space *mapping = file->f_mapping;
80777 +
80778 + get_file(file);
80779 + if (tmp->vm_flags & VM_DENYWRITE)
80780 + atomic_dec(&inode->i_writecount);
80781 + mutex_lock(&mapping->i_mmap_mutex);
80782 + if (tmp->vm_flags & VM_SHARED)
80783 + mapping->i_mmap_writable++;
80784 + flush_dcache_mmap_lock(mapping);
80785 + /* insert tmp into the share list, just after mpnt */
80786 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80787 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80788 + else
80789 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80790 + flush_dcache_mmap_unlock(mapping);
80791 + mutex_unlock(&mapping->i_mmap_mutex);
80792 + }
80793 +
80794 + /*
80795 + * Clear hugetlb-related page reserves for children. This only
80796 + * affects MAP_PRIVATE mappings. Faults generated by the child
80797 + * are not guaranteed to succeed, even if read-only
80798 + */
80799 + if (is_vm_hugetlb_page(tmp))
80800 + reset_vma_resv_huge_pages(tmp);
80801 +
80802 + return tmp;
80803 +
80804 +fail_nomem_anon_vma_fork:
80805 + mpol_put(pol);
80806 +fail_nomem_policy:
80807 + kmem_cache_free(vm_area_cachep, tmp);
80808 +fail_nomem:
80809 + vm_unacct_memory(charge);
80810 + return NULL;
80811 +}
80812 +
80813 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80814 +{
80815 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80816 + struct rb_node **rb_link, *rb_parent;
80817 + int retval;
80818
80819 uprobe_start_dup_mmap();
80820 down_write(&oldmm->mmap_sem);
80821 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80822
80823 prev = NULL;
80824 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80825 - struct file *file;
80826 -
80827 if (mpnt->vm_flags & VM_DONTCOPY) {
80828 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80829 -vma_pages(mpnt));
80830 continue;
80831 }
80832 - charge = 0;
80833 - if (mpnt->vm_flags & VM_ACCOUNT) {
80834 - unsigned long len = vma_pages(mpnt);
80835 -
80836 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80837 - goto fail_nomem;
80838 - charge = len;
80839 - }
80840 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80841 - if (!tmp)
80842 - goto fail_nomem;
80843 - *tmp = *mpnt;
80844 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80845 - pol = mpol_dup(vma_policy(mpnt));
80846 - retval = PTR_ERR(pol);
80847 - if (IS_ERR(pol))
80848 - goto fail_nomem_policy;
80849 - vma_set_policy(tmp, pol);
80850 - tmp->vm_mm = mm;
80851 - if (anon_vma_fork(tmp, mpnt))
80852 - goto fail_nomem_anon_vma_fork;
80853 - tmp->vm_flags &= ~VM_LOCKED;
80854 - tmp->vm_next = tmp->vm_prev = NULL;
80855 - file = tmp->vm_file;
80856 - if (file) {
80857 - struct inode *inode = file_inode(file);
80858 - struct address_space *mapping = file->f_mapping;
80859 -
80860 - get_file(file);
80861 - if (tmp->vm_flags & VM_DENYWRITE)
80862 - atomic_dec(&inode->i_writecount);
80863 - mutex_lock(&mapping->i_mmap_mutex);
80864 - if (tmp->vm_flags & VM_SHARED)
80865 - mapping->i_mmap_writable++;
80866 - flush_dcache_mmap_lock(mapping);
80867 - /* insert tmp into the share list, just after mpnt */
80868 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80869 - vma_nonlinear_insert(tmp,
80870 - &mapping->i_mmap_nonlinear);
80871 - else
80872 - vma_interval_tree_insert_after(tmp, mpnt,
80873 - &mapping->i_mmap);
80874 - flush_dcache_mmap_unlock(mapping);
80875 - mutex_unlock(&mapping->i_mmap_mutex);
80876 + tmp = dup_vma(mm, oldmm, mpnt);
80877 + if (!tmp) {
80878 + retval = -ENOMEM;
80879 + goto out;
80880 }
80881
80882 /*
80883 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80884 if (retval)
80885 goto out;
80886 }
80887 +
80888 +#ifdef CONFIG_PAX_SEGMEXEC
80889 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80890 + struct vm_area_struct *mpnt_m;
80891 +
80892 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80893 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80894 +
80895 + if (!mpnt->vm_mirror)
80896 + continue;
80897 +
80898 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80899 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80900 + mpnt->vm_mirror = mpnt_m;
80901 + } else {
80902 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80903 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80904 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80905 + mpnt->vm_mirror->vm_mirror = mpnt;
80906 + }
80907 + }
80908 + BUG_ON(mpnt_m);
80909 + }
80910 +#endif
80911 +
80912 /* a new mm has just been created */
80913 arch_dup_mmap(oldmm, mm);
80914 retval = 0;
80915 @@ -471,14 +522,6 @@ out:
80916 up_write(&oldmm->mmap_sem);
80917 uprobe_end_dup_mmap();
80918 return retval;
80919 -fail_nomem_anon_vma_fork:
80920 - mpol_put(pol);
80921 -fail_nomem_policy:
80922 - kmem_cache_free(vm_area_cachep, tmp);
80923 -fail_nomem:
80924 - retval = -ENOMEM;
80925 - vm_unacct_memory(charge);
80926 - goto out;
80927 }
80928
80929 static inline int mm_alloc_pgd(struct mm_struct *mm)
80930 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80931 return ERR_PTR(err);
80932
80933 mm = get_task_mm(task);
80934 - if (mm && mm != current->mm &&
80935 - !ptrace_may_access(task, mode)) {
80936 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80937 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80938 mmput(mm);
80939 mm = ERR_PTR(-EACCES);
80940 }
80941 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80942 spin_unlock(&fs->lock);
80943 return -EAGAIN;
80944 }
80945 - fs->users++;
80946 + atomic_inc(&fs->users);
80947 spin_unlock(&fs->lock);
80948 return 0;
80949 }
80950 tsk->fs = copy_fs_struct(fs);
80951 if (!tsk->fs)
80952 return -ENOMEM;
80953 + /* Carry through gr_chroot_dentry and is_chrooted instead
80954 + of recomputing it here. Already copied when the task struct
80955 + is duplicated. This allows pivot_root to not be treated as
80956 + a chroot
80957 + */
80958 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80959 +
80960 return 0;
80961 }
80962
80963 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80964 * parts of the process environment (as per the clone
80965 * flags). The actual kick-off is left to the caller.
80966 */
80967 -static struct task_struct *copy_process(unsigned long clone_flags,
80968 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80969 unsigned long stack_start,
80970 unsigned long stack_size,
80971 int __user *child_tidptr,
80972 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80973 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80974 #endif
80975 retval = -EAGAIN;
80976 +
80977 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80978 +
80979 if (atomic_read(&p->real_cred->user->processes) >=
80980 task_rlimit(p, RLIMIT_NPROC)) {
80981 if (p->real_cred->user != INIT_USER &&
80982 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80983 goto bad_fork_free_pid;
80984 }
80985
80986 + /* synchronizes with gr_set_acls()
80987 + we need to call this past the point of no return for fork()
80988 + */
80989 + gr_copy_label(p);
80990 +
80991 if (likely(p->pid)) {
80992 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80993
80994 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80995 bad_fork_free:
80996 free_task(p);
80997 fork_out:
80998 + gr_log_forkfail(retval);
80999 +
81000 return ERR_PTR(retval);
81001 }
81002
81003 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
81004
81005 p = copy_process(clone_flags, stack_start, stack_size,
81006 child_tidptr, NULL, trace);
81007 + add_latent_entropy();
81008 /*
81009 * Do this prior waking up the new thread - the thread pointer
81010 * might get invalid after that point, if the thread exits quickly.
81011 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
81012 if (clone_flags & CLONE_PARENT_SETTID)
81013 put_user(nr, parent_tidptr);
81014
81015 + gr_handle_brute_check();
81016 +
81017 if (clone_flags & CLONE_VFORK) {
81018 p->vfork_done = &vfork;
81019 init_completion(&vfork);
81020 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
81021 mm_cachep = kmem_cache_create("mm_struct",
81022 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
81023 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
81024 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
81025 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
81026 mmap_init();
81027 nsproxy_cache_init();
81028 }
81029 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
81030 return 0;
81031
81032 /* don't need lock here; in the worst case we'll do useless copy */
81033 - if (fs->users == 1)
81034 + if (atomic_read(&fs->users) == 1)
81035 return 0;
81036
81037 *new_fsp = copy_fs_struct(fs);
81038 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
81039 fs = current->fs;
81040 spin_lock(&fs->lock);
81041 current->fs = new_fs;
81042 - if (--fs->users)
81043 + gr_set_chroot_entries(current, &current->fs->root);
81044 + if (atomic_dec_return(&fs->users))
81045 new_fs = NULL;
81046 else
81047 new_fs = fs;
81048 diff --git a/kernel/futex.c b/kernel/futex.c
81049 index c3a1a55..e32b4a98 100644
81050 --- a/kernel/futex.c
81051 +++ b/kernel/futex.c
81052 @@ -54,6 +54,7 @@
81053 #include <linux/mount.h>
81054 #include <linux/pagemap.h>
81055 #include <linux/syscalls.h>
81056 +#include <linux/ptrace.h>
81057 #include <linux/signal.h>
81058 #include <linux/export.h>
81059 #include <linux/magic.h>
81060 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
81061 struct page *page, *page_head;
81062 int err, ro = 0;
81063
81064 +#ifdef CONFIG_PAX_SEGMEXEC
81065 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
81066 + return -EFAULT;
81067 +#endif
81068 +
81069 /*
81070 * The futex address must be "naturally" aligned.
81071 */
81072 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
81073
81074 static int get_futex_value_locked(u32 *dest, u32 __user *from)
81075 {
81076 - int ret;
81077 + unsigned long ret;
81078
81079 pagefault_disable();
81080 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
81081 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
81082 {
81083 u32 curval;
81084 int i;
81085 + mm_segment_t oldfs;
81086
81087 /*
81088 * This will fail and we want it. Some arch implementations do
81089 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
81090 * implementation, the non-functional ones will return
81091 * -ENOSYS.
81092 */
81093 + oldfs = get_fs();
81094 + set_fs(USER_DS);
81095 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
81096 futex_cmpxchg_enabled = 1;
81097 + set_fs(oldfs);
81098
81099 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
81100 plist_head_init(&futex_queues[i].chain);
81101 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
81102 index f9f44fd..29885e4 100644
81103 --- a/kernel/futex_compat.c
81104 +++ b/kernel/futex_compat.c
81105 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
81106 return 0;
81107 }
81108
81109 -static void __user *futex_uaddr(struct robust_list __user *entry,
81110 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
81111 compat_long_t futex_offset)
81112 {
81113 compat_uptr_t base = ptr_to_compat(entry);
81114 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
81115 index 9b22d03..6295b62 100644
81116 --- a/kernel/gcov/base.c
81117 +++ b/kernel/gcov/base.c
81118 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
81119 }
81120
81121 #ifdef CONFIG_MODULES
81122 -static inline int within(void *addr, void *start, unsigned long size)
81123 -{
81124 - return ((addr >= start) && (addr < start + size));
81125 -}
81126 -
81127 /* Update list and generate events when modules are unloaded. */
81128 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81129 void *data)
81130 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81131 prev = NULL;
81132 /* Remove entries located in module from linked list. */
81133 for (info = gcov_info_head; info; info = info->next) {
81134 - if (within(info, mod->module_core, mod->core_size)) {
81135 + if (within_module_core_rw((unsigned long)info, mod)) {
81136 if (prev)
81137 prev->next = info->next;
81138 else
81139 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
81140 index 383319b..56ebb13 100644
81141 --- a/kernel/hrtimer.c
81142 +++ b/kernel/hrtimer.c
81143 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
81144 local_irq_restore(flags);
81145 }
81146
81147 -static void run_hrtimer_softirq(struct softirq_action *h)
81148 +static __latent_entropy void run_hrtimer_softirq(void)
81149 {
81150 hrtimer_peek_ahead_timers();
81151 }
81152 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
81153 index 55fcce6..0e4cf34 100644
81154 --- a/kernel/irq_work.c
81155 +++ b/kernel/irq_work.c
81156 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
81157 return NOTIFY_OK;
81158 }
81159
81160 -static struct notifier_block cpu_notify;
81161 +static struct notifier_block cpu_notify = {
81162 + .notifier_call = irq_work_cpu_notify,
81163 + .priority = 0,
81164 +};
81165
81166 static __init int irq_work_init_cpu_notifier(void)
81167 {
81168 - cpu_notify.notifier_call = irq_work_cpu_notify;
81169 - cpu_notify.priority = 0;
81170 register_cpu_notifier(&cpu_notify);
81171 return 0;
81172 }
81173 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
81174 index 60f48fa..7f3a770 100644
81175 --- a/kernel/jump_label.c
81176 +++ b/kernel/jump_label.c
81177 @@ -13,6 +13,7 @@
81178 #include <linux/sort.h>
81179 #include <linux/err.h>
81180 #include <linux/static_key.h>
81181 +#include <linux/mm.h>
81182
81183 #ifdef HAVE_JUMP_LABEL
81184
81185 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
81186
81187 size = (((unsigned long)stop - (unsigned long)start)
81188 / sizeof(struct jump_entry));
81189 + pax_open_kernel();
81190 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
81191 + pax_close_kernel();
81192 }
81193
81194 static void jump_label_update(struct static_key *key, int enable);
81195 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
81196 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
81197 struct jump_entry *iter;
81198
81199 + pax_open_kernel();
81200 for (iter = iter_start; iter < iter_stop; iter++) {
81201 if (within_module_init(iter->code, mod))
81202 iter->code = 0;
81203 }
81204 + pax_close_kernel();
81205 }
81206
81207 static int
81208 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
81209 index 3127ad5..159d880 100644
81210 --- a/kernel/kallsyms.c
81211 +++ b/kernel/kallsyms.c
81212 @@ -11,6 +11,9 @@
81213 * Changed the compression method from stem compression to "table lookup"
81214 * compression (see scripts/kallsyms.c for a more complete description)
81215 */
81216 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81217 +#define __INCLUDED_BY_HIDESYM 1
81218 +#endif
81219 #include <linux/kallsyms.h>
81220 #include <linux/module.h>
81221 #include <linux/init.h>
81222 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
81223
81224 static inline int is_kernel_inittext(unsigned long addr)
81225 {
81226 + if (system_state != SYSTEM_BOOTING)
81227 + return 0;
81228 +
81229 if (addr >= (unsigned long)_sinittext
81230 && addr <= (unsigned long)_einittext)
81231 return 1;
81232 return 0;
81233 }
81234
81235 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81236 +#ifdef CONFIG_MODULES
81237 +static inline int is_module_text(unsigned long addr)
81238 +{
81239 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
81240 + return 1;
81241 +
81242 + addr = ktla_ktva(addr);
81243 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
81244 +}
81245 +#else
81246 +static inline int is_module_text(unsigned long addr)
81247 +{
81248 + return 0;
81249 +}
81250 +#endif
81251 +#endif
81252 +
81253 static inline int is_kernel_text(unsigned long addr)
81254 {
81255 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
81256 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
81257
81258 static inline int is_kernel(unsigned long addr)
81259 {
81260 +
81261 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81262 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
81263 + return 1;
81264 +
81265 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
81266 +#else
81267 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
81268 +#endif
81269 +
81270 return 1;
81271 return in_gate_area_no_mm(addr);
81272 }
81273
81274 static int is_ksym_addr(unsigned long addr)
81275 {
81276 +
81277 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81278 + if (is_module_text(addr))
81279 + return 0;
81280 +#endif
81281 +
81282 if (all_var)
81283 return is_kernel(addr);
81284
81285 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
81286
81287 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
81288 {
81289 - iter->name[0] = '\0';
81290 iter->nameoff = get_symbol_offset(new_pos);
81291 iter->pos = new_pos;
81292 }
81293 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
81294 {
81295 struct kallsym_iter *iter = m->private;
81296
81297 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81298 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
81299 + return 0;
81300 +#endif
81301 +
81302 /* Some debugging symbols have no name. Ignore them. */
81303 if (!iter->name[0])
81304 return 0;
81305 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
81306 */
81307 type = iter->exported ? toupper(iter->type) :
81308 tolower(iter->type);
81309 +
81310 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
81311 type, iter->name, iter->module_name);
81312 } else
81313 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
81314 struct kallsym_iter *iter;
81315 int ret;
81316
81317 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
81318 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
81319 if (!iter)
81320 return -ENOMEM;
81321 reset_iter(iter, 0);
81322 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
81323 index e30ac0f..3528cac 100644
81324 --- a/kernel/kcmp.c
81325 +++ b/kernel/kcmp.c
81326 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
81327 struct task_struct *task1, *task2;
81328 int ret;
81329
81330 +#ifdef CONFIG_GRKERNSEC
81331 + return -ENOSYS;
81332 +#endif
81333 +
81334 rcu_read_lock();
81335
81336 /*
81337 diff --git a/kernel/kexec.c b/kernel/kexec.c
81338 index 59f7b55..4022f65 100644
81339 --- a/kernel/kexec.c
81340 +++ b/kernel/kexec.c
81341 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81342 unsigned long flags)
81343 {
81344 struct compat_kexec_segment in;
81345 - struct kexec_segment out, __user *ksegments;
81346 + struct kexec_segment out;
81347 + struct kexec_segment __user *ksegments;
81348 unsigned long i, result;
81349
81350 /* Don't allow clients that don't understand the native
81351 diff --git a/kernel/kmod.c b/kernel/kmod.c
81352 index b086006..ae5736e 100644
81353 --- a/kernel/kmod.c
81354 +++ b/kernel/kmod.c
81355 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81356 kfree(info->argv);
81357 }
81358
81359 -static int call_modprobe(char *module_name, int wait)
81360 +static int call_modprobe(char *module_name, char *module_param, int wait)
81361 {
81362 struct subprocess_info *info;
81363 static char *envp[] = {
81364 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81365 NULL
81366 };
81367
81368 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81369 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81370 if (!argv)
81371 goto out;
81372
81373 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81374 argv[1] = "-q";
81375 argv[2] = "--";
81376 argv[3] = module_name; /* check free_modprobe_argv() */
81377 - argv[4] = NULL;
81378 + argv[4] = module_param;
81379 + argv[5] = NULL;
81380
81381 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81382 NULL, free_modprobe_argv, NULL);
81383 @@ -129,9 +130,8 @@ out:
81384 * If module auto-loading support is disabled then this function
81385 * becomes a no-operation.
81386 */
81387 -int __request_module(bool wait, const char *fmt, ...)
81388 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81389 {
81390 - va_list args;
81391 char module_name[MODULE_NAME_LEN];
81392 unsigned int max_modprobes;
81393 int ret;
81394 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81395 if (!modprobe_path[0])
81396 return 0;
81397
81398 - va_start(args, fmt);
81399 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
81400 - va_end(args);
81401 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
81402 if (ret >= MODULE_NAME_LEN)
81403 return -ENAMETOOLONG;
81404
81405 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
81406 if (ret)
81407 return ret;
81408
81409 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81410 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81411 + /* hack to workaround consolekit/udisks stupidity */
81412 + read_lock(&tasklist_lock);
81413 + if (!strcmp(current->comm, "mount") &&
81414 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
81415 + read_unlock(&tasklist_lock);
81416 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
81417 + return -EPERM;
81418 + }
81419 + read_unlock(&tasklist_lock);
81420 + }
81421 +#endif
81422 +
81423 /* If modprobe needs a service that is in a module, we get a recursive
81424 * loop. Limit the number of running kmod threads to max_threads/2 or
81425 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
81426 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
81427
81428 trace_module_request(module_name, wait, _RET_IP_);
81429
81430 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81431 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81432
81433 atomic_dec(&kmod_concurrent);
81434 return ret;
81435 }
81436 +
81437 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81438 +{
81439 + va_list args;
81440 + int ret;
81441 +
81442 + va_start(args, fmt);
81443 + ret = ____request_module(wait, module_param, fmt, args);
81444 + va_end(args);
81445 +
81446 + return ret;
81447 +}
81448 +
81449 +int __request_module(bool wait, const char *fmt, ...)
81450 +{
81451 + va_list args;
81452 + int ret;
81453 +
81454 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81455 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81456 + char module_param[MODULE_NAME_LEN];
81457 +
81458 + memset(module_param, 0, sizeof(module_param));
81459 +
81460 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81461 +
81462 + va_start(args, fmt);
81463 + ret = ____request_module(wait, module_param, fmt, args);
81464 + va_end(args);
81465 +
81466 + return ret;
81467 + }
81468 +#endif
81469 +
81470 + va_start(args, fmt);
81471 + ret = ____request_module(wait, NULL, fmt, args);
81472 + va_end(args);
81473 +
81474 + return ret;
81475 +}
81476 +
81477 EXPORT_SYMBOL(__request_module);
81478 #endif /* CONFIG_MODULES */
81479
81480 @@ -218,6 +271,18 @@ static int ____call_usermodehelper(void *data)
81481 */
81482 set_user_nice(current, 0);
81483
81484 +#ifdef CONFIG_GRKERNSEC
81485 + /* this is race-free as far as userland is concerned as we copied
81486 + out the path to be used prior to this point and are now operating
81487 + on that copy
81488 + */
81489 + if (strncmp(sub_info->path, "/sbin/", 6) || strstr(sub_info->path, "..")) {
81490 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin\n", sub_info->path);
81491 + retval = -EPERM;
81492 + goto fail;
81493 + }
81494 +#endif
81495 +
81496 retval = -ENOMEM;
81497 new = prepare_kernel_cred(current);
81498 if (!new)
81499 @@ -260,6 +325,10 @@ static int call_helper(void *data)
81500
81501 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
81502 {
81503 +#ifdef CONFIG_GRKERNSEC
81504 + kfree(info->path);
81505 + info->path = info->origpath;
81506 +#endif
81507 if (info->cleanup)
81508 (*info->cleanup)(info);
81509 kfree(info);
81510 @@ -303,7 +372,7 @@ static int wait_for_helper(void *data)
81511 *
81512 * Thus the __user pointer cast is valid here.
81513 */
81514 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81515 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81516
81517 /*
81518 * If ret is 0, either ____call_usermodehelper failed and the
81519 @@ -542,7 +611,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
81520 goto out;
81521
81522 INIT_WORK(&sub_info->work, __call_usermodehelper);
81523 +#ifdef CONFIG_GRKERNSEC
81524 + sub_info->origpath = path;
81525 + sub_info->path = kstrdup(path, gfp_mask);
81526 +#else
81527 sub_info->path = path;
81528 +#endif
81529 sub_info->argv = argv;
81530 sub_info->envp = envp;
81531
81532 @@ -650,7 +724,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81533 static int proc_cap_handler(struct ctl_table *table, int write,
81534 void __user *buffer, size_t *lenp, loff_t *ppos)
81535 {
81536 - struct ctl_table t;
81537 + ctl_table_no_const t;
81538 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81539 kernel_cap_t new_cap;
81540 int err, i;
81541 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81542 index 6e33498..3133bd3 100644
81543 --- a/kernel/kprobes.c
81544 +++ b/kernel/kprobes.c
81545 @@ -31,6 +31,9 @@
81546 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81547 * <prasanna@in.ibm.com> added function-return probes.
81548 */
81549 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81550 +#define __INCLUDED_BY_HIDESYM 1
81551 +#endif
81552 #include <linux/kprobes.h>
81553 #include <linux/hash.h>
81554 #include <linux/init.h>
81555 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81556 * kernel image and loaded module images reside. This is required
81557 * so x86_64 can correctly handle the %rip-relative fixups.
81558 */
81559 - kip->insns = module_alloc(PAGE_SIZE);
81560 + kip->insns = module_alloc_exec(PAGE_SIZE);
81561 if (!kip->insns) {
81562 kfree(kip);
81563 return NULL;
81564 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81565 */
81566 if (!list_is_singular(&kip->list)) {
81567 list_del(&kip->list);
81568 - module_free(NULL, kip->insns);
81569 + module_free_exec(NULL, kip->insns);
81570 kfree(kip);
81571 }
81572 return 1;
81573 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81574 {
81575 int i, err = 0;
81576 unsigned long offset = 0, size = 0;
81577 - char *modname, namebuf[128];
81578 + char *modname, namebuf[KSYM_NAME_LEN];
81579 const char *symbol_name;
81580 void *addr;
81581 struct kprobe_blackpoint *kb;
81582 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81583 kprobe_type = "k";
81584
81585 if (sym)
81586 - seq_printf(pi, "%p %s %s+0x%x %s ",
81587 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81588 p->addr, kprobe_type, sym, offset,
81589 (modname ? modname : " "));
81590 else
81591 - seq_printf(pi, "%p %s %p ",
81592 + seq_printf(pi, "%pK %s %pK ",
81593 p->addr, kprobe_type, p->addr);
81594
81595 if (!pp)
81596 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81597 const char *sym = NULL;
81598 unsigned int i = *(loff_t *) v;
81599 unsigned long offset = 0;
81600 - char *modname, namebuf[128];
81601 + char *modname, namebuf[KSYM_NAME_LEN];
81602
81603 head = &kprobe_table[i];
81604 preempt_disable();
81605 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81606 index 6ada93c..dce7d5d 100644
81607 --- a/kernel/ksysfs.c
81608 +++ b/kernel/ksysfs.c
81609 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81610 {
81611 if (count+1 > UEVENT_HELPER_PATH_LEN)
81612 return -ENOENT;
81613 + if (!capable(CAP_SYS_ADMIN))
81614 + return -EPERM;
81615 memcpy(uevent_helper, buf, count);
81616 uevent_helper[count] = '\0';
81617 if (count && uevent_helper[count-1] == '\n')
81618 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81619 return count;
81620 }
81621
81622 -static struct bin_attribute notes_attr = {
81623 +static bin_attribute_no_const notes_attr __read_only = {
81624 .attr = {
81625 .name = "notes",
81626 .mode = S_IRUGO,
81627 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81628 index e16c45b..6f49c48 100644
81629 --- a/kernel/lockdep.c
81630 +++ b/kernel/lockdep.c
81631 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81632 end = (unsigned long) &_end,
81633 addr = (unsigned long) obj;
81634
81635 +#ifdef CONFIG_PAX_KERNEXEC
81636 + start = ktla_ktva(start);
81637 +#endif
81638 +
81639 /*
81640 * static variable?
81641 */
81642 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81643 if (!static_obj(lock->key)) {
81644 debug_locks_off();
81645 printk("INFO: trying to register non-static key.\n");
81646 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81647 printk("the code is fine but needs lockdep annotation.\n");
81648 printk("turning off the locking correctness validator.\n");
81649 dump_stack();
81650 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81651 if (!class)
81652 return 0;
81653 }
81654 - atomic_inc((atomic_t *)&class->ops);
81655 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81656 if (very_verbose(class)) {
81657 printk("\nacquire class [%p] %s", class->key, class->name);
81658 if (class->name_version > 1)
81659 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81660 index b2c71c5..7b88d63 100644
81661 --- a/kernel/lockdep_proc.c
81662 +++ b/kernel/lockdep_proc.c
81663 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81664 return 0;
81665 }
81666
81667 - seq_printf(m, "%p", class->key);
81668 + seq_printf(m, "%pK", class->key);
81669 #ifdef CONFIG_DEBUG_LOCKDEP
81670 seq_printf(m, " OPS:%8ld", class->ops);
81671 #endif
81672 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81673
81674 list_for_each_entry(entry, &class->locks_after, entry) {
81675 if (entry->distance == 1) {
81676 - seq_printf(m, " -> [%p] ", entry->class->key);
81677 + seq_printf(m, " -> [%pK] ", entry->class->key);
81678 print_name(m, entry->class);
81679 seq_puts(m, "\n");
81680 }
81681 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81682 if (!class->key)
81683 continue;
81684
81685 - seq_printf(m, "[%p] ", class->key);
81686 + seq_printf(m, "[%pK] ", class->key);
81687 print_name(m, class);
81688 seq_puts(m, "\n");
81689 }
81690 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81691 if (!i)
81692 seq_line(m, '-', 40-namelen, namelen);
81693
81694 - snprintf(ip, sizeof(ip), "[<%p>]",
81695 + snprintf(ip, sizeof(ip), "[<%pK>]",
81696 (void *)class->contention_point[i]);
81697 seq_printf(m, "%40s %14lu %29s %pS\n",
81698 name, stats->contention_point[i],
81699 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81700 if (!i)
81701 seq_line(m, '-', 40-namelen, namelen);
81702
81703 - snprintf(ip, sizeof(ip), "[<%p>]",
81704 + snprintf(ip, sizeof(ip), "[<%pK>]",
81705 (void *)class->contending_point[i]);
81706 seq_printf(m, "%40s %14lu %29s %pS\n",
81707 name, stats->contending_point[i],
81708 diff --git a/kernel/module.c b/kernel/module.c
81709 index 2069158..71101bb 100644
81710 --- a/kernel/module.c
81711 +++ b/kernel/module.c
81712 @@ -61,6 +61,7 @@
81713 #include <linux/pfn.h>
81714 #include <linux/bsearch.h>
81715 #include <linux/fips.h>
81716 +#include <linux/grsecurity.h>
81717 #include <uapi/linux/module.h>
81718 #include "module-internal.h"
81719
81720 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81721
81722 /* Bounds of module allocation, for speeding __module_address.
81723 * Protected by module_mutex. */
81724 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81725 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81726 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81727
81728 int register_module_notifier(struct notifier_block * nb)
81729 {
81730 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81731 return true;
81732
81733 list_for_each_entry_rcu(mod, &modules, list) {
81734 - struct symsearch arr[] = {
81735 + struct symsearch modarr[] = {
81736 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81737 NOT_GPL_ONLY, false },
81738 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81739 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81740 if (mod->state == MODULE_STATE_UNFORMED)
81741 continue;
81742
81743 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81744 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81745 return true;
81746 }
81747 return false;
81748 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81749 if (!pcpusec->sh_size)
81750 return 0;
81751
81752 - if (align > PAGE_SIZE) {
81753 + if (align-1 >= PAGE_SIZE) {
81754 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81755 mod->name, align, PAGE_SIZE);
81756 align = PAGE_SIZE;
81757 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81758 static ssize_t show_coresize(struct module_attribute *mattr,
81759 struct module_kobject *mk, char *buffer)
81760 {
81761 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81762 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81763 }
81764
81765 static struct module_attribute modinfo_coresize =
81766 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81767 static ssize_t show_initsize(struct module_attribute *mattr,
81768 struct module_kobject *mk, char *buffer)
81769 {
81770 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81771 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81772 }
81773
81774 static struct module_attribute modinfo_initsize =
81775 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81776 */
81777 #ifdef CONFIG_SYSFS
81778
81779 -#ifdef CONFIG_KALLSYMS
81780 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81781 static inline bool sect_empty(const Elf_Shdr *sect)
81782 {
81783 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81784 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81785 {
81786 unsigned int notes, loaded, i;
81787 struct module_notes_attrs *notes_attrs;
81788 - struct bin_attribute *nattr;
81789 + bin_attribute_no_const *nattr;
81790
81791 /* failed to create section attributes, so can't create notes */
81792 if (!mod->sect_attrs)
81793 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81794 static int module_add_modinfo_attrs(struct module *mod)
81795 {
81796 struct module_attribute *attr;
81797 - struct module_attribute *temp_attr;
81798 + module_attribute_no_const *temp_attr;
81799 int error = 0;
81800 int i;
81801
81802 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81803
81804 static void unset_module_core_ro_nx(struct module *mod)
81805 {
81806 - set_page_attributes(mod->module_core + mod->core_text_size,
81807 - mod->module_core + mod->core_size,
81808 + set_page_attributes(mod->module_core_rw,
81809 + mod->module_core_rw + mod->core_size_rw,
81810 set_memory_x);
81811 - set_page_attributes(mod->module_core,
81812 - mod->module_core + mod->core_ro_size,
81813 + set_page_attributes(mod->module_core_rx,
81814 + mod->module_core_rx + mod->core_size_rx,
81815 set_memory_rw);
81816 }
81817
81818 static void unset_module_init_ro_nx(struct module *mod)
81819 {
81820 - set_page_attributes(mod->module_init + mod->init_text_size,
81821 - mod->module_init + mod->init_size,
81822 + set_page_attributes(mod->module_init_rw,
81823 + mod->module_init_rw + mod->init_size_rw,
81824 set_memory_x);
81825 - set_page_attributes(mod->module_init,
81826 - mod->module_init + mod->init_ro_size,
81827 + set_page_attributes(mod->module_init_rx,
81828 + mod->module_init_rx + mod->init_size_rx,
81829 set_memory_rw);
81830 }
81831
81832 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81833 list_for_each_entry_rcu(mod, &modules, list) {
81834 if (mod->state == MODULE_STATE_UNFORMED)
81835 continue;
81836 - if ((mod->module_core) && (mod->core_text_size)) {
81837 - set_page_attributes(mod->module_core,
81838 - mod->module_core + mod->core_text_size,
81839 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81840 + set_page_attributes(mod->module_core_rx,
81841 + mod->module_core_rx + mod->core_size_rx,
81842 set_memory_rw);
81843 }
81844 - if ((mod->module_init) && (mod->init_text_size)) {
81845 - set_page_attributes(mod->module_init,
81846 - mod->module_init + mod->init_text_size,
81847 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81848 + set_page_attributes(mod->module_init_rx,
81849 + mod->module_init_rx + mod->init_size_rx,
81850 set_memory_rw);
81851 }
81852 }
81853 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81854 list_for_each_entry_rcu(mod, &modules, list) {
81855 if (mod->state == MODULE_STATE_UNFORMED)
81856 continue;
81857 - if ((mod->module_core) && (mod->core_text_size)) {
81858 - set_page_attributes(mod->module_core,
81859 - mod->module_core + mod->core_text_size,
81860 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81861 + set_page_attributes(mod->module_core_rx,
81862 + mod->module_core_rx + mod->core_size_rx,
81863 set_memory_ro);
81864 }
81865 - if ((mod->module_init) && (mod->init_text_size)) {
81866 - set_page_attributes(mod->module_init,
81867 - mod->module_init + mod->init_text_size,
81868 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81869 + set_page_attributes(mod->module_init_rx,
81870 + mod->module_init_rx + mod->init_size_rx,
81871 set_memory_ro);
81872 }
81873 }
81874 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81875
81876 /* This may be NULL, but that's OK */
81877 unset_module_init_ro_nx(mod);
81878 - module_free(mod, mod->module_init);
81879 + module_free(mod, mod->module_init_rw);
81880 + module_free_exec(mod, mod->module_init_rx);
81881 kfree(mod->args);
81882 percpu_modfree(mod);
81883
81884 /* Free lock-classes: */
81885 - lockdep_free_key_range(mod->module_core, mod->core_size);
81886 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81887 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81888
81889 /* Finally, free the core (containing the module structure) */
81890 unset_module_core_ro_nx(mod);
81891 - module_free(mod, mod->module_core);
81892 + module_free_exec(mod, mod->module_core_rx);
81893 + module_free(mod, mod->module_core_rw);
81894
81895 #ifdef CONFIG_MPU
81896 update_protections(current->mm);
81897 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81898 int ret = 0;
81899 const struct kernel_symbol *ksym;
81900
81901 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81902 + int is_fs_load = 0;
81903 + int register_filesystem_found = 0;
81904 + char *p;
81905 +
81906 + p = strstr(mod->args, "grsec_modharden_fs");
81907 + if (p) {
81908 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81909 + /* copy \0 as well */
81910 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81911 + is_fs_load = 1;
81912 + }
81913 +#endif
81914 +
81915 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81916 const char *name = info->strtab + sym[i].st_name;
81917
81918 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81919 + /* it's a real shame this will never get ripped and copied
81920 + upstream! ;(
81921 + */
81922 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81923 + register_filesystem_found = 1;
81924 +#endif
81925 +
81926 switch (sym[i].st_shndx) {
81927 case SHN_COMMON:
81928 /* We compiled with -fno-common. These are not
81929 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81930 ksym = resolve_symbol_wait(mod, info, name);
81931 /* Ok if resolved. */
81932 if (ksym && !IS_ERR(ksym)) {
81933 + pax_open_kernel();
81934 sym[i].st_value = ksym->value;
81935 + pax_close_kernel();
81936 break;
81937 }
81938
81939 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81940 secbase = (unsigned long)mod_percpu(mod);
81941 else
81942 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81943 + pax_open_kernel();
81944 sym[i].st_value += secbase;
81945 + pax_close_kernel();
81946 break;
81947 }
81948 }
81949
81950 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81951 + if (is_fs_load && !register_filesystem_found) {
81952 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81953 + ret = -EPERM;
81954 + }
81955 +#endif
81956 +
81957 return ret;
81958 }
81959
81960 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81961 || s->sh_entsize != ~0UL
81962 || strstarts(sname, ".init"))
81963 continue;
81964 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81965 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81966 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81967 + else
81968 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81969 pr_debug("\t%s\n", sname);
81970 }
81971 - switch (m) {
81972 - case 0: /* executable */
81973 - mod->core_size = debug_align(mod->core_size);
81974 - mod->core_text_size = mod->core_size;
81975 - break;
81976 - case 1: /* RO: text and ro-data */
81977 - mod->core_size = debug_align(mod->core_size);
81978 - mod->core_ro_size = mod->core_size;
81979 - break;
81980 - case 3: /* whole core */
81981 - mod->core_size = debug_align(mod->core_size);
81982 - break;
81983 - }
81984 }
81985
81986 pr_debug("Init section allocation order:\n");
81987 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81988 || s->sh_entsize != ~0UL
81989 || !strstarts(sname, ".init"))
81990 continue;
81991 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81992 - | INIT_OFFSET_MASK);
81993 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81994 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81995 + else
81996 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81997 + s->sh_entsize |= INIT_OFFSET_MASK;
81998 pr_debug("\t%s\n", sname);
81999 }
82000 - switch (m) {
82001 - case 0: /* executable */
82002 - mod->init_size = debug_align(mod->init_size);
82003 - mod->init_text_size = mod->init_size;
82004 - break;
82005 - case 1: /* RO: text and ro-data */
82006 - mod->init_size = debug_align(mod->init_size);
82007 - mod->init_ro_size = mod->init_size;
82008 - break;
82009 - case 3: /* whole init */
82010 - mod->init_size = debug_align(mod->init_size);
82011 - break;
82012 - }
82013 }
82014 }
82015
82016 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82017
82018 /* Put symbol section at end of init part of module. */
82019 symsect->sh_flags |= SHF_ALLOC;
82020 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
82021 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
82022 info->index.sym) | INIT_OFFSET_MASK;
82023 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
82024
82025 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82026 }
82027
82028 /* Append room for core symbols at end of core part. */
82029 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
82030 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
82031 - mod->core_size += strtab_size;
82032 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
82033 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
82034 + mod->core_size_rx += strtab_size;
82035
82036 /* Put string table section at end of init part of module. */
82037 strsect->sh_flags |= SHF_ALLOC;
82038 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
82039 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
82040 info->index.str) | INIT_OFFSET_MASK;
82041 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
82042 }
82043 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82044 /* Make sure we get permanent strtab: don't use info->strtab. */
82045 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
82046
82047 + pax_open_kernel();
82048 +
82049 /* Set types up while we still have access to sections. */
82050 for (i = 0; i < mod->num_symtab; i++)
82051 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
82052
82053 - mod->core_symtab = dst = mod->module_core + info->symoffs;
82054 - mod->core_strtab = s = mod->module_core + info->stroffs;
82055 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
82056 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
82057 src = mod->symtab;
82058 for (ndst = i = 0; i < mod->num_symtab; i++) {
82059 if (i == 0 ||
82060 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82061 }
82062 }
82063 mod->core_num_syms = ndst;
82064 +
82065 + pax_close_kernel();
82066 }
82067 #else
82068 static inline void layout_symtab(struct module *mod, struct load_info *info)
82069 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
82070 return vmalloc_exec(size);
82071 }
82072
82073 -static void *module_alloc_update_bounds(unsigned long size)
82074 +static void *module_alloc_update_bounds_rw(unsigned long size)
82075 {
82076 void *ret = module_alloc(size);
82077
82078 if (ret) {
82079 mutex_lock(&module_mutex);
82080 /* Update module bounds. */
82081 - if ((unsigned long)ret < module_addr_min)
82082 - module_addr_min = (unsigned long)ret;
82083 - if ((unsigned long)ret + size > module_addr_max)
82084 - module_addr_max = (unsigned long)ret + size;
82085 + if ((unsigned long)ret < module_addr_min_rw)
82086 + module_addr_min_rw = (unsigned long)ret;
82087 + if ((unsigned long)ret + size > module_addr_max_rw)
82088 + module_addr_max_rw = (unsigned long)ret + size;
82089 + mutex_unlock(&module_mutex);
82090 + }
82091 + return ret;
82092 +}
82093 +
82094 +static void *module_alloc_update_bounds_rx(unsigned long size)
82095 +{
82096 + void *ret = module_alloc_exec(size);
82097 +
82098 + if (ret) {
82099 + mutex_lock(&module_mutex);
82100 + /* Update module bounds. */
82101 + if ((unsigned long)ret < module_addr_min_rx)
82102 + module_addr_min_rx = (unsigned long)ret;
82103 + if ((unsigned long)ret + size > module_addr_max_rx)
82104 + module_addr_max_rx = (unsigned long)ret + size;
82105 mutex_unlock(&module_mutex);
82106 }
82107 return ret;
82108 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
82109 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82110 {
82111 const char *modmagic = get_modinfo(info, "vermagic");
82112 + const char *license = get_modinfo(info, "license");
82113 int err;
82114
82115 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
82116 + if (!license || !license_is_gpl_compatible(license))
82117 + return -ENOEXEC;
82118 +#endif
82119 +
82120 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
82121 modmagic = NULL;
82122
82123 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82124 }
82125
82126 /* Set up license info based on the info section */
82127 - set_license(mod, get_modinfo(info, "license"));
82128 + set_license(mod, license);
82129
82130 return 0;
82131 }
82132 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
82133 void *ptr;
82134
82135 /* Do the allocs. */
82136 - ptr = module_alloc_update_bounds(mod->core_size);
82137 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
82138 /*
82139 * The pointer to this block is stored in the module structure
82140 * which is inside the block. Just mark it as not being a
82141 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
82142 if (!ptr)
82143 return -ENOMEM;
82144
82145 - memset(ptr, 0, mod->core_size);
82146 - mod->module_core = ptr;
82147 + memset(ptr, 0, mod->core_size_rw);
82148 + mod->module_core_rw = ptr;
82149
82150 - if (mod->init_size) {
82151 - ptr = module_alloc_update_bounds(mod->init_size);
82152 + if (mod->init_size_rw) {
82153 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
82154 /*
82155 * The pointer to this block is stored in the module structure
82156 * which is inside the block. This block doesn't need to be
82157 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
82158 */
82159 kmemleak_ignore(ptr);
82160 if (!ptr) {
82161 - module_free(mod, mod->module_core);
82162 + module_free(mod, mod->module_core_rw);
82163 return -ENOMEM;
82164 }
82165 - memset(ptr, 0, mod->init_size);
82166 - mod->module_init = ptr;
82167 + memset(ptr, 0, mod->init_size_rw);
82168 + mod->module_init_rw = ptr;
82169 } else
82170 - mod->module_init = NULL;
82171 + mod->module_init_rw = NULL;
82172 +
82173 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
82174 + kmemleak_not_leak(ptr);
82175 + if (!ptr) {
82176 + if (mod->module_init_rw)
82177 + module_free(mod, mod->module_init_rw);
82178 + module_free(mod, mod->module_core_rw);
82179 + return -ENOMEM;
82180 + }
82181 +
82182 + pax_open_kernel();
82183 + memset(ptr, 0, mod->core_size_rx);
82184 + pax_close_kernel();
82185 + mod->module_core_rx = ptr;
82186 +
82187 + if (mod->init_size_rx) {
82188 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
82189 + kmemleak_ignore(ptr);
82190 + if (!ptr && mod->init_size_rx) {
82191 + module_free_exec(mod, mod->module_core_rx);
82192 + if (mod->module_init_rw)
82193 + module_free(mod, mod->module_init_rw);
82194 + module_free(mod, mod->module_core_rw);
82195 + return -ENOMEM;
82196 + }
82197 +
82198 + pax_open_kernel();
82199 + memset(ptr, 0, mod->init_size_rx);
82200 + pax_close_kernel();
82201 + mod->module_init_rx = ptr;
82202 + } else
82203 + mod->module_init_rx = NULL;
82204
82205 /* Transfer each section which specifies SHF_ALLOC */
82206 pr_debug("final section addresses:\n");
82207 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
82208 if (!(shdr->sh_flags & SHF_ALLOC))
82209 continue;
82210
82211 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
82212 - dest = mod->module_init
82213 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82214 - else
82215 - dest = mod->module_core + shdr->sh_entsize;
82216 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
82217 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82218 + dest = mod->module_init_rw
82219 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82220 + else
82221 + dest = mod->module_init_rx
82222 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82223 + } else {
82224 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82225 + dest = mod->module_core_rw + shdr->sh_entsize;
82226 + else
82227 + dest = mod->module_core_rx + shdr->sh_entsize;
82228 + }
82229 +
82230 + if (shdr->sh_type != SHT_NOBITS) {
82231 +
82232 +#ifdef CONFIG_PAX_KERNEXEC
82233 +#ifdef CONFIG_X86_64
82234 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
82235 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
82236 +#endif
82237 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
82238 + pax_open_kernel();
82239 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82240 + pax_close_kernel();
82241 + } else
82242 +#endif
82243
82244 - if (shdr->sh_type != SHT_NOBITS)
82245 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82246 + }
82247 /* Update sh_addr to point to copy in image. */
82248 - shdr->sh_addr = (unsigned long)dest;
82249 +
82250 +#ifdef CONFIG_PAX_KERNEXEC
82251 + if (shdr->sh_flags & SHF_EXECINSTR)
82252 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
82253 + else
82254 +#endif
82255 +
82256 + shdr->sh_addr = (unsigned long)dest;
82257 pr_debug("\t0x%lx %s\n",
82258 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
82259 }
82260 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
82261 * Do it before processing of module parameters, so the module
82262 * can provide parameter accessor functions of its own.
82263 */
82264 - if (mod->module_init)
82265 - flush_icache_range((unsigned long)mod->module_init,
82266 - (unsigned long)mod->module_init
82267 - + mod->init_size);
82268 - flush_icache_range((unsigned long)mod->module_core,
82269 - (unsigned long)mod->module_core + mod->core_size);
82270 + if (mod->module_init_rx)
82271 + flush_icache_range((unsigned long)mod->module_init_rx,
82272 + (unsigned long)mod->module_init_rx
82273 + + mod->init_size_rx);
82274 + flush_icache_range((unsigned long)mod->module_core_rx,
82275 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
82276
82277 set_fs(old_fs);
82278 }
82279 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
82280 static void module_deallocate(struct module *mod, struct load_info *info)
82281 {
82282 percpu_modfree(mod);
82283 - module_free(mod, mod->module_init);
82284 - module_free(mod, mod->module_core);
82285 + module_free_exec(mod, mod->module_init_rx);
82286 + module_free_exec(mod, mod->module_core_rx);
82287 + module_free(mod, mod->module_init_rw);
82288 + module_free(mod, mod->module_core_rw);
82289 }
82290
82291 int __weak module_finalize(const Elf_Ehdr *hdr,
82292 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
82293 static int post_relocation(struct module *mod, const struct load_info *info)
82294 {
82295 /* Sort exception table now relocations are done. */
82296 + pax_open_kernel();
82297 sort_extable(mod->extable, mod->extable + mod->num_exentries);
82298 + pax_close_kernel();
82299
82300 /* Copy relocated percpu area over. */
82301 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
82302 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
82303 MODULE_STATE_COMING, mod);
82304
82305 /* Set RO and NX regions for core */
82306 - set_section_ro_nx(mod->module_core,
82307 - mod->core_text_size,
82308 - mod->core_ro_size,
82309 - mod->core_size);
82310 + set_section_ro_nx(mod->module_core_rx,
82311 + mod->core_size_rx,
82312 + mod->core_size_rx,
82313 + mod->core_size_rx);
82314
82315 /* Set RO and NX regions for init */
82316 - set_section_ro_nx(mod->module_init,
82317 - mod->init_text_size,
82318 - mod->init_ro_size,
82319 - mod->init_size);
82320 + set_section_ro_nx(mod->module_init_rx,
82321 + mod->init_size_rx,
82322 + mod->init_size_rx,
82323 + mod->init_size_rx);
82324
82325 do_mod_ctors(mod);
82326 /* Start the module */
82327 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
82328 mod->strtab = mod->core_strtab;
82329 #endif
82330 unset_module_init_ro_nx(mod);
82331 - module_free(mod, mod->module_init);
82332 - mod->module_init = NULL;
82333 - mod->init_size = 0;
82334 - mod->init_ro_size = 0;
82335 - mod->init_text_size = 0;
82336 + module_free(mod, mod->module_init_rw);
82337 + module_free_exec(mod, mod->module_init_rx);
82338 + mod->module_init_rw = NULL;
82339 + mod->module_init_rx = NULL;
82340 + mod->init_size_rw = 0;
82341 + mod->init_size_rx = 0;
82342 mutex_unlock(&module_mutex);
82343 wake_up_all(&module_wq);
82344
82345 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
82346 if (err)
82347 goto free_unload;
82348
82349 + /* Now copy in args */
82350 + mod->args = strndup_user(uargs, ~0UL >> 1);
82351 + if (IS_ERR(mod->args)) {
82352 + err = PTR_ERR(mod->args);
82353 + goto free_unload;
82354 + }
82355 +
82356 /* Set up MODINFO_ATTR fields */
82357 setup_modinfo(mod, info);
82358
82359 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82360 + {
82361 + char *p, *p2;
82362 +
82363 + if (strstr(mod->args, "grsec_modharden_netdev")) {
82364 + 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);
82365 + err = -EPERM;
82366 + goto free_modinfo;
82367 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
82368 + p += sizeof("grsec_modharden_normal") - 1;
82369 + p2 = strstr(p, "_");
82370 + if (p2) {
82371 + *p2 = '\0';
82372 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
82373 + *p2 = '_';
82374 + }
82375 + err = -EPERM;
82376 + goto free_modinfo;
82377 + }
82378 + }
82379 +#endif
82380 +
82381 /* Fix up syms, so that st_value is a pointer to location. */
82382 err = simplify_symbols(mod, info);
82383 if (err < 0)
82384 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
82385
82386 flush_module_icache(mod);
82387
82388 - /* Now copy in args */
82389 - mod->args = strndup_user(uargs, ~0UL >> 1);
82390 - if (IS_ERR(mod->args)) {
82391 - err = PTR_ERR(mod->args);
82392 - goto free_arch_cleanup;
82393 - }
82394 -
82395 dynamic_debug_setup(info->debug, info->num_debug);
82396
82397 /* Finally it's fully formed, ready to start executing. */
82398 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
82399 ddebug_cleanup:
82400 dynamic_debug_remove(info->debug);
82401 synchronize_sched();
82402 - kfree(mod->args);
82403 - free_arch_cleanup:
82404 module_arch_cleanup(mod);
82405 free_modinfo:
82406 free_modinfo(mod);
82407 + kfree(mod->args);
82408 free_unload:
82409 module_unload_free(mod);
82410 unlink_mod:
82411 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
82412 unsigned long nextval;
82413
82414 /* At worse, next value is at end of module */
82415 - if (within_module_init(addr, mod))
82416 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
82417 + if (within_module_init_rx(addr, mod))
82418 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
82419 + else if (within_module_init_rw(addr, mod))
82420 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
82421 + else if (within_module_core_rx(addr, mod))
82422 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
82423 + else if (within_module_core_rw(addr, mod))
82424 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
82425 else
82426 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
82427 + return NULL;
82428
82429 /* Scan for closest preceding symbol, and next symbol. (ELF
82430 starts real symbols at 1). */
82431 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
82432 return 0;
82433
82434 seq_printf(m, "%s %u",
82435 - mod->name, mod->init_size + mod->core_size);
82436 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
82437 print_unload_info(m, mod);
82438
82439 /* Informative for users. */
82440 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
82441 mod->state == MODULE_STATE_COMING ? "Loading":
82442 "Live");
82443 /* Used by oprofile and other similar tools. */
82444 - seq_printf(m, " 0x%pK", mod->module_core);
82445 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
82446
82447 /* Taints info */
82448 if (mod->taints)
82449 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
82450
82451 static int __init proc_modules_init(void)
82452 {
82453 +#ifndef CONFIG_GRKERNSEC_HIDESYM
82454 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82455 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82456 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82457 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
82458 +#else
82459 proc_create("modules", 0, NULL, &proc_modules_operations);
82460 +#endif
82461 +#else
82462 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82463 +#endif
82464 return 0;
82465 }
82466 module_init(proc_modules_init);
82467 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
82468 {
82469 struct module *mod;
82470
82471 - if (addr < module_addr_min || addr > module_addr_max)
82472 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
82473 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
82474 return NULL;
82475
82476 list_for_each_entry_rcu(mod, &modules, list) {
82477 if (mod->state == MODULE_STATE_UNFORMED)
82478 continue;
82479 - if (within_module_core(addr, mod)
82480 - || within_module_init(addr, mod))
82481 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82482 return mod;
82483 }
82484 return NULL;
82485 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82486 */
82487 struct module *__module_text_address(unsigned long addr)
82488 {
82489 - struct module *mod = __module_address(addr);
82490 + struct module *mod;
82491 +
82492 +#ifdef CONFIG_X86_32
82493 + addr = ktla_ktva(addr);
82494 +#endif
82495 +
82496 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82497 + return NULL;
82498 +
82499 + mod = __module_address(addr);
82500 +
82501 if (mod) {
82502 /* Make sure it's within the text section. */
82503 - if (!within(addr, mod->module_init, mod->init_text_size)
82504 - && !within(addr, mod->module_core, mod->core_text_size))
82505 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82506 mod = NULL;
82507 }
82508 return mod;
82509 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82510 index 7e3443f..b2a1e6b 100644
82511 --- a/kernel/mutex-debug.c
82512 +++ b/kernel/mutex-debug.c
82513 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82514 }
82515
82516 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82517 - struct thread_info *ti)
82518 + struct task_struct *task)
82519 {
82520 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82521
82522 /* Mark the current thread as blocked on the lock: */
82523 - ti->task->blocked_on = waiter;
82524 + task->blocked_on = waiter;
82525 }
82526
82527 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82528 - struct thread_info *ti)
82529 + struct task_struct *task)
82530 {
82531 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82532 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82533 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82534 - ti->task->blocked_on = NULL;
82535 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82536 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82537 + task->blocked_on = NULL;
82538
82539 list_del_init(&waiter->list);
82540 waiter->task = NULL;
82541 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82542 index 0799fd3..d06ae3b 100644
82543 --- a/kernel/mutex-debug.h
82544 +++ b/kernel/mutex-debug.h
82545 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82546 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82547 extern void debug_mutex_add_waiter(struct mutex *lock,
82548 struct mutex_waiter *waiter,
82549 - struct thread_info *ti);
82550 + struct task_struct *task);
82551 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82552 - struct thread_info *ti);
82553 + struct task_struct *task);
82554 extern void debug_mutex_unlock(struct mutex *lock);
82555 extern void debug_mutex_init(struct mutex *lock, const char *name,
82556 struct lock_class_key *key);
82557 diff --git a/kernel/mutex.c b/kernel/mutex.c
82558 index a2b80f1..e91d35c 100644
82559 --- a/kernel/mutex.c
82560 +++ b/kernel/mutex.c
82561 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82562 node->locked = 1;
82563 return;
82564 }
82565 - ACCESS_ONCE(prev->next) = node;
82566 + ACCESS_ONCE_RW(prev->next) = node;
82567 smp_wmb();
82568 /* Wait until the lock holder passes the lock down */
82569 while (!ACCESS_ONCE(node->locked))
82570 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82571 while (!(next = ACCESS_ONCE(node->next)))
82572 arch_mutex_cpu_relax();
82573 }
82574 - ACCESS_ONCE(next->locked) = 1;
82575 + ACCESS_ONCE_RW(next->locked) = 1;
82576 smp_wmb();
82577 }
82578
82579 @@ -514,7 +514,7 @@ slowpath:
82580 spin_lock_mutex(&lock->wait_lock, flags);
82581
82582 debug_mutex_lock_common(lock, &waiter);
82583 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82584 + debug_mutex_add_waiter(lock, &waiter, task);
82585
82586 /* add waiting tasks to the end of the waitqueue (FIFO): */
82587 list_add_tail(&waiter.list, &lock->wait_list);
82588 @@ -565,7 +565,7 @@ slowpath:
82589 done:
82590 lock_acquired(&lock->dep_map, ip);
82591 /* got the lock - rejoice! */
82592 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82593 + mutex_remove_waiter(lock, &waiter, task);
82594 mutex_set_owner(lock);
82595
82596 if (use_ww_ctx) {
82597 @@ -604,7 +604,7 @@ done:
82598 return 0;
82599
82600 err:
82601 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82602 + mutex_remove_waiter(lock, &waiter, task);
82603 spin_unlock_mutex(&lock->wait_lock, flags);
82604 debug_mutex_free_waiter(&waiter);
82605 mutex_release(&lock->dep_map, 1, ip);
82606 diff --git a/kernel/notifier.c b/kernel/notifier.c
82607 index 2d5cc4c..d9ea600 100644
82608 --- a/kernel/notifier.c
82609 +++ b/kernel/notifier.c
82610 @@ -5,6 +5,7 @@
82611 #include <linux/rcupdate.h>
82612 #include <linux/vmalloc.h>
82613 #include <linux/reboot.h>
82614 +#include <linux/mm.h>
82615
82616 /*
82617 * Notifier list for kernel code which wants to be called
82618 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82619 while ((*nl) != NULL) {
82620 if (n->priority > (*nl)->priority)
82621 break;
82622 - nl = &((*nl)->next);
82623 + nl = (struct notifier_block **)&((*nl)->next);
82624 }
82625 - n->next = *nl;
82626 + pax_open_kernel();
82627 + *(const void **)&n->next = *nl;
82628 rcu_assign_pointer(*nl, n);
82629 + pax_close_kernel();
82630 return 0;
82631 }
82632
82633 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82634 return 0;
82635 if (n->priority > (*nl)->priority)
82636 break;
82637 - nl = &((*nl)->next);
82638 + nl = (struct notifier_block **)&((*nl)->next);
82639 }
82640 - n->next = *nl;
82641 + pax_open_kernel();
82642 + *(const void **)&n->next = *nl;
82643 rcu_assign_pointer(*nl, n);
82644 + pax_close_kernel();
82645 return 0;
82646 }
82647
82648 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82649 {
82650 while ((*nl) != NULL) {
82651 if ((*nl) == n) {
82652 + pax_open_kernel();
82653 rcu_assign_pointer(*nl, n->next);
82654 + pax_close_kernel();
82655 return 0;
82656 }
82657 - nl = &((*nl)->next);
82658 + nl = (struct notifier_block **)&((*nl)->next);
82659 }
82660 return -ENOENT;
82661 }
82662 diff --git a/kernel/panic.c b/kernel/panic.c
82663 index 8018646..b6a5b4f 100644
82664 --- a/kernel/panic.c
82665 +++ b/kernel/panic.c
82666 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82667 disable_trace_on_warning();
82668
82669 pr_warn("------------[ cut here ]------------\n");
82670 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82671 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82672 raw_smp_processor_id(), current->pid, file, line, caller);
82673
82674 if (args)
82675 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82676 */
82677 void __stack_chk_fail(void)
82678 {
82679 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82680 + dump_stack();
82681 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82682 __builtin_return_address(0));
82683 }
82684 EXPORT_SYMBOL(__stack_chk_fail);
82685 diff --git a/kernel/pid.c b/kernel/pid.c
82686 index ebe5e80..5d6d634 100644
82687 --- a/kernel/pid.c
82688 +++ b/kernel/pid.c
82689 @@ -33,6 +33,7 @@
82690 #include <linux/rculist.h>
82691 #include <linux/bootmem.h>
82692 #include <linux/hash.h>
82693 +#include <linux/security.h>
82694 #include <linux/pid_namespace.h>
82695 #include <linux/init_task.h>
82696 #include <linux/syscalls.h>
82697 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82698
82699 int pid_max = PID_MAX_DEFAULT;
82700
82701 -#define RESERVED_PIDS 300
82702 +#define RESERVED_PIDS 500
82703
82704 int pid_max_min = RESERVED_PIDS + 1;
82705 int pid_max_max = PID_MAX_LIMIT;
82706 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82707 */
82708 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82709 {
82710 + struct task_struct *task;
82711 +
82712 rcu_lockdep_assert(rcu_read_lock_held(),
82713 "find_task_by_pid_ns() needs rcu_read_lock()"
82714 " protection");
82715 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82716 +
82717 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82718 +
82719 + if (gr_pid_is_chrooted(task))
82720 + return NULL;
82721 +
82722 + return task;
82723 }
82724
82725 struct task_struct *find_task_by_vpid(pid_t vnr)
82726 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82727 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82728 }
82729
82730 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82731 +{
82732 + rcu_lockdep_assert(rcu_read_lock_held(),
82733 + "find_task_by_pid_ns() needs rcu_read_lock()"
82734 + " protection");
82735 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82736 +}
82737 +
82738 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82739 {
82740 struct pid *pid;
82741 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82742 index 601bb36..f7e6f34 100644
82743 --- a/kernel/pid_namespace.c
82744 +++ b/kernel/pid_namespace.c
82745 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82746 void __user *buffer, size_t *lenp, loff_t *ppos)
82747 {
82748 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82749 - struct ctl_table tmp = *table;
82750 + ctl_table_no_const tmp = *table;
82751
82752 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82753 return -EPERM;
82754 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82755 index c7f31aa..2b44977 100644
82756 --- a/kernel/posix-cpu-timers.c
82757 +++ b/kernel/posix-cpu-timers.c
82758 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82759
82760 static __init int init_posix_cpu_timers(void)
82761 {
82762 - struct k_clock process = {
82763 + static struct k_clock process = {
82764 .clock_getres = process_cpu_clock_getres,
82765 .clock_get = process_cpu_clock_get,
82766 .timer_create = process_cpu_timer_create,
82767 .nsleep = process_cpu_nsleep,
82768 .nsleep_restart = process_cpu_nsleep_restart,
82769 };
82770 - struct k_clock thread = {
82771 + static struct k_clock thread = {
82772 .clock_getres = thread_cpu_clock_getres,
82773 .clock_get = thread_cpu_clock_get,
82774 .timer_create = thread_cpu_timer_create,
82775 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82776 index 424c2d4..679242f 100644
82777 --- a/kernel/posix-timers.c
82778 +++ b/kernel/posix-timers.c
82779 @@ -43,6 +43,7 @@
82780 #include <linux/hash.h>
82781 #include <linux/posix-clock.h>
82782 #include <linux/posix-timers.h>
82783 +#include <linux/grsecurity.h>
82784 #include <linux/syscalls.h>
82785 #include <linux/wait.h>
82786 #include <linux/workqueue.h>
82787 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82788 * which we beg off on and pass to do_sys_settimeofday().
82789 */
82790
82791 -static struct k_clock posix_clocks[MAX_CLOCKS];
82792 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82793
82794 /*
82795 * These ones are defined below.
82796 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82797 */
82798 static __init int init_posix_timers(void)
82799 {
82800 - struct k_clock clock_realtime = {
82801 + static struct k_clock clock_realtime = {
82802 .clock_getres = hrtimer_get_res,
82803 .clock_get = posix_clock_realtime_get,
82804 .clock_set = posix_clock_realtime_set,
82805 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82806 .timer_get = common_timer_get,
82807 .timer_del = common_timer_del,
82808 };
82809 - struct k_clock clock_monotonic = {
82810 + static struct k_clock clock_monotonic = {
82811 .clock_getres = hrtimer_get_res,
82812 .clock_get = posix_ktime_get_ts,
82813 .nsleep = common_nsleep,
82814 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82815 .timer_get = common_timer_get,
82816 .timer_del = common_timer_del,
82817 };
82818 - struct k_clock clock_monotonic_raw = {
82819 + static struct k_clock clock_monotonic_raw = {
82820 .clock_getres = hrtimer_get_res,
82821 .clock_get = posix_get_monotonic_raw,
82822 };
82823 - struct k_clock clock_realtime_coarse = {
82824 + static struct k_clock clock_realtime_coarse = {
82825 .clock_getres = posix_get_coarse_res,
82826 .clock_get = posix_get_realtime_coarse,
82827 };
82828 - struct k_clock clock_monotonic_coarse = {
82829 + static struct k_clock clock_monotonic_coarse = {
82830 .clock_getres = posix_get_coarse_res,
82831 .clock_get = posix_get_monotonic_coarse,
82832 };
82833 - struct k_clock clock_tai = {
82834 + static struct k_clock clock_tai = {
82835 .clock_getres = hrtimer_get_res,
82836 .clock_get = posix_get_tai,
82837 .nsleep = common_nsleep,
82838 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82839 .timer_get = common_timer_get,
82840 .timer_del = common_timer_del,
82841 };
82842 - struct k_clock clock_boottime = {
82843 + static struct k_clock clock_boottime = {
82844 .clock_getres = hrtimer_get_res,
82845 .clock_get = posix_get_boottime,
82846 .nsleep = common_nsleep,
82847 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82848 return;
82849 }
82850
82851 - posix_clocks[clock_id] = *new_clock;
82852 + posix_clocks[clock_id] = new_clock;
82853 }
82854 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82855
82856 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82857 return (id & CLOCKFD_MASK) == CLOCKFD ?
82858 &clock_posix_dynamic : &clock_posix_cpu;
82859
82860 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82861 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82862 return NULL;
82863 - return &posix_clocks[id];
82864 + return posix_clocks[id];
82865 }
82866
82867 static int common_timer_create(struct k_itimer *new_timer)
82868 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82869 struct k_clock *kc = clockid_to_kclock(which_clock);
82870 struct k_itimer *new_timer;
82871 int error, new_timer_id;
82872 - sigevent_t event;
82873 + sigevent_t event = { };
82874 int it_id_set = IT_ID_NOT_SET;
82875
82876 if (!kc)
82877 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82878 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82879 return -EFAULT;
82880
82881 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82882 + have their clock_set fptr set to a nosettime dummy function
82883 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82884 + call common_clock_set, which calls do_sys_settimeofday, which
82885 + we hook
82886 + */
82887 +
82888 return kc->clock_set(which_clock, &new_tp);
82889 }
82890
82891 diff --git a/kernel/power/process.c b/kernel/power/process.c
82892 index 06ec886..9dba35e 100644
82893 --- a/kernel/power/process.c
82894 +++ b/kernel/power/process.c
82895 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82896 unsigned int elapsed_msecs;
82897 bool wakeup = false;
82898 int sleep_usecs = USEC_PER_MSEC;
82899 + bool timedout = false;
82900
82901 do_gettimeofday(&start);
82902
82903 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82904
82905 while (true) {
82906 todo = 0;
82907 + if (time_after(jiffies, end_time))
82908 + timedout = true;
82909 read_lock(&tasklist_lock);
82910 do_each_thread(g, p) {
82911 if (p == current || !freeze_task(p))
82912 continue;
82913
82914 - if (!freezer_should_skip(p))
82915 + if (!freezer_should_skip(p)) {
82916 todo++;
82917 + if (timedout) {
82918 + printk(KERN_ERR "Task refusing to freeze:\n");
82919 + sched_show_task(p);
82920 + }
82921 + }
82922 } while_each_thread(g, p);
82923 read_unlock(&tasklist_lock);
82924
82925 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82926 todo += wq_busy;
82927 }
82928
82929 - if (!todo || time_after(jiffies, end_time))
82930 + if (!todo || timedout)
82931 break;
82932
82933 if (pm_wakeup_pending()) {
82934 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82935 index 5b5a708..ec7637e 100644
82936 --- a/kernel/printk/printk.c
82937 +++ b/kernel/printk/printk.c
82938 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82939 if (from_file && type != SYSLOG_ACTION_OPEN)
82940 return 0;
82941
82942 +#ifdef CONFIG_GRKERNSEC_DMESG
82943 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82944 + return -EPERM;
82945 +#endif
82946 +
82947 if (syslog_action_restricted(type)) {
82948 if (capable(CAP_SYSLOG))
82949 return 0;
82950 diff --git a/kernel/profile.c b/kernel/profile.c
82951 index 6631e1e..310c266 100644
82952 --- a/kernel/profile.c
82953 +++ b/kernel/profile.c
82954 @@ -37,7 +37,7 @@ struct profile_hit {
82955 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82956 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82957
82958 -static atomic_t *prof_buffer;
82959 +static atomic_unchecked_t *prof_buffer;
82960 static unsigned long prof_len, prof_shift;
82961
82962 int prof_on __read_mostly;
82963 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82964 hits[i].pc = 0;
82965 continue;
82966 }
82967 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82968 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82969 hits[i].hits = hits[i].pc = 0;
82970 }
82971 }
82972 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82973 * Add the current hit(s) and flush the write-queue out
82974 * to the global buffer:
82975 */
82976 - atomic_add(nr_hits, &prof_buffer[pc]);
82977 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82978 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82979 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82980 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82981 hits[i].pc = hits[i].hits = 0;
82982 }
82983 out:
82984 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82985 {
82986 unsigned long pc;
82987 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82988 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82989 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82990 }
82991 #endif /* !CONFIG_SMP */
82992
82993 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82994 return -EFAULT;
82995 buf++; p++; count--; read++;
82996 }
82997 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82998 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82999 if (copy_to_user(buf, (void *)pnt, count))
83000 return -EFAULT;
83001 read += count;
83002 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
83003 }
83004 #endif
83005 profile_discard_flip_buffers();
83006 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
83007 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
83008 return count;
83009 }
83010
83011 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
83012 index a146ee3..ffed4c3 100644
83013 --- a/kernel/ptrace.c
83014 +++ b/kernel/ptrace.c
83015 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
83016 if (seize)
83017 flags |= PT_SEIZED;
83018 rcu_read_lock();
83019 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83020 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83021 flags |= PT_PTRACE_CAP;
83022 rcu_read_unlock();
83023 task->ptrace = flags;
83024 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
83025 break;
83026 return -EIO;
83027 }
83028 - if (copy_to_user(dst, buf, retval))
83029 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
83030 return -EFAULT;
83031 copied += retval;
83032 src += retval;
83033 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
83034 bool seized = child->ptrace & PT_SEIZED;
83035 int ret = -EIO;
83036 siginfo_t siginfo, *si;
83037 - void __user *datavp = (void __user *) data;
83038 + void __user *datavp = (__force void __user *) data;
83039 unsigned long __user *datalp = datavp;
83040 unsigned long flags;
83041
83042 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
83043 goto out;
83044 }
83045
83046 + if (gr_handle_ptrace(child, request)) {
83047 + ret = -EPERM;
83048 + goto out_put_task_struct;
83049 + }
83050 +
83051 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83052 ret = ptrace_attach(child, request, addr, data);
83053 /*
83054 * Some architectures need to do book-keeping after
83055 * a ptrace attach.
83056 */
83057 - if (!ret)
83058 + if (!ret) {
83059 arch_ptrace_attach(child);
83060 + gr_audit_ptrace(child);
83061 + }
83062 goto out_put_task_struct;
83063 }
83064
83065 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
83066 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
83067 if (copied != sizeof(tmp))
83068 return -EIO;
83069 - return put_user(tmp, (unsigned long __user *)data);
83070 + return put_user(tmp, (__force unsigned long __user *)data);
83071 }
83072
83073 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
83074 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
83075 }
83076
83077 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83078 - compat_long_t addr, compat_long_t data)
83079 + compat_ulong_t addr, compat_ulong_t data)
83080 {
83081 struct task_struct *child;
83082 long ret;
83083 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83084 goto out;
83085 }
83086
83087 + if (gr_handle_ptrace(child, request)) {
83088 + ret = -EPERM;
83089 + goto out_put_task_struct;
83090 + }
83091 +
83092 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83093 ret = ptrace_attach(child, request, addr, data);
83094 /*
83095 * Some architectures need to do book-keeping after
83096 * a ptrace attach.
83097 */
83098 - if (!ret)
83099 + if (!ret) {
83100 arch_ptrace_attach(child);
83101 + gr_audit_ptrace(child);
83102 + }
83103 goto out_put_task_struct;
83104 }
83105
83106 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
83107 index cce6ba8..7c758b1f 100644
83108 --- a/kernel/rcupdate.c
83109 +++ b/kernel/rcupdate.c
83110 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
83111 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
83112 */
83113 if (till_stall_check < 3) {
83114 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
83115 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
83116 till_stall_check = 3;
83117 } else if (till_stall_check > 300) {
83118 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
83119 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
83120 till_stall_check = 300;
83121 }
83122 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
83123 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
83124 index aa34411..4832cd4 100644
83125 --- a/kernel/rcutiny.c
83126 +++ b/kernel/rcutiny.c
83127 @@ -45,7 +45,7 @@
83128 /* Forward declarations for rcutiny_plugin.h. */
83129 struct rcu_ctrlblk;
83130 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
83131 -static void rcu_process_callbacks(struct softirq_action *unused);
83132 +static void rcu_process_callbacks(void);
83133 static void __call_rcu(struct rcu_head *head,
83134 void (*func)(struct rcu_head *rcu),
83135 struct rcu_ctrlblk *rcp);
83136 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
83137 false));
83138 }
83139
83140 -static void rcu_process_callbacks(struct softirq_action *unused)
83141 +static __latent_entropy void rcu_process_callbacks(void)
83142 {
83143 __rcu_process_callbacks(&rcu_sched_ctrlblk);
83144 __rcu_process_callbacks(&rcu_bh_ctrlblk);
83145 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
83146 index f4871e5..8ef5741 100644
83147 --- a/kernel/rcutorture.c
83148 +++ b/kernel/rcutorture.c
83149 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
83150 { 0 };
83151 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
83152 { 0 };
83153 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83154 -static atomic_t n_rcu_torture_alloc;
83155 -static atomic_t n_rcu_torture_alloc_fail;
83156 -static atomic_t n_rcu_torture_free;
83157 -static atomic_t n_rcu_torture_mberror;
83158 -static atomic_t n_rcu_torture_error;
83159 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83160 +static atomic_unchecked_t n_rcu_torture_alloc;
83161 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
83162 +static atomic_unchecked_t n_rcu_torture_free;
83163 +static atomic_unchecked_t n_rcu_torture_mberror;
83164 +static atomic_unchecked_t n_rcu_torture_error;
83165 static long n_rcu_torture_barrier_error;
83166 static long n_rcu_torture_boost_ktrerror;
83167 static long n_rcu_torture_boost_rterror;
83168 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
83169
83170 spin_lock_bh(&rcu_torture_lock);
83171 if (list_empty(&rcu_torture_freelist)) {
83172 - atomic_inc(&n_rcu_torture_alloc_fail);
83173 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
83174 spin_unlock_bh(&rcu_torture_lock);
83175 return NULL;
83176 }
83177 - atomic_inc(&n_rcu_torture_alloc);
83178 + atomic_inc_unchecked(&n_rcu_torture_alloc);
83179 p = rcu_torture_freelist.next;
83180 list_del_init(p);
83181 spin_unlock_bh(&rcu_torture_lock);
83182 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
83183 static void
83184 rcu_torture_free(struct rcu_torture *p)
83185 {
83186 - atomic_inc(&n_rcu_torture_free);
83187 + atomic_inc_unchecked(&n_rcu_torture_free);
83188 spin_lock_bh(&rcu_torture_lock);
83189 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
83190 spin_unlock_bh(&rcu_torture_lock);
83191 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
83192 i = rp->rtort_pipe_count;
83193 if (i > RCU_TORTURE_PIPE_LEN)
83194 i = RCU_TORTURE_PIPE_LEN;
83195 - atomic_inc(&rcu_torture_wcount[i]);
83196 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83197 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
83198 rp->rtort_mbtest = 0;
83199 rcu_torture_free(rp);
83200 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
83201 i = rp->rtort_pipe_count;
83202 if (i > RCU_TORTURE_PIPE_LEN)
83203 i = RCU_TORTURE_PIPE_LEN;
83204 - atomic_inc(&rcu_torture_wcount[i]);
83205 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83206 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
83207 rp->rtort_mbtest = 0;
83208 list_del(&rp->rtort_free);
83209 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
83210 i = old_rp->rtort_pipe_count;
83211 if (i > RCU_TORTURE_PIPE_LEN)
83212 i = RCU_TORTURE_PIPE_LEN;
83213 - atomic_inc(&rcu_torture_wcount[i]);
83214 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83215 old_rp->rtort_pipe_count++;
83216 cur_ops->deferred_free(old_rp);
83217 }
83218 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
83219 return;
83220 }
83221 if (p->rtort_mbtest == 0)
83222 - atomic_inc(&n_rcu_torture_mberror);
83223 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83224 spin_lock(&rand_lock);
83225 cur_ops->read_delay(&rand);
83226 n_rcu_torture_timers++;
83227 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
83228 continue;
83229 }
83230 if (p->rtort_mbtest == 0)
83231 - atomic_inc(&n_rcu_torture_mberror);
83232 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83233 cur_ops->read_delay(&rand);
83234 preempt_disable();
83235 pipe_count = p->rtort_pipe_count;
83236 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
83237 rcu_torture_current,
83238 rcu_torture_current_version,
83239 list_empty(&rcu_torture_freelist),
83240 - atomic_read(&n_rcu_torture_alloc),
83241 - atomic_read(&n_rcu_torture_alloc_fail),
83242 - atomic_read(&n_rcu_torture_free));
83243 + atomic_read_unchecked(&n_rcu_torture_alloc),
83244 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
83245 + atomic_read_unchecked(&n_rcu_torture_free));
83246 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
83247 - atomic_read(&n_rcu_torture_mberror),
83248 + atomic_read_unchecked(&n_rcu_torture_mberror),
83249 n_rcu_torture_boost_ktrerror,
83250 n_rcu_torture_boost_rterror);
83251 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
83252 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
83253 n_barrier_attempts,
83254 n_rcu_torture_barrier_error);
83255 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
83256 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
83257 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
83258 n_rcu_torture_barrier_error != 0 ||
83259 n_rcu_torture_boost_ktrerror != 0 ||
83260 n_rcu_torture_boost_rterror != 0 ||
83261 n_rcu_torture_boost_failure != 0 ||
83262 i > 1) {
83263 cnt += sprintf(&page[cnt], "!!! ");
83264 - atomic_inc(&n_rcu_torture_error);
83265 + atomic_inc_unchecked(&n_rcu_torture_error);
83266 WARN_ON_ONCE(1);
83267 }
83268 cnt += sprintf(&page[cnt], "Reader Pipe: ");
83269 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
83270 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
83271 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83272 cnt += sprintf(&page[cnt], " %d",
83273 - atomic_read(&rcu_torture_wcount[i]));
83274 + atomic_read_unchecked(&rcu_torture_wcount[i]));
83275 }
83276 cnt += sprintf(&page[cnt], "\n");
83277 if (cur_ops->stats)
83278 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
83279
83280 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
83281
83282 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83283 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83284 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
83285 else if (n_online_successes != n_online_attempts ||
83286 n_offline_successes != n_offline_attempts)
83287 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
83288
83289 rcu_torture_current = NULL;
83290 rcu_torture_current_version = 0;
83291 - atomic_set(&n_rcu_torture_alloc, 0);
83292 - atomic_set(&n_rcu_torture_alloc_fail, 0);
83293 - atomic_set(&n_rcu_torture_free, 0);
83294 - atomic_set(&n_rcu_torture_mberror, 0);
83295 - atomic_set(&n_rcu_torture_error, 0);
83296 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
83297 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
83298 + atomic_set_unchecked(&n_rcu_torture_free, 0);
83299 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
83300 + atomic_set_unchecked(&n_rcu_torture_error, 0);
83301 n_rcu_torture_barrier_error = 0;
83302 n_rcu_torture_boost_ktrerror = 0;
83303 n_rcu_torture_boost_rterror = 0;
83304 n_rcu_torture_boost_failure = 0;
83305 n_rcu_torture_boosts = 0;
83306 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
83307 - atomic_set(&rcu_torture_wcount[i], 0);
83308 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
83309 for_each_possible_cpu(cpu) {
83310 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83311 per_cpu(rcu_torture_count, cpu)[i] = 0;
83312 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
83313 index 068de3a..5e7db2f 100644
83314 --- a/kernel/rcutree.c
83315 +++ b/kernel/rcutree.c
83316 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
83317 rcu_prepare_for_idle(smp_processor_id());
83318 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83319 smp_mb__before_atomic_inc(); /* See above. */
83320 - atomic_inc(&rdtp->dynticks);
83321 + atomic_inc_unchecked(&rdtp->dynticks);
83322 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
83323 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83324 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83325
83326 /*
83327 * It is illegal to enter an extended quiescent state while
83328 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
83329 int user)
83330 {
83331 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
83332 - atomic_inc(&rdtp->dynticks);
83333 + atomic_inc_unchecked(&rdtp->dynticks);
83334 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83335 smp_mb__after_atomic_inc(); /* See above. */
83336 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83337 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83338 rcu_cleanup_after_idle(smp_processor_id());
83339 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
83340 if (!user && !is_idle_task(current)) {
83341 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
83342 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
83343
83344 if (rdtp->dynticks_nmi_nesting == 0 &&
83345 - (atomic_read(&rdtp->dynticks) & 0x1))
83346 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
83347 return;
83348 rdtp->dynticks_nmi_nesting++;
83349 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
83350 - atomic_inc(&rdtp->dynticks);
83351 + atomic_inc_unchecked(&rdtp->dynticks);
83352 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83353 smp_mb__after_atomic_inc(); /* See above. */
83354 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83355 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83356 }
83357
83358 /**
83359 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
83360 return;
83361 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83362 smp_mb__before_atomic_inc(); /* See above. */
83363 - atomic_inc(&rdtp->dynticks);
83364 + atomic_inc_unchecked(&rdtp->dynticks);
83365 smp_mb__after_atomic_inc(); /* Force delay to next write. */
83366 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83367 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83368 }
83369
83370 /**
83371 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
83372 int ret;
83373
83374 preempt_disable();
83375 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83376 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83377 preempt_enable();
83378 return ret;
83379 }
83380 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
83381 */
83382 static int dyntick_save_progress_counter(struct rcu_data *rdp)
83383 {
83384 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
83385 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83386 return (rdp->dynticks_snap & 0x1) == 0;
83387 }
83388
83389 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
83390 unsigned int curr;
83391 unsigned int snap;
83392
83393 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
83394 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83395 snap = (unsigned int)rdp->dynticks_snap;
83396
83397 /*
83398 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
83399 rdp = this_cpu_ptr(rsp->rda);
83400 rcu_preempt_check_blocked_tasks(rnp);
83401 rnp->qsmask = rnp->qsmaskinit;
83402 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
83403 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
83404 WARN_ON_ONCE(rnp->completed != rsp->completed);
83405 - ACCESS_ONCE(rnp->completed) = rsp->completed;
83406 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
83407 if (rnp == rdp->mynode)
83408 __note_gp_changes(rsp, rnp, rdp);
83409 rcu_preempt_boost_start_gp(rnp);
83410 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
83411 */
83412 rcu_for_each_node_breadth_first(rsp, rnp) {
83413 raw_spin_lock_irq(&rnp->lock);
83414 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
83415 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
83416 rdp = this_cpu_ptr(rsp->rda);
83417 if (rnp == rdp->mynode)
83418 __note_gp_changes(rsp, rnp, rdp);
83419 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
83420 rsp->qlen += rdp->qlen;
83421 rdp->n_cbs_orphaned += rdp->qlen;
83422 rdp->qlen_lazy = 0;
83423 - ACCESS_ONCE(rdp->qlen) = 0;
83424 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83425 }
83426
83427 /*
83428 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
83429 }
83430 smp_mb(); /* List handling before counting for rcu_barrier(). */
83431 rdp->qlen_lazy -= count_lazy;
83432 - ACCESS_ONCE(rdp->qlen) -= count;
83433 + ACCESS_ONCE_RW(rdp->qlen) -= count;
83434 rdp->n_cbs_invoked += count;
83435
83436 /* Reinstate batch limit if we have worked down the excess. */
83437 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
83438 /*
83439 * Do RCU core processing for the current CPU.
83440 */
83441 -static void rcu_process_callbacks(struct softirq_action *unused)
83442 +static __latent_entropy void rcu_process_callbacks(void)
83443 {
83444 struct rcu_state *rsp;
83445
83446 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
83447 local_irq_restore(flags);
83448 return;
83449 }
83450 - ACCESS_ONCE(rdp->qlen)++;
83451 + ACCESS_ONCE_RW(rdp->qlen)++;
83452 if (lazy)
83453 rdp->qlen_lazy++;
83454 else
83455 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
83456 * counter wrap on a 32-bit system. Quite a few more CPUs would of
83457 * course be required on a 64-bit system.
83458 */
83459 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
83460 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
83461 (ulong)atomic_long_read(&rsp->expedited_done) +
83462 ULONG_MAX / 8)) {
83463 synchronize_sched();
83464 - atomic_long_inc(&rsp->expedited_wrap);
83465 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
83466 return;
83467 }
83468
83469 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
83470 * Take a ticket. Note that atomic_inc_return() implies a
83471 * full memory barrier.
83472 */
83473 - snap = atomic_long_inc_return(&rsp->expedited_start);
83474 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
83475 firstsnap = snap;
83476 get_online_cpus();
83477 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
83478 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
83479 synchronize_sched_expedited_cpu_stop,
83480 NULL) == -EAGAIN) {
83481 put_online_cpus();
83482 - atomic_long_inc(&rsp->expedited_tryfail);
83483 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83484
83485 /* Check to see if someone else did our work for us. */
83486 s = atomic_long_read(&rsp->expedited_done);
83487 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83488 /* ensure test happens before caller kfree */
83489 smp_mb__before_atomic_inc(); /* ^^^ */
83490 - atomic_long_inc(&rsp->expedited_workdone1);
83491 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83492 return;
83493 }
83494
83495 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83496 udelay(trycount * num_online_cpus());
83497 } else {
83498 wait_rcu_gp(call_rcu_sched);
83499 - atomic_long_inc(&rsp->expedited_normal);
83500 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83501 return;
83502 }
83503
83504 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83505 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83506 /* ensure test happens before caller kfree */
83507 smp_mb__before_atomic_inc(); /* ^^^ */
83508 - atomic_long_inc(&rsp->expedited_workdone2);
83509 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83510 return;
83511 }
83512
83513 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83514 * period works for us.
83515 */
83516 get_online_cpus();
83517 - snap = atomic_long_read(&rsp->expedited_start);
83518 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83519 smp_mb(); /* ensure read is before try_stop_cpus(). */
83520 }
83521 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83522 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83523
83524 /*
83525 * Everyone up to our most recent fetch is covered by our grace
83526 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83527 * than we did already did their update.
83528 */
83529 do {
83530 - atomic_long_inc(&rsp->expedited_done_tries);
83531 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83532 s = atomic_long_read(&rsp->expedited_done);
83533 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83534 /* ensure test happens before caller kfree */
83535 smp_mb__before_atomic_inc(); /* ^^^ */
83536 - atomic_long_inc(&rsp->expedited_done_lost);
83537 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83538 break;
83539 }
83540 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83541 - atomic_long_inc(&rsp->expedited_done_exit);
83542 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83543
83544 put_online_cpus();
83545 }
83546 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83547 * ACCESS_ONCE() to prevent the compiler from speculating
83548 * the increment to precede the early-exit check.
83549 */
83550 - ACCESS_ONCE(rsp->n_barrier_done)++;
83551 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83552 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83553 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83554 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83555 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83556
83557 /* Increment ->n_barrier_done to prevent duplicate work. */
83558 smp_mb(); /* Keep increment after above mechanism. */
83559 - ACCESS_ONCE(rsp->n_barrier_done)++;
83560 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83561 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83562 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83563 smp_mb(); /* Keep increment before caller's subsequent code. */
83564 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83565 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83566 init_callback_list(rdp);
83567 rdp->qlen_lazy = 0;
83568 - ACCESS_ONCE(rdp->qlen) = 0;
83569 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83570 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83571 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83572 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83573 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83574 rdp->cpu = cpu;
83575 rdp->rsp = rsp;
83576 rcu_boot_init_nocb_percpu_data(rdp);
83577 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83578 rdp->blimit = blimit;
83579 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83580 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83581 - atomic_set(&rdp->dynticks->dynticks,
83582 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83583 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83584 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83585 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83586
83587 /* Add CPU to rcu_node bitmasks. */
83588 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83589 index b383258..2440c1e 100644
83590 --- a/kernel/rcutree.h
83591 +++ b/kernel/rcutree.h
83592 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83593 long long dynticks_nesting; /* Track irq/process nesting level. */
83594 /* Process level is worth LLONG_MAX/2. */
83595 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83596 - atomic_t dynticks; /* Even value for idle, else odd. */
83597 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83598 #ifdef CONFIG_RCU_FAST_NO_HZ
83599 bool all_lazy; /* Are all CPU's CBs lazy? */
83600 unsigned long nonlazy_posted;
83601 @@ -419,17 +419,17 @@ struct rcu_state {
83602 /* _rcu_barrier(). */
83603 /* End of fields guarded by barrier_mutex. */
83604
83605 - atomic_long_t expedited_start; /* Starting ticket. */
83606 - atomic_long_t expedited_done; /* Done ticket. */
83607 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83608 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83609 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83610 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83611 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83612 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83613 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83614 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83615 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83616 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83617 + atomic_long_t expedited_done; /* Done ticket. */
83618 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83619 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83620 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83621 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83622 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83623 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83624 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83625 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83626 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83627
83628 unsigned long jiffies_force_qs; /* Time at which to invoke */
83629 /* force_quiescent_state(). */
83630 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83631 index 769e12e..7b2139b 100644
83632 --- a/kernel/rcutree_plugin.h
83633 +++ b/kernel/rcutree_plugin.h
83634 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83635
83636 /* Clean up and exit. */
83637 smp_mb(); /* ensure expedited GP seen before counter increment. */
83638 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83639 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83640 unlock_mb_ret:
83641 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83642 mb_ret:
83643 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83644 free_cpumask_var(cm);
83645 }
83646
83647 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83648 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83649 .store = &rcu_cpu_kthread_task,
83650 .thread_should_run = rcu_cpu_kthread_should_run,
83651 .thread_fn = rcu_cpu_kthread,
83652 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83653 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83654 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83655 cpu, ticks_value, ticks_title,
83656 - atomic_read(&rdtp->dynticks) & 0xfff,
83657 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83658 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83659 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83660 fast_no_hz);
83661 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83662
83663 /* Enqueue the callback on the nocb list and update counts. */
83664 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83665 - ACCESS_ONCE(*old_rhpp) = rhp;
83666 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83667 atomic_long_add(rhcount, &rdp->nocb_q_count);
83668 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83669
83670 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83671 * Extract queued callbacks, update counts, and wait
83672 * for a grace period to elapse.
83673 */
83674 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83675 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83676 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83677 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83678 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83679 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83680 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83681 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83682 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83683 rcu_nocb_wait_gp(rdp);
83684
83685 /* Each pass through the following loop invokes a callback. */
83686 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83687 list = next;
83688 }
83689 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83690 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83691 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83692 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83693 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83694 rdp->n_nocbs_invoked += c;
83695 }
83696 return 0;
83697 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83698 t = kthread_run(rcu_nocb_kthread, rdp,
83699 "rcuo%c/%d", rsp->abbr, cpu);
83700 BUG_ON(IS_ERR(t));
83701 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83702 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83703 }
83704 }
83705
83706 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83707 index cf6c174..a8f4b50 100644
83708 --- a/kernel/rcutree_trace.c
83709 +++ b/kernel/rcutree_trace.c
83710 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83711 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83712 rdp->passed_quiesce, rdp->qs_pending);
83713 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83714 - atomic_read(&rdp->dynticks->dynticks),
83715 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83716 rdp->dynticks->dynticks_nesting,
83717 rdp->dynticks->dynticks_nmi_nesting,
83718 rdp->dynticks_fqs);
83719 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83720 struct rcu_state *rsp = (struct rcu_state *)m->private;
83721
83722 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",
83723 - atomic_long_read(&rsp->expedited_start),
83724 + atomic_long_read_unchecked(&rsp->expedited_start),
83725 atomic_long_read(&rsp->expedited_done),
83726 - atomic_long_read(&rsp->expedited_wrap),
83727 - atomic_long_read(&rsp->expedited_tryfail),
83728 - atomic_long_read(&rsp->expedited_workdone1),
83729 - atomic_long_read(&rsp->expedited_workdone2),
83730 - atomic_long_read(&rsp->expedited_normal),
83731 - atomic_long_read(&rsp->expedited_stoppedcpus),
83732 - atomic_long_read(&rsp->expedited_done_tries),
83733 - atomic_long_read(&rsp->expedited_done_lost),
83734 - atomic_long_read(&rsp->expedited_done_exit));
83735 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83736 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83737 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83738 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83739 + atomic_long_read_unchecked(&rsp->expedited_normal),
83740 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83741 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83742 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83743 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83744 return 0;
83745 }
83746
83747 diff --git a/kernel/resource.c b/kernel/resource.c
83748 index 3f285dc..5755f62 100644
83749 --- a/kernel/resource.c
83750 +++ b/kernel/resource.c
83751 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83752
83753 static int __init ioresources_init(void)
83754 {
83755 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83756 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83757 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83758 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83759 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83760 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83761 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83762 +#endif
83763 +#else
83764 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83765 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83766 +#endif
83767 return 0;
83768 }
83769 __initcall(ioresources_init);
83770 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83771 index 1d96dd0..994ff19 100644
83772 --- a/kernel/rtmutex-tester.c
83773 +++ b/kernel/rtmutex-tester.c
83774 @@ -22,7 +22,7 @@
83775 #define MAX_RT_TEST_MUTEXES 8
83776
83777 static spinlock_t rttest_lock;
83778 -static atomic_t rttest_event;
83779 +static atomic_unchecked_t rttest_event;
83780
83781 struct test_thread_data {
83782 int opcode;
83783 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83784
83785 case RTTEST_LOCKCONT:
83786 td->mutexes[td->opdata] = 1;
83787 - td->event = atomic_add_return(1, &rttest_event);
83788 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83789 return 0;
83790
83791 case RTTEST_RESET:
83792 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83793 return 0;
83794
83795 case RTTEST_RESETEVENT:
83796 - atomic_set(&rttest_event, 0);
83797 + atomic_set_unchecked(&rttest_event, 0);
83798 return 0;
83799
83800 default:
83801 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83802 return ret;
83803
83804 td->mutexes[id] = 1;
83805 - td->event = atomic_add_return(1, &rttest_event);
83806 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83807 rt_mutex_lock(&mutexes[id]);
83808 - td->event = atomic_add_return(1, &rttest_event);
83809 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83810 td->mutexes[id] = 4;
83811 return 0;
83812
83813 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83814 return ret;
83815
83816 td->mutexes[id] = 1;
83817 - td->event = atomic_add_return(1, &rttest_event);
83818 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83819 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83820 - td->event = atomic_add_return(1, &rttest_event);
83821 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83822 td->mutexes[id] = ret ? 0 : 4;
83823 return ret ? -EINTR : 0;
83824
83825 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83826 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83827 return ret;
83828
83829 - td->event = atomic_add_return(1, &rttest_event);
83830 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83831 rt_mutex_unlock(&mutexes[id]);
83832 - td->event = atomic_add_return(1, &rttest_event);
83833 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83834 td->mutexes[id] = 0;
83835 return 0;
83836
83837 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83838 break;
83839
83840 td->mutexes[dat] = 2;
83841 - td->event = atomic_add_return(1, &rttest_event);
83842 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83843 break;
83844
83845 default:
83846 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83847 return;
83848
83849 td->mutexes[dat] = 3;
83850 - td->event = atomic_add_return(1, &rttest_event);
83851 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83852 break;
83853
83854 case RTTEST_LOCKNOWAIT:
83855 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83856 return;
83857
83858 td->mutexes[dat] = 1;
83859 - td->event = atomic_add_return(1, &rttest_event);
83860 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83861 return;
83862
83863 default:
83864 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83865 index 4a07353..66b5291 100644
83866 --- a/kernel/sched/auto_group.c
83867 +++ b/kernel/sched/auto_group.c
83868 @@ -11,7 +11,7 @@
83869
83870 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83871 static struct autogroup autogroup_default;
83872 -static atomic_t autogroup_seq_nr;
83873 +static atomic_unchecked_t autogroup_seq_nr;
83874
83875 void __init autogroup_init(struct task_struct *init_task)
83876 {
83877 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83878
83879 kref_init(&ag->kref);
83880 init_rwsem(&ag->lock);
83881 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83882 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83883 ag->tg = tg;
83884 #ifdef CONFIG_RT_GROUP_SCHED
83885 /*
83886 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83887 index 05c39f0..442e6fe 100644
83888 --- a/kernel/sched/core.c
83889 +++ b/kernel/sched/core.c
83890 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83891 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83892 * or number of jiffies left till timeout) if completed.
83893 */
83894 -long __sched
83895 +long __sched __intentional_overflow(-1)
83896 wait_for_completion_interruptible_timeout(struct completion *x,
83897 unsigned long timeout)
83898 {
83899 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83900 *
83901 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83902 */
83903 -int __sched wait_for_completion_killable(struct completion *x)
83904 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83905 {
83906 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83907 if (t == -ERESTARTSYS)
83908 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83909 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83910 * or number of jiffies left till timeout) if completed.
83911 */
83912 -long __sched
83913 +long __sched __intentional_overflow(-1)
83914 wait_for_completion_killable_timeout(struct completion *x,
83915 unsigned long timeout)
83916 {
83917 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83918 /* convert nice value [19,-20] to rlimit style value [1,40] */
83919 int nice_rlim = 20 - nice;
83920
83921 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83922 +
83923 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83924 capable(CAP_SYS_NICE));
83925 }
83926 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83927 if (nice > 19)
83928 nice = 19;
83929
83930 - if (increment < 0 && !can_nice(current, nice))
83931 + if (increment < 0 && (!can_nice(current, nice) ||
83932 + gr_handle_chroot_nice()))
83933 return -EPERM;
83934
83935 retval = security_task_setnice(current, nice);
83936 @@ -3344,6 +3347,7 @@ recheck:
83937 unsigned long rlim_rtprio =
83938 task_rlimit(p, RLIMIT_RTPRIO);
83939
83940 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83941 /* can't set/change the rt policy */
83942 if (policy != p->policy && !rlim_rtprio)
83943 return -EPERM;
83944 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83945
83946 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83947
83948 -static struct ctl_table sd_ctl_dir[] = {
83949 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83950 {
83951 .procname = "sched_domain",
83952 .mode = 0555,
83953 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83954 {}
83955 };
83956
83957 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83958 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83959 {
83960 - struct ctl_table *entry =
83961 + ctl_table_no_const *entry =
83962 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83963
83964 return entry;
83965 }
83966
83967 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83968 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83969 {
83970 - struct ctl_table *entry;
83971 + ctl_table_no_const *entry;
83972
83973 /*
83974 * In the intermediate directories, both the child directory and
83975 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83976 * will always be set. In the lowest directory the names are
83977 * static strings and all have proc handlers.
83978 */
83979 - for (entry = *tablep; entry->mode; entry++) {
83980 - if (entry->child)
83981 - sd_free_ctl_entry(&entry->child);
83982 + for (entry = tablep; entry->mode; entry++) {
83983 + if (entry->child) {
83984 + sd_free_ctl_entry(entry->child);
83985 + pax_open_kernel();
83986 + entry->child = NULL;
83987 + pax_close_kernel();
83988 + }
83989 if (entry->proc_handler == NULL)
83990 kfree(entry->procname);
83991 }
83992
83993 - kfree(*tablep);
83994 - *tablep = NULL;
83995 + kfree(tablep);
83996 }
83997
83998 static int min_load_idx = 0;
83999 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
84000
84001 static void
84002 -set_table_entry(struct ctl_table *entry,
84003 +set_table_entry(ctl_table_no_const *entry,
84004 const char *procname, void *data, int maxlen,
84005 umode_t mode, proc_handler *proc_handler,
84006 bool load_idx)
84007 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
84008 static struct ctl_table *
84009 sd_alloc_ctl_domain_table(struct sched_domain *sd)
84010 {
84011 - struct ctl_table *table = sd_alloc_ctl_entry(13);
84012 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
84013
84014 if (table == NULL)
84015 return NULL;
84016 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
84017 return table;
84018 }
84019
84020 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
84021 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
84022 {
84023 - struct ctl_table *entry, *table;
84024 + ctl_table_no_const *entry, *table;
84025 struct sched_domain *sd;
84026 int domain_num = 0, i;
84027 char buf[32];
84028 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
84029 static void register_sched_domain_sysctl(void)
84030 {
84031 int i, cpu_num = num_possible_cpus();
84032 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
84033 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
84034 char buf[32];
84035
84036 WARN_ON(sd_ctl_dir[0].child);
84037 + pax_open_kernel();
84038 sd_ctl_dir[0].child = entry;
84039 + pax_close_kernel();
84040
84041 if (entry == NULL)
84042 return;
84043 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
84044 if (sd_sysctl_header)
84045 unregister_sysctl_table(sd_sysctl_header);
84046 sd_sysctl_header = NULL;
84047 - if (sd_ctl_dir[0].child)
84048 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
84049 + if (sd_ctl_dir[0].child) {
84050 + sd_free_ctl_entry(sd_ctl_dir[0].child);
84051 + pax_open_kernel();
84052 + sd_ctl_dir[0].child = NULL;
84053 + pax_close_kernel();
84054 + }
84055 }
84056 #else
84057 static void register_sched_domain_sysctl(void)
84058 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
84059 index 31cbc15..ba68c15 100644
84060 --- a/kernel/sched/fair.c
84061 +++ b/kernel/sched/fair.c
84062 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
84063
84064 static void reset_ptenuma_scan(struct task_struct *p)
84065 {
84066 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
84067 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
84068 p->mm->numa_scan_offset = 0;
84069 }
84070
84071 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
84072 * run_rebalance_domains is triggered when needed from the scheduler tick.
84073 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
84074 */
84075 -static void run_rebalance_domains(struct softirq_action *h)
84076 +static __latent_entropy void run_rebalance_domains(void)
84077 {
84078 int this_cpu = smp_processor_id();
84079 struct rq *this_rq = cpu_rq(this_cpu);
84080 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
84081 index ef0a7b2..1b728c1 100644
84082 --- a/kernel/sched/sched.h
84083 +++ b/kernel/sched/sched.h
84084 @@ -1004,7 +1004,7 @@ struct sched_class {
84085 #ifdef CONFIG_FAIR_GROUP_SCHED
84086 void (*task_move_group) (struct task_struct *p, int on_rq);
84087 #endif
84088 -};
84089 +} __do_const;
84090
84091 #define sched_class_highest (&stop_sched_class)
84092 #define for_each_class(class) \
84093 diff --git a/kernel/signal.c b/kernel/signal.c
84094 index 50e4107..9409983 100644
84095 --- a/kernel/signal.c
84096 +++ b/kernel/signal.c
84097 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
84098
84099 int print_fatal_signals __read_mostly;
84100
84101 -static void __user *sig_handler(struct task_struct *t, int sig)
84102 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
84103 {
84104 return t->sighand->action[sig - 1].sa.sa_handler;
84105 }
84106
84107 -static int sig_handler_ignored(void __user *handler, int sig)
84108 +static int sig_handler_ignored(__sighandler_t handler, int sig)
84109 {
84110 /* Is it explicitly or implicitly ignored? */
84111 return handler == SIG_IGN ||
84112 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
84113
84114 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
84115 {
84116 - void __user *handler;
84117 + __sighandler_t handler;
84118
84119 handler = sig_handler(t, sig);
84120
84121 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
84122 atomic_inc(&user->sigpending);
84123 rcu_read_unlock();
84124
84125 + if (!override_rlimit)
84126 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
84127 +
84128 if (override_rlimit ||
84129 atomic_read(&user->sigpending) <=
84130 task_rlimit(t, RLIMIT_SIGPENDING)) {
84131 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
84132
84133 int unhandled_signal(struct task_struct *tsk, int sig)
84134 {
84135 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
84136 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
84137 if (is_global_init(tsk))
84138 return 1;
84139 if (handler != SIG_IGN && handler != SIG_DFL)
84140 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
84141 }
84142 }
84143
84144 + /* allow glibc communication via tgkill to other threads in our
84145 + thread group */
84146 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
84147 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
84148 + && gr_handle_signal(t, sig))
84149 + return -EPERM;
84150 +
84151 return security_task_kill(t, info, sig, 0);
84152 }
84153
84154 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84155 return send_signal(sig, info, p, 1);
84156 }
84157
84158 -static int
84159 +int
84160 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84161 {
84162 return send_signal(sig, info, t, 0);
84163 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84164 unsigned long int flags;
84165 int ret, blocked, ignored;
84166 struct k_sigaction *action;
84167 + int is_unhandled = 0;
84168
84169 spin_lock_irqsave(&t->sighand->siglock, flags);
84170 action = &t->sighand->action[sig-1];
84171 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84172 }
84173 if (action->sa.sa_handler == SIG_DFL)
84174 t->signal->flags &= ~SIGNAL_UNKILLABLE;
84175 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
84176 + is_unhandled = 1;
84177 ret = specific_send_sig_info(sig, info, t);
84178 spin_unlock_irqrestore(&t->sighand->siglock, flags);
84179
84180 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
84181 + normal operation */
84182 + if (is_unhandled) {
84183 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
84184 + gr_handle_crash(t, sig);
84185 + }
84186 +
84187 return ret;
84188 }
84189
84190 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84191 ret = check_kill_permission(sig, info, p);
84192 rcu_read_unlock();
84193
84194 - if (!ret && sig)
84195 + if (!ret && sig) {
84196 ret = do_send_sig_info(sig, info, p, true);
84197 + if (!ret)
84198 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
84199 + }
84200
84201 return ret;
84202 }
84203 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
84204 int error = -ESRCH;
84205
84206 rcu_read_lock();
84207 - p = find_task_by_vpid(pid);
84208 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
84209 + /* allow glibc communication via tgkill to other threads in our
84210 + thread group */
84211 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
84212 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
84213 + p = find_task_by_vpid_unrestricted(pid);
84214 + else
84215 +#endif
84216 + p = find_task_by_vpid(pid);
84217 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
84218 error = check_kill_permission(sig, info, p);
84219 /*
84220 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
84221 }
84222 seg = get_fs();
84223 set_fs(KERNEL_DS);
84224 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
84225 - (stack_t __force __user *) &uoss,
84226 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
84227 + (stack_t __force_user *) &uoss,
84228 compat_user_stack_pointer());
84229 set_fs(seg);
84230 if (ret >= 0 && uoss_ptr) {
84231 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
84232 index eb89e18..a4e6792 100644
84233 --- a/kernel/smpboot.c
84234 +++ b/kernel/smpboot.c
84235 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
84236 }
84237 smpboot_unpark_thread(plug_thread, cpu);
84238 }
84239 - list_add(&plug_thread->list, &hotplug_threads);
84240 + pax_list_add(&plug_thread->list, &hotplug_threads);
84241 out:
84242 mutex_unlock(&smpboot_threads_lock);
84243 return ret;
84244 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
84245 {
84246 get_online_cpus();
84247 mutex_lock(&smpboot_threads_lock);
84248 - list_del(&plug_thread->list);
84249 + pax_list_del(&plug_thread->list);
84250 smpboot_destroy_threads(plug_thread);
84251 mutex_unlock(&smpboot_threads_lock);
84252 put_online_cpus();
84253 diff --git a/kernel/softirq.c b/kernel/softirq.c
84254 index adf6c00..5d89b73 100644
84255 --- a/kernel/softirq.c
84256 +++ b/kernel/softirq.c
84257 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
84258 EXPORT_SYMBOL(irq_stat);
84259 #endif
84260
84261 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
84262 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
84263
84264 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
84265
84266 -char *softirq_to_name[NR_SOFTIRQS] = {
84267 +const char * const softirq_to_name[NR_SOFTIRQS] = {
84268 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
84269 "TASKLET", "SCHED", "HRTIMER", "RCU"
84270 };
84271 @@ -248,7 +248,7 @@ restart:
84272 kstat_incr_softirqs_this_cpu(vec_nr);
84273
84274 trace_softirq_entry(vec_nr);
84275 - h->action(h);
84276 + h->action();
84277 trace_softirq_exit(vec_nr);
84278 if (unlikely(prev_count != preempt_count())) {
84279 printk(KERN_ERR "huh, entered softirq %u %s %p"
84280 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
84281 or_softirq_pending(1UL << nr);
84282 }
84283
84284 -void open_softirq(int nr, void (*action)(struct softirq_action *))
84285 +void __init open_softirq(int nr, void (*action)(void))
84286 {
84287 softirq_vec[nr].action = action;
84288 }
84289 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
84290
84291 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
84292
84293 -static void tasklet_action(struct softirq_action *a)
84294 +static __latent_entropy void tasklet_action(void)
84295 {
84296 struct tasklet_struct *list;
84297
84298 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
84299 }
84300 }
84301
84302 -static void tasklet_hi_action(struct softirq_action *a)
84303 +static __latent_entropy void tasklet_hi_action(void)
84304 {
84305 struct tasklet_struct *list;
84306
84307 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
84308 .notifier_call = cpu_callback
84309 };
84310
84311 -static struct smp_hotplug_thread softirq_threads = {
84312 +static struct smp_hotplug_thread softirq_threads __read_only = {
84313 .store = &ksoftirqd,
84314 .thread_should_run = ksoftirqd_should_run,
84315 .thread_fn = run_ksoftirqd,
84316 diff --git a/kernel/srcu.c b/kernel/srcu.c
84317 index 01d5ccb..cdcbee6 100644
84318 --- a/kernel/srcu.c
84319 +++ b/kernel/srcu.c
84320 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
84321
84322 idx = ACCESS_ONCE(sp->completed) & 0x1;
84323 preempt_disable();
84324 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84325 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84326 smp_mb(); /* B */ /* Avoid leaking the critical section. */
84327 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84328 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84329 preempt_enable();
84330 return idx;
84331 }
84332 diff --git a/kernel/sys.c b/kernel/sys.c
84333 index 771129b..dc0c7e3 100644
84334 --- a/kernel/sys.c
84335 +++ b/kernel/sys.c
84336 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
84337 error = -EACCES;
84338 goto out;
84339 }
84340 +
84341 + if (gr_handle_chroot_setpriority(p, niceval)) {
84342 + error = -EACCES;
84343 + goto out;
84344 + }
84345 +
84346 no_nice = security_task_setnice(p, niceval);
84347 if (no_nice) {
84348 error = no_nice;
84349 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
84350 goto error;
84351 }
84352
84353 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
84354 + goto error;
84355 +
84356 if (rgid != (gid_t) -1 ||
84357 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
84358 new->sgid = new->egid;
84359 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
84360 old = current_cred();
84361
84362 retval = -EPERM;
84363 +
84364 + if (gr_check_group_change(kgid, kgid, kgid))
84365 + goto error;
84366 +
84367 if (nsown_capable(CAP_SETGID))
84368 new->gid = new->egid = new->sgid = new->fsgid = kgid;
84369 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
84370 @@ -404,7 +417,7 @@ error:
84371 /*
84372 * change the user struct in a credentials set to match the new UID
84373 */
84374 -static int set_user(struct cred *new)
84375 +int set_user(struct cred *new)
84376 {
84377 struct user_struct *new_user;
84378
84379 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
84380 goto error;
84381 }
84382
84383 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
84384 + goto error;
84385 +
84386 if (!uid_eq(new->uid, old->uid)) {
84387 retval = set_user(new);
84388 if (retval < 0)
84389 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
84390 old = current_cred();
84391
84392 retval = -EPERM;
84393 +
84394 + if (gr_check_crash_uid(kuid))
84395 + goto error;
84396 + if (gr_check_user_change(kuid, kuid, kuid))
84397 + goto error;
84398 +
84399 if (nsown_capable(CAP_SETUID)) {
84400 new->suid = new->uid = kuid;
84401 if (!uid_eq(kuid, old->uid)) {
84402 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
84403 goto error;
84404 }
84405
84406 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
84407 + goto error;
84408 +
84409 if (ruid != (uid_t) -1) {
84410 new->uid = kruid;
84411 if (!uid_eq(kruid, old->uid)) {
84412 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
84413 goto error;
84414 }
84415
84416 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
84417 + goto error;
84418 +
84419 if (rgid != (gid_t) -1)
84420 new->gid = krgid;
84421 if (egid != (gid_t) -1)
84422 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
84423 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
84424 nsown_capable(CAP_SETUID)) {
84425 if (!uid_eq(kuid, old->fsuid)) {
84426 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
84427 + goto error;
84428 +
84429 new->fsuid = kuid;
84430 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
84431 goto change_okay;
84432 }
84433 }
84434
84435 +error:
84436 abort_creds(new);
84437 return old_fsuid;
84438
84439 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
84440 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
84441 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
84442 nsown_capable(CAP_SETGID)) {
84443 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
84444 + goto error;
84445 +
84446 if (!gid_eq(kgid, old->fsgid)) {
84447 new->fsgid = kgid;
84448 goto change_okay;
84449 }
84450 }
84451
84452 +error:
84453 abort_creds(new);
84454 return old_fsgid;
84455
84456 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
84457 return -EFAULT;
84458
84459 down_read(&uts_sem);
84460 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
84461 + error = __copy_to_user(name->sysname, &utsname()->sysname,
84462 __OLD_UTS_LEN);
84463 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
84464 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
84465 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
84466 __OLD_UTS_LEN);
84467 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
84468 - error |= __copy_to_user(&name->release, &utsname()->release,
84469 + error |= __copy_to_user(name->release, &utsname()->release,
84470 __OLD_UTS_LEN);
84471 error |= __put_user(0, name->release + __OLD_UTS_LEN);
84472 - error |= __copy_to_user(&name->version, &utsname()->version,
84473 + error |= __copy_to_user(name->version, &utsname()->version,
84474 __OLD_UTS_LEN);
84475 error |= __put_user(0, name->version + __OLD_UTS_LEN);
84476 - error |= __copy_to_user(&name->machine, &utsname()->machine,
84477 + error |= __copy_to_user(name->machine, &utsname()->machine,
84478 __OLD_UTS_LEN);
84479 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84480 up_read(&uts_sem);
84481 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84482 */
84483 new_rlim->rlim_cur = 1;
84484 }
84485 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84486 + is changed to a lower value. Since tasks can be created by the same
84487 + user in between this limit change and an execve by this task, force
84488 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84489 + */
84490 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84491 + tsk->flags |= PF_NPROC_EXCEEDED;
84492 }
84493 if (!retval) {
84494 if (old_rlim)
84495 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84496 index 07f6fc4..65fb3d4 100644
84497 --- a/kernel/sysctl.c
84498 +++ b/kernel/sysctl.c
84499 @@ -93,7 +93,6 @@
84500
84501
84502 #if defined(CONFIG_SYSCTL)
84503 -
84504 /* External variables not in a header file. */
84505 extern int sysctl_overcommit_memory;
84506 extern int sysctl_overcommit_ratio;
84507 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84508
84509 /* Constants used for minimum and maximum */
84510 #ifdef CONFIG_LOCKUP_DETECTOR
84511 -static int sixty = 60;
84512 +static int sixty __read_only = 60;
84513 #endif
84514
84515 -static int zero;
84516 -static int __maybe_unused one = 1;
84517 -static int __maybe_unused two = 2;
84518 -static int __maybe_unused three = 3;
84519 -static unsigned long one_ul = 1;
84520 -static int one_hundred = 100;
84521 +static int neg_one __read_only = -1;
84522 +static int zero __read_only = 0;
84523 +static int __maybe_unused one __read_only = 1;
84524 +static int __maybe_unused two __read_only = 2;
84525 +static int __maybe_unused three __read_only = 3;
84526 +static unsigned long one_ul __read_only = 1;
84527 +static int one_hundred __read_only = 100;
84528 #ifdef CONFIG_PRINTK
84529 -static int ten_thousand = 10000;
84530 +static int ten_thousand __read_only = 10000;
84531 #endif
84532
84533 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84534 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84535 void __user *buffer, size_t *lenp, loff_t *ppos);
84536 #endif
84537
84538 -#ifdef CONFIG_PRINTK
84539 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84540 void __user *buffer, size_t *lenp, loff_t *ppos);
84541 -#endif
84542
84543 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84544 void __user *buffer, size_t *lenp, loff_t *ppos);
84545 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84546
84547 #endif
84548
84549 +extern struct ctl_table grsecurity_table[];
84550 +
84551 static struct ctl_table kern_table[];
84552 static struct ctl_table vm_table[];
84553 static struct ctl_table fs_table[];
84554 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84555 int sysctl_legacy_va_layout;
84556 #endif
84557
84558 +#ifdef CONFIG_PAX_SOFTMODE
84559 +static ctl_table pax_table[] = {
84560 + {
84561 + .procname = "softmode",
84562 + .data = &pax_softmode,
84563 + .maxlen = sizeof(unsigned int),
84564 + .mode = 0600,
84565 + .proc_handler = &proc_dointvec,
84566 + },
84567 +
84568 + { }
84569 +};
84570 +#endif
84571 +
84572 /* The default sysctl tables: */
84573
84574 static struct ctl_table sysctl_base_table[] = {
84575 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84576 #endif
84577
84578 static struct ctl_table kern_table[] = {
84579 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84580 + {
84581 + .procname = "grsecurity",
84582 + .mode = 0500,
84583 + .child = grsecurity_table,
84584 + },
84585 +#endif
84586 +
84587 +#ifdef CONFIG_PAX_SOFTMODE
84588 + {
84589 + .procname = "pax",
84590 + .mode = 0500,
84591 + .child = pax_table,
84592 + },
84593 +#endif
84594 +
84595 {
84596 .procname = "sched_child_runs_first",
84597 .data = &sysctl_sched_child_runs_first,
84598 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84599 .data = &modprobe_path,
84600 .maxlen = KMOD_PATH_LEN,
84601 .mode = 0644,
84602 - .proc_handler = proc_dostring,
84603 + .proc_handler = proc_dostring_modpriv,
84604 },
84605 {
84606 .procname = "modules_disabled",
84607 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84608 .extra1 = &zero,
84609 .extra2 = &one,
84610 },
84611 +#endif
84612 {
84613 .procname = "kptr_restrict",
84614 .data = &kptr_restrict,
84615 .maxlen = sizeof(int),
84616 .mode = 0644,
84617 .proc_handler = proc_dointvec_minmax_sysadmin,
84618 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84619 + .extra1 = &two,
84620 +#else
84621 .extra1 = &zero,
84622 +#endif
84623 .extra2 = &two,
84624 },
84625 -#endif
84626 {
84627 .procname = "ngroups_max",
84628 .data = &ngroups_max,
84629 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84630 */
84631 {
84632 .procname = "perf_event_paranoid",
84633 - .data = &sysctl_perf_event_paranoid,
84634 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84635 + .data = &sysctl_perf_event_legitimately_concerned,
84636 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84637 .mode = 0644,
84638 - .proc_handler = proc_dointvec,
84639 + /* go ahead, be a hero */
84640 + .proc_handler = proc_dointvec_minmax_sysadmin,
84641 + .extra1 = &neg_one,
84642 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84643 + .extra2 = &three,
84644 +#else
84645 + .extra2 = &two,
84646 +#endif
84647 },
84648 {
84649 .procname = "perf_event_mlock_kb",
84650 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84651 .proc_handler = proc_dointvec_minmax,
84652 .extra1 = &zero,
84653 },
84654 + {
84655 + .procname = "heap_stack_gap",
84656 + .data = &sysctl_heap_stack_gap,
84657 + .maxlen = sizeof(sysctl_heap_stack_gap),
84658 + .mode = 0644,
84659 + .proc_handler = proc_doulongvec_minmax,
84660 + },
84661 #else
84662 {
84663 .procname = "nr_trim_pages",
84664 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84665 buffer, lenp, ppos);
84666 }
84667
84668 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84669 + void __user *buffer, size_t *lenp, loff_t *ppos)
84670 +{
84671 + if (write && !capable(CAP_SYS_MODULE))
84672 + return -EPERM;
84673 +
84674 + return _proc_do_string(table->data, table->maxlen, write,
84675 + buffer, lenp, ppos);
84676 +}
84677 +
84678 static size_t proc_skip_spaces(char **buf)
84679 {
84680 size_t ret;
84681 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84682 len = strlen(tmp);
84683 if (len > *size)
84684 len = *size;
84685 + if (len > sizeof(tmp))
84686 + len = sizeof(tmp);
84687 if (copy_to_user(*buf, tmp, len))
84688 return -EFAULT;
84689 *size -= len;
84690 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84691 static int proc_taint(struct ctl_table *table, int write,
84692 void __user *buffer, size_t *lenp, loff_t *ppos)
84693 {
84694 - struct ctl_table t;
84695 + ctl_table_no_const t;
84696 unsigned long tmptaint = get_taint();
84697 int err;
84698
84699 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84700 return err;
84701 }
84702
84703 -#ifdef CONFIG_PRINTK
84704 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84705 void __user *buffer, size_t *lenp, loff_t *ppos)
84706 {
84707 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84708
84709 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84710 }
84711 -#endif
84712
84713 struct do_proc_dointvec_minmax_conv_param {
84714 int *min;
84715 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84716 *i = val;
84717 } else {
84718 val = convdiv * (*i) / convmul;
84719 - if (!first)
84720 + if (!first) {
84721 err = proc_put_char(&buffer, &left, '\t');
84722 + if (err)
84723 + break;
84724 + }
84725 err = proc_put_long(&buffer, &left, val, false);
84726 if (err)
84727 break;
84728 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84729 return -ENOSYS;
84730 }
84731
84732 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84733 + void __user *buffer, size_t *lenp, loff_t *ppos)
84734 +{
84735 + return -ENOSYS;
84736 +}
84737 +
84738 int proc_dointvec(struct ctl_table *table, int write,
84739 void __user *buffer, size_t *lenp, loff_t *ppos)
84740 {
84741 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84742 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84743 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84744 EXPORT_SYMBOL(proc_dostring);
84745 +EXPORT_SYMBOL(proc_dostring_modpriv);
84746 EXPORT_SYMBOL(proc_doulongvec_minmax);
84747 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84748 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84749 index 145bb4d..b2aa969 100644
84750 --- a/kernel/taskstats.c
84751 +++ b/kernel/taskstats.c
84752 @@ -28,9 +28,12 @@
84753 #include <linux/fs.h>
84754 #include <linux/file.h>
84755 #include <linux/pid_namespace.h>
84756 +#include <linux/grsecurity.h>
84757 #include <net/genetlink.h>
84758 #include <linux/atomic.h>
84759
84760 +extern int gr_is_taskstats_denied(int pid);
84761 +
84762 /*
84763 * Maximum length of a cpumask that can be specified in
84764 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84765 @@ -570,6 +573,9 @@ err:
84766
84767 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84768 {
84769 + if (gr_is_taskstats_denied(current->pid))
84770 + return -EACCES;
84771 +
84772 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84773 return cmd_attr_register_cpumask(info);
84774 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84775 diff --git a/kernel/time.c b/kernel/time.c
84776 index 7c7964c..784a599 100644
84777 --- a/kernel/time.c
84778 +++ b/kernel/time.c
84779 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84780 return error;
84781
84782 if (tz) {
84783 + /* we log in do_settimeofday called below, so don't log twice
84784 + */
84785 + if (!tv)
84786 + gr_log_timechange();
84787 +
84788 sys_tz = *tz;
84789 update_vsyscall_tz();
84790 if (firsttime) {
84791 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84792 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84793 * value to a scaled second value.
84794 */
84795 -unsigned long
84796 +unsigned long __intentional_overflow(-1)
84797 timespec_to_jiffies(const struct timespec *value)
84798 {
84799 unsigned long sec = value->tv_sec;
84800 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84801 index eec50fc..65e5df6 100644
84802 --- a/kernel/time/alarmtimer.c
84803 +++ b/kernel/time/alarmtimer.c
84804 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84805 struct platform_device *pdev;
84806 int error = 0;
84807 int i;
84808 - struct k_clock alarm_clock = {
84809 + static struct k_clock alarm_clock = {
84810 .clock_getres = alarm_clock_getres,
84811 .clock_get = alarm_clock_get,
84812 .timer_create = alarm_timer_create,
84813 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84814 index 947ba25..20cbade 100644
84815 --- a/kernel/time/timekeeping.c
84816 +++ b/kernel/time/timekeeping.c
84817 @@ -15,6 +15,7 @@
84818 #include <linux/init.h>
84819 #include <linux/mm.h>
84820 #include <linux/sched.h>
84821 +#include <linux/grsecurity.h>
84822 #include <linux/syscore_ops.h>
84823 #include <linux/clocksource.h>
84824 #include <linux/jiffies.h>
84825 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84826 if (!timespec_valid_strict(tv))
84827 return -EINVAL;
84828
84829 + gr_log_timechange();
84830 +
84831 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84832 write_seqcount_begin(&timekeeper_seq);
84833
84834 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84835 index 61ed862..3b52c65 100644
84836 --- a/kernel/time/timer_list.c
84837 +++ b/kernel/time/timer_list.c
84838 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84839
84840 static void print_name_offset(struct seq_file *m, void *sym)
84841 {
84842 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84843 + SEQ_printf(m, "<%p>", NULL);
84844 +#else
84845 char symname[KSYM_NAME_LEN];
84846
84847 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84848 SEQ_printf(m, "<%pK>", sym);
84849 else
84850 SEQ_printf(m, "%s", symname);
84851 +#endif
84852 }
84853
84854 static void
84855 @@ -119,7 +123,11 @@ next_one:
84856 static void
84857 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84858 {
84859 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84860 + SEQ_printf(m, " .base: %p\n", NULL);
84861 +#else
84862 SEQ_printf(m, " .base: %pK\n", base);
84863 +#endif
84864 SEQ_printf(m, " .index: %d\n",
84865 base->index);
84866 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84867 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84868 {
84869 struct proc_dir_entry *pe;
84870
84871 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84872 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84873 +#else
84874 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84875 +#endif
84876 if (!pe)
84877 return -ENOMEM;
84878 return 0;
84879 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84880 index 0b537f2..40d6c20 100644
84881 --- a/kernel/time/timer_stats.c
84882 +++ b/kernel/time/timer_stats.c
84883 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84884 static unsigned long nr_entries;
84885 static struct entry entries[MAX_ENTRIES];
84886
84887 -static atomic_t overflow_count;
84888 +static atomic_unchecked_t overflow_count;
84889
84890 /*
84891 * The entries are in a hash-table, for fast lookup:
84892 @@ -140,7 +140,7 @@ static void reset_entries(void)
84893 nr_entries = 0;
84894 memset(entries, 0, sizeof(entries));
84895 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84896 - atomic_set(&overflow_count, 0);
84897 + atomic_set_unchecked(&overflow_count, 0);
84898 }
84899
84900 static struct entry *alloc_entry(void)
84901 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84902 if (likely(entry))
84903 entry->count++;
84904 else
84905 - atomic_inc(&overflow_count);
84906 + atomic_inc_unchecked(&overflow_count);
84907
84908 out_unlock:
84909 raw_spin_unlock_irqrestore(lock, flags);
84910 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84911
84912 static void print_name_offset(struct seq_file *m, unsigned long addr)
84913 {
84914 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84915 + seq_printf(m, "<%p>", NULL);
84916 +#else
84917 char symname[KSYM_NAME_LEN];
84918
84919 if (lookup_symbol_name(addr, symname) < 0)
84920 - seq_printf(m, "<%p>", (void *)addr);
84921 + seq_printf(m, "<%pK>", (void *)addr);
84922 else
84923 seq_printf(m, "%s", symname);
84924 +#endif
84925 }
84926
84927 static int tstats_show(struct seq_file *m, void *v)
84928 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84929
84930 seq_puts(m, "Timer Stats Version: v0.2\n");
84931 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84932 - if (atomic_read(&overflow_count))
84933 + if (atomic_read_unchecked(&overflow_count))
84934 seq_printf(m, "Overflow: %d entries\n",
84935 - atomic_read(&overflow_count));
84936 + atomic_read_unchecked(&overflow_count));
84937
84938 for (i = 0; i < nr_entries; i++) {
84939 entry = entries + i;
84940 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84941 {
84942 struct proc_dir_entry *pe;
84943
84944 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84945 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84946 +#else
84947 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84948 +#endif
84949 if (!pe)
84950 return -ENOMEM;
84951 return 0;
84952 diff --git a/kernel/timer.c b/kernel/timer.c
84953 index 4296d13..0164b04 100644
84954 --- a/kernel/timer.c
84955 +++ b/kernel/timer.c
84956 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84957 /*
84958 * This function runs timers and the timer-tq in bottom half context.
84959 */
84960 -static void run_timer_softirq(struct softirq_action *h)
84961 +static __latent_entropy void run_timer_softirq(void)
84962 {
84963 struct tvec_base *base = __this_cpu_read(tvec_bases);
84964
84965 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84966 *
84967 * In all cases the return value is guaranteed to be non-negative.
84968 */
84969 -signed long __sched schedule_timeout(signed long timeout)
84970 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84971 {
84972 struct timer_list timer;
84973 unsigned long expire;
84974 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84975 index b8b8560..75b1a09 100644
84976 --- a/kernel/trace/blktrace.c
84977 +++ b/kernel/trace/blktrace.c
84978 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84979 struct blk_trace *bt = filp->private_data;
84980 char buf[16];
84981
84982 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84983 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84984
84985 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84986 }
84987 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84988 return 1;
84989
84990 bt = buf->chan->private_data;
84991 - atomic_inc(&bt->dropped);
84992 + atomic_inc_unchecked(&bt->dropped);
84993 return 0;
84994 }
84995
84996 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84997
84998 bt->dir = dir;
84999 bt->dev = dev;
85000 - atomic_set(&bt->dropped, 0);
85001 + atomic_set_unchecked(&bt->dropped, 0);
85002
85003 ret = -EIO;
85004 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
85005 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
85006 index a6d098c..bb8cf65 100644
85007 --- a/kernel/trace/ftrace.c
85008 +++ b/kernel/trace/ftrace.c
85009 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
85010 if (unlikely(ftrace_disabled))
85011 return 0;
85012
85013 + ret = ftrace_arch_code_modify_prepare();
85014 + FTRACE_WARN_ON(ret);
85015 + if (ret)
85016 + return 0;
85017 +
85018 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
85019 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
85020 if (ret) {
85021 ftrace_bug(ret, ip);
85022 - return 0;
85023 }
85024 - return 1;
85025 + return ret ? 0 : 1;
85026 }
85027
85028 /*
85029 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
85030 if (!count)
85031 return 0;
85032
85033 + pax_open_kernel();
85034 sort(start, count, sizeof(*start),
85035 ftrace_cmp_ips, ftrace_swap_ips);
85036 + pax_close_kernel();
85037
85038 start_pg = ftrace_allocate_pages(count);
85039 if (!start_pg)
85040 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
85041 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
85042
85043 static int ftrace_graph_active;
85044 -static struct notifier_block ftrace_suspend_notifier;
85045 -
85046 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
85047 {
85048 return 0;
85049 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
85050 return NOTIFY_DONE;
85051 }
85052
85053 +static struct notifier_block ftrace_suspend_notifier = {
85054 + .notifier_call = ftrace_suspend_notifier_call
85055 +};
85056 +
85057 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85058 trace_func_graph_ent_t entryfunc)
85059 {
85060 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85061 goto out;
85062 }
85063
85064 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
85065 register_pm_notifier(&ftrace_suspend_notifier);
85066
85067 ftrace_graph_active++;
85068 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
85069 index cc2f66f..05edd54 100644
85070 --- a/kernel/trace/ring_buffer.c
85071 +++ b/kernel/trace/ring_buffer.c
85072 @@ -352,9 +352,9 @@ struct buffer_data_page {
85073 */
85074 struct buffer_page {
85075 struct list_head list; /* list of buffer pages */
85076 - local_t write; /* index for next write */
85077 + local_unchecked_t write; /* index for next write */
85078 unsigned read; /* index for next read */
85079 - local_t entries; /* entries on this page */
85080 + local_unchecked_t entries; /* entries on this page */
85081 unsigned long real_end; /* real end of data */
85082 struct buffer_data_page *page; /* Actual data page */
85083 };
85084 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
85085 unsigned long last_overrun;
85086 local_t entries_bytes;
85087 local_t entries;
85088 - local_t overrun;
85089 - local_t commit_overrun;
85090 + local_unchecked_t overrun;
85091 + local_unchecked_t commit_overrun;
85092 local_t dropped_events;
85093 local_t committing;
85094 local_t commits;
85095 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85096 *
85097 * We add a counter to the write field to denote this.
85098 */
85099 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
85100 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
85101 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
85102 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
85103
85104 /*
85105 * Just make sure we have seen our old_write and synchronize
85106 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85107 * cmpxchg to only update if an interrupt did not already
85108 * do it for us. If the cmpxchg fails, we don't care.
85109 */
85110 - (void)local_cmpxchg(&next_page->write, old_write, val);
85111 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
85112 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
85113 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
85114
85115 /*
85116 * No need to worry about races with clearing out the commit.
85117 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
85118
85119 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
85120 {
85121 - return local_read(&bpage->entries) & RB_WRITE_MASK;
85122 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
85123 }
85124
85125 static inline unsigned long rb_page_write(struct buffer_page *bpage)
85126 {
85127 - return local_read(&bpage->write) & RB_WRITE_MASK;
85128 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
85129 }
85130
85131 static int
85132 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
85133 * bytes consumed in ring buffer from here.
85134 * Increment overrun to account for the lost events.
85135 */
85136 - local_add(page_entries, &cpu_buffer->overrun);
85137 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
85138 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85139 }
85140
85141 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
85142 * it is our responsibility to update
85143 * the counters.
85144 */
85145 - local_add(entries, &cpu_buffer->overrun);
85146 + local_add_unchecked(entries, &cpu_buffer->overrun);
85147 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85148
85149 /*
85150 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85151 if (tail == BUF_PAGE_SIZE)
85152 tail_page->real_end = 0;
85153
85154 - local_sub(length, &tail_page->write);
85155 + local_sub_unchecked(length, &tail_page->write);
85156 return;
85157 }
85158
85159 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85160 rb_event_set_padding(event);
85161
85162 /* Set the write back to the previous setting */
85163 - local_sub(length, &tail_page->write);
85164 + local_sub_unchecked(length, &tail_page->write);
85165 return;
85166 }
85167
85168 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85169
85170 /* Set write to end of buffer */
85171 length = (tail + length) - BUF_PAGE_SIZE;
85172 - local_sub(length, &tail_page->write);
85173 + local_sub_unchecked(length, &tail_page->write);
85174 }
85175
85176 /*
85177 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85178 * about it.
85179 */
85180 if (unlikely(next_page == commit_page)) {
85181 - local_inc(&cpu_buffer->commit_overrun);
85182 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85183 goto out_reset;
85184 }
85185
85186 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85187 cpu_buffer->tail_page) &&
85188 (cpu_buffer->commit_page ==
85189 cpu_buffer->reader_page))) {
85190 - local_inc(&cpu_buffer->commit_overrun);
85191 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85192 goto out_reset;
85193 }
85194 }
85195 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85196 length += RB_LEN_TIME_EXTEND;
85197
85198 tail_page = cpu_buffer->tail_page;
85199 - write = local_add_return(length, &tail_page->write);
85200 + write = local_add_return_unchecked(length, &tail_page->write);
85201
85202 /* set write to only the index of the write */
85203 write &= RB_WRITE_MASK;
85204 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85205 kmemcheck_annotate_bitfield(event, bitfield);
85206 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
85207
85208 - local_inc(&tail_page->entries);
85209 + local_inc_unchecked(&tail_page->entries);
85210
85211 /*
85212 * If this is the first commit on the page, then update
85213 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85214
85215 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
85216 unsigned long write_mask =
85217 - local_read(&bpage->write) & ~RB_WRITE_MASK;
85218 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
85219 unsigned long event_length = rb_event_length(event);
85220 /*
85221 * This is on the tail page. It is possible that
85222 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85223 */
85224 old_index += write_mask;
85225 new_index += write_mask;
85226 - index = local_cmpxchg(&bpage->write, old_index, new_index);
85227 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
85228 if (index == old_index) {
85229 /* update counters */
85230 local_sub(event_length, &cpu_buffer->entries_bytes);
85231 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85232
85233 /* Do the likely case first */
85234 if (likely(bpage->page == (void *)addr)) {
85235 - local_dec(&bpage->entries);
85236 + local_dec_unchecked(&bpage->entries);
85237 return;
85238 }
85239
85240 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85241 start = bpage;
85242 do {
85243 if (bpage->page == (void *)addr) {
85244 - local_dec(&bpage->entries);
85245 + local_dec_unchecked(&bpage->entries);
85246 return;
85247 }
85248 rb_inc_page(cpu_buffer, &bpage);
85249 @@ -3139,7 +3139,7 @@ static inline unsigned long
85250 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
85251 {
85252 return local_read(&cpu_buffer->entries) -
85253 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
85254 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
85255 }
85256
85257 /**
85258 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
85259 return 0;
85260
85261 cpu_buffer = buffer->buffers[cpu];
85262 - ret = local_read(&cpu_buffer->overrun);
85263 + ret = local_read_unchecked(&cpu_buffer->overrun);
85264
85265 return ret;
85266 }
85267 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
85268 return 0;
85269
85270 cpu_buffer = buffer->buffers[cpu];
85271 - ret = local_read(&cpu_buffer->commit_overrun);
85272 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
85273
85274 return ret;
85275 }
85276 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
85277 /* if you care about this being correct, lock the buffer */
85278 for_each_buffer_cpu(buffer, cpu) {
85279 cpu_buffer = buffer->buffers[cpu];
85280 - overruns += local_read(&cpu_buffer->overrun);
85281 + overruns += local_read_unchecked(&cpu_buffer->overrun);
85282 }
85283
85284 return overruns;
85285 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85286 /*
85287 * Reset the reader page to size zero.
85288 */
85289 - local_set(&cpu_buffer->reader_page->write, 0);
85290 - local_set(&cpu_buffer->reader_page->entries, 0);
85291 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85292 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85293 local_set(&cpu_buffer->reader_page->page->commit, 0);
85294 cpu_buffer->reader_page->real_end = 0;
85295
85296 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85297 * want to compare with the last_overrun.
85298 */
85299 smp_mb();
85300 - overwrite = local_read(&(cpu_buffer->overrun));
85301 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
85302
85303 /*
85304 * Here's the tricky part.
85305 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85306
85307 cpu_buffer->head_page
85308 = list_entry(cpu_buffer->pages, struct buffer_page, list);
85309 - local_set(&cpu_buffer->head_page->write, 0);
85310 - local_set(&cpu_buffer->head_page->entries, 0);
85311 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
85312 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
85313 local_set(&cpu_buffer->head_page->page->commit, 0);
85314
85315 cpu_buffer->head_page->read = 0;
85316 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85317
85318 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
85319 INIT_LIST_HEAD(&cpu_buffer->new_pages);
85320 - local_set(&cpu_buffer->reader_page->write, 0);
85321 - local_set(&cpu_buffer->reader_page->entries, 0);
85322 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85323 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85324 local_set(&cpu_buffer->reader_page->page->commit, 0);
85325 cpu_buffer->reader_page->read = 0;
85326
85327 local_set(&cpu_buffer->entries_bytes, 0);
85328 - local_set(&cpu_buffer->overrun, 0);
85329 - local_set(&cpu_buffer->commit_overrun, 0);
85330 + local_set_unchecked(&cpu_buffer->overrun, 0);
85331 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
85332 local_set(&cpu_buffer->dropped_events, 0);
85333 local_set(&cpu_buffer->entries, 0);
85334 local_set(&cpu_buffer->committing, 0);
85335 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
85336 rb_init_page(bpage);
85337 bpage = reader->page;
85338 reader->page = *data_page;
85339 - local_set(&reader->write, 0);
85340 - local_set(&reader->entries, 0);
85341 + local_set_unchecked(&reader->write, 0);
85342 + local_set_unchecked(&reader->entries, 0);
85343 reader->read = 0;
85344 *data_page = bpage;
85345
85346 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
85347 index 207f5fc..ff41c9b 100644
85348 --- a/kernel/trace/trace.c
85349 +++ b/kernel/trace/trace.c
85350 @@ -3338,7 +3338,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
85351 return 0;
85352 }
85353
85354 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
85355 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
85356 {
85357 /* do nothing if flag is already set */
85358 if (!!(trace_flags & mask) == !!enabled)
85359 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
85360 index afaae41..64871f8 100644
85361 --- a/kernel/trace/trace.h
85362 +++ b/kernel/trace/trace.h
85363 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
85364 void trace_printk_init_buffers(void);
85365 void trace_printk_start_comm(void);
85366 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
85367 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
85368 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
85369
85370 /*
85371 * Normal trace_printk() and friends allocates special buffers
85372 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
85373 index 26dc348..8708ca7 100644
85374 --- a/kernel/trace/trace_clock.c
85375 +++ b/kernel/trace/trace_clock.c
85376 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
85377 return now;
85378 }
85379
85380 -static atomic64_t trace_counter;
85381 +static atomic64_unchecked_t trace_counter;
85382
85383 /*
85384 * trace_clock_counter(): simply an atomic counter.
85385 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
85386 */
85387 u64 notrace trace_clock_counter(void)
85388 {
85389 - return atomic64_add_return(1, &trace_counter);
85390 + return atomic64_inc_return_unchecked(&trace_counter);
85391 }
85392 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
85393 index 29a7ebc..eb473cf 100644
85394 --- a/kernel/trace/trace_events.c
85395 +++ b/kernel/trace/trace_events.c
85396 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
85397 struct ftrace_module_file_ops {
85398 struct list_head list;
85399 struct module *mod;
85400 - struct file_operations id;
85401 - struct file_operations enable;
85402 - struct file_operations format;
85403 - struct file_operations filter;
85404 };
85405
85406 static struct ftrace_module_file_ops *
85407 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
85408
85409 file_ops->mod = mod;
85410
85411 - file_ops->id = ftrace_event_id_fops;
85412 - file_ops->id.owner = mod;
85413 -
85414 - file_ops->enable = ftrace_enable_fops;
85415 - file_ops->enable.owner = mod;
85416 -
85417 - file_ops->filter = ftrace_event_filter_fops;
85418 - file_ops->filter.owner = mod;
85419 -
85420 - file_ops->format = ftrace_event_format_fops;
85421 - file_ops->format.owner = mod;
85422 + pax_open_kernel();
85423 + mod->trace_id.owner = mod;
85424 + mod->trace_enable.owner = mod;
85425 + mod->trace_filter.owner = mod;
85426 + mod->trace_format.owner = mod;
85427 + pax_close_kernel();
85428
85429 list_add(&file_ops->list, &ftrace_module_file_list);
85430
85431 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
85432 struct ftrace_module_file_ops *file_ops)
85433 {
85434 return __trace_add_new_event(call, tr,
85435 - &file_ops->id, &file_ops->enable,
85436 - &file_ops->filter, &file_ops->format);
85437 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
85438 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
85439 }
85440
85441 #else
85442 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
85443 index b3dcfb2..ebee344 100644
85444 --- a/kernel/trace/trace_mmiotrace.c
85445 +++ b/kernel/trace/trace_mmiotrace.c
85446 @@ -24,7 +24,7 @@ struct header_iter {
85447 static struct trace_array *mmio_trace_array;
85448 static bool overrun_detected;
85449 static unsigned long prev_overruns;
85450 -static atomic_t dropped_count;
85451 +static atomic_unchecked_t dropped_count;
85452
85453 static void mmio_reset_data(struct trace_array *tr)
85454 {
85455 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
85456
85457 static unsigned long count_overruns(struct trace_iterator *iter)
85458 {
85459 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
85460 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
85461 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
85462
85463 if (over > prev_overruns)
85464 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
85465 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
85466 sizeof(*entry), 0, pc);
85467 if (!event) {
85468 - atomic_inc(&dropped_count);
85469 + atomic_inc_unchecked(&dropped_count);
85470 return;
85471 }
85472 entry = ring_buffer_event_data(event);
85473 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
85474 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
85475 sizeof(*entry), 0, pc);
85476 if (!event) {
85477 - atomic_inc(&dropped_count);
85478 + atomic_inc_unchecked(&dropped_count);
85479 return;
85480 }
85481 entry = ring_buffer_event_data(event);
85482 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85483 index 34e7cba..6f9a729 100644
85484 --- a/kernel/trace/trace_output.c
85485 +++ b/kernel/trace/trace_output.c
85486 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85487
85488 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85489 if (!IS_ERR(p)) {
85490 - p = mangle_path(s->buffer + s->len, p, "\n");
85491 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85492 if (p) {
85493 s->len = p - s->buffer;
85494 return 1;
85495 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85496 goto out;
85497 }
85498
85499 + pax_open_kernel();
85500 if (event->funcs->trace == NULL)
85501 - event->funcs->trace = trace_nop_print;
85502 + *(void **)&event->funcs->trace = trace_nop_print;
85503 if (event->funcs->raw == NULL)
85504 - event->funcs->raw = trace_nop_print;
85505 + *(void **)&event->funcs->raw = trace_nop_print;
85506 if (event->funcs->hex == NULL)
85507 - event->funcs->hex = trace_nop_print;
85508 + *(void **)&event->funcs->hex = trace_nop_print;
85509 if (event->funcs->binary == NULL)
85510 - event->funcs->binary = trace_nop_print;
85511 + *(void **)&event->funcs->binary = trace_nop_print;
85512 + pax_close_kernel();
85513
85514 key = event->type & (EVENT_HASHSIZE - 1);
85515
85516 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85517 index b20428c..4845a10 100644
85518 --- a/kernel/trace/trace_stack.c
85519 +++ b/kernel/trace/trace_stack.c
85520 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85521 return;
85522
85523 /* we do not handle interrupt stacks yet */
85524 - if (!object_is_on_stack(stack))
85525 + if (!object_starts_on_stack(stack))
85526 return;
85527
85528 local_irq_save(flags);
85529 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85530 index 9064b91..1f5d2f8 100644
85531 --- a/kernel/user_namespace.c
85532 +++ b/kernel/user_namespace.c
85533 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85534 !kgid_has_mapping(parent_ns, group))
85535 return -EPERM;
85536
85537 +#ifdef CONFIG_GRKERNSEC
85538 + /*
85539 + * This doesn't really inspire confidence:
85540 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85541 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85542 + * Increases kernel attack surface in areas developers
85543 + * previously cared little about ("low importance due
85544 + * to requiring "root" capability")
85545 + * To be removed when this code receives *proper* review
85546 + */
85547 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85548 + !capable(CAP_SETGID))
85549 + return -EPERM;
85550 +#endif
85551 +
85552 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85553 if (!ns)
85554 return -ENOMEM;
85555 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85556 if (atomic_read(&current->mm->mm_users) > 1)
85557 return -EINVAL;
85558
85559 - if (current->fs->users != 1)
85560 + if (atomic_read(&current->fs->users) != 1)
85561 return -EINVAL;
85562
85563 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85564 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85565 index 4f69f9a..7c6f8f8 100644
85566 --- a/kernel/utsname_sysctl.c
85567 +++ b/kernel/utsname_sysctl.c
85568 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85569 static int proc_do_uts_string(ctl_table *table, int write,
85570 void __user *buffer, size_t *lenp, loff_t *ppos)
85571 {
85572 - struct ctl_table uts_table;
85573 + ctl_table_no_const uts_table;
85574 int r;
85575 memcpy(&uts_table, table, sizeof(uts_table));
85576 uts_table.data = get_uts(table, write);
85577 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85578 index 1241d8c..d5cfc28 100644
85579 --- a/kernel/watchdog.c
85580 +++ b/kernel/watchdog.c
85581 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85582 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85583 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85584
85585 -static struct smp_hotplug_thread watchdog_threads = {
85586 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85587 .store = &softlockup_watchdog,
85588 .thread_should_run = watchdog_should_run,
85589 .thread_fn = watchdog,
85590 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85591 index e93f7b9..989fcd7 100644
85592 --- a/kernel/workqueue.c
85593 +++ b/kernel/workqueue.c
85594 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85595 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85596 worker_flags |= WORKER_REBOUND;
85597 worker_flags &= ~WORKER_UNBOUND;
85598 - ACCESS_ONCE(worker->flags) = worker_flags;
85599 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85600 }
85601
85602 spin_unlock_irq(&pool->lock);
85603 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85604 index 1501aa5..e771896 100644
85605 --- a/lib/Kconfig.debug
85606 +++ b/lib/Kconfig.debug
85607 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85608
85609 config DEBUG_WW_MUTEX_SLOWPATH
85610 bool "Wait/wound mutex debugging: Slowpath testing"
85611 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85612 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85613 select DEBUG_LOCK_ALLOC
85614 select DEBUG_SPINLOCK
85615 select DEBUG_MUTEXES
85616 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85617
85618 config DEBUG_LOCK_ALLOC
85619 bool "Lock debugging: detect incorrect freeing of live locks"
85620 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85621 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85622 select DEBUG_SPINLOCK
85623 select DEBUG_MUTEXES
85624 select LOCKDEP
85625 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85626
85627 config PROVE_LOCKING
85628 bool "Lock debugging: prove locking correctness"
85629 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85630 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85631 select LOCKDEP
85632 select DEBUG_SPINLOCK
85633 select DEBUG_MUTEXES
85634 @@ -914,7 +914,7 @@ config LOCKDEP
85635
85636 config LOCK_STAT
85637 bool "Lock usage statistics"
85638 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85639 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85640 select LOCKDEP
85641 select DEBUG_SPINLOCK
85642 select DEBUG_MUTEXES
85643 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85644 depends on DEBUG_KERNEL
85645 depends on STACKTRACE_SUPPORT
85646 depends on PROC_FS
85647 + depends on !GRKERNSEC_HIDESYM
85648 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85649 select KALLSYMS
85650 select KALLSYMS_ALL
85651 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85652 config DEBUG_STRICT_USER_COPY_CHECKS
85653 bool "Strict user copy size checks"
85654 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85655 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85656 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85657 help
85658 Enabling this option turns a certain set of sanity checks for user
85659 copy operations into compile time failures.
85660 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85661
85662 config PROVIDE_OHCI1394_DMA_INIT
85663 bool "Remote debugging over FireWire early on boot"
85664 - depends on PCI && X86
85665 + depends on PCI && X86 && !GRKERNSEC
85666 help
85667 If you want to debug problems which hang or crash the kernel early
85668 on boot and the crashing machine has a FireWire port, you can use
85669 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85670
85671 config FIREWIRE_OHCI_REMOTE_DMA
85672 bool "Remote debugging over FireWire with firewire-ohci"
85673 - depends on FIREWIRE_OHCI
85674 + depends on FIREWIRE_OHCI && !GRKERNSEC
85675 help
85676 This option lets you use the FireWire bus for remote debugging
85677 with help of the firewire-ohci driver. It enables unfiltered
85678 diff --git a/lib/Makefile b/lib/Makefile
85679 index 7baccfd..3ceb95f 100644
85680 --- a/lib/Makefile
85681 +++ b/lib/Makefile
85682 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85683
85684 obj-$(CONFIG_BTREE) += btree.o
85685 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85686 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85687 +obj-y += list_debug.o
85688 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85689
85690 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85691 diff --git a/lib/bitmap.c b/lib/bitmap.c
85692 index 06f7e4f..f3cf2b0 100644
85693 --- a/lib/bitmap.c
85694 +++ b/lib/bitmap.c
85695 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85696 {
85697 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85698 u32 chunk;
85699 - const char __user __force *ubuf = (const char __user __force *)buf;
85700 + const char __user *ubuf = (const char __force_user *)buf;
85701
85702 bitmap_zero(maskp, nmaskbits);
85703
85704 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85705 {
85706 if (!access_ok(VERIFY_READ, ubuf, ulen))
85707 return -EFAULT;
85708 - return __bitmap_parse((const char __force *)ubuf,
85709 + return __bitmap_parse((const char __force_kernel *)ubuf,
85710 ulen, 1, maskp, nmaskbits);
85711
85712 }
85713 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85714 {
85715 unsigned a, b;
85716 int c, old_c, totaldigits;
85717 - const char __user __force *ubuf = (const char __user __force *)buf;
85718 + const char __user *ubuf = (const char __force_user *)buf;
85719 int exp_digit, in_range;
85720
85721 totaldigits = c = 0;
85722 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85723 {
85724 if (!access_ok(VERIFY_READ, ubuf, ulen))
85725 return -EFAULT;
85726 - return __bitmap_parselist((const char __force *)ubuf,
85727 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85728 ulen, 1, maskp, nmaskbits);
85729 }
85730 EXPORT_SYMBOL(bitmap_parselist_user);
85731 diff --git a/lib/bug.c b/lib/bug.c
85732 index 1686034..a9c00c8 100644
85733 --- a/lib/bug.c
85734 +++ b/lib/bug.c
85735 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85736 return BUG_TRAP_TYPE_NONE;
85737
85738 bug = find_bug(bugaddr);
85739 + if (!bug)
85740 + return BUG_TRAP_TYPE_NONE;
85741
85742 file = NULL;
85743 line = 0;
85744 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85745 index 37061ed..da83f48 100644
85746 --- a/lib/debugobjects.c
85747 +++ b/lib/debugobjects.c
85748 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85749 if (limit > 4)
85750 return;
85751
85752 - is_on_stack = object_is_on_stack(addr);
85753 + is_on_stack = object_starts_on_stack(addr);
85754 if (is_on_stack == onstack)
85755 return;
85756
85757 diff --git a/lib/devres.c b/lib/devres.c
85758 index 8235331..5881053 100644
85759 --- a/lib/devres.c
85760 +++ b/lib/devres.c
85761 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85762 void devm_iounmap(struct device *dev, void __iomem *addr)
85763 {
85764 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85765 - (void *)addr));
85766 + (void __force *)addr));
85767 iounmap(addr);
85768 }
85769 EXPORT_SYMBOL(devm_iounmap);
85770 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85771 {
85772 ioport_unmap(addr);
85773 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85774 - devm_ioport_map_match, (void *)addr));
85775 + devm_ioport_map_match, (void __force *)addr));
85776 }
85777 EXPORT_SYMBOL(devm_ioport_unmap);
85778 #endif /* CONFIG_HAS_IOPORT */
85779 diff --git a/lib/div64.c b/lib/div64.c
85780 index a163b6c..9618fa5 100644
85781 --- a/lib/div64.c
85782 +++ b/lib/div64.c
85783 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85784 EXPORT_SYMBOL(__div64_32);
85785
85786 #ifndef div_s64_rem
85787 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85788 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85789 {
85790 u64 quotient;
85791
85792 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85793 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85794 */
85795 #ifndef div64_u64
85796 -u64 div64_u64(u64 dividend, u64 divisor)
85797 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85798 {
85799 u32 high = divisor >> 32;
85800 u64 quot;
85801 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85802 index d87a17a..ac0d79a 100644
85803 --- a/lib/dma-debug.c
85804 +++ b/lib/dma-debug.c
85805 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85806
85807 void dma_debug_add_bus(struct bus_type *bus)
85808 {
85809 - struct notifier_block *nb;
85810 + notifier_block_no_const *nb;
85811
85812 if (global_disable)
85813 return;
85814 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85815
85816 static void check_for_stack(struct device *dev, void *addr)
85817 {
85818 - if (object_is_on_stack(addr))
85819 + if (object_starts_on_stack(addr))
85820 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85821 "stack [addr=%p]\n", addr);
85822 }
85823 diff --git a/lib/inflate.c b/lib/inflate.c
85824 index 013a761..c28f3fc 100644
85825 --- a/lib/inflate.c
85826 +++ b/lib/inflate.c
85827 @@ -269,7 +269,7 @@ static void free(void *where)
85828 malloc_ptr = free_mem_ptr;
85829 }
85830 #else
85831 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85832 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85833 #define free(a) kfree(a)
85834 #endif
85835
85836 diff --git a/lib/ioremap.c b/lib/ioremap.c
85837 index 0c9216c..863bd89 100644
85838 --- a/lib/ioremap.c
85839 +++ b/lib/ioremap.c
85840 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85841 unsigned long next;
85842
85843 phys_addr -= addr;
85844 - pmd = pmd_alloc(&init_mm, pud, addr);
85845 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85846 if (!pmd)
85847 return -ENOMEM;
85848 do {
85849 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85850 unsigned long next;
85851
85852 phys_addr -= addr;
85853 - pud = pud_alloc(&init_mm, pgd, addr);
85854 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85855 if (!pud)
85856 return -ENOMEM;
85857 do {
85858 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85859 index bd2bea9..6b3c95e 100644
85860 --- a/lib/is_single_threaded.c
85861 +++ b/lib/is_single_threaded.c
85862 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85863 struct task_struct *p, *t;
85864 bool ret;
85865
85866 + if (!mm)
85867 + return true;
85868 +
85869 if (atomic_read(&task->signal->live) != 1)
85870 return false;
85871
85872 diff --git a/lib/kobject.c b/lib/kobject.c
85873 index 4a1f33d..2f3ca75 100644
85874 --- a/lib/kobject.c
85875 +++ b/lib/kobject.c
85876 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85877
85878
85879 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85880 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85881 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85882
85883 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85884 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85885 {
85886 enum kobj_ns_type type = ops->type;
85887 int error;
85888 diff --git a/lib/list_debug.c b/lib/list_debug.c
85889 index c24c2f7..f0296f4 100644
85890 --- a/lib/list_debug.c
85891 +++ b/lib/list_debug.c
85892 @@ -11,7 +11,9 @@
85893 #include <linux/bug.h>
85894 #include <linux/kernel.h>
85895 #include <linux/rculist.h>
85896 +#include <linux/mm.h>
85897
85898 +#ifdef CONFIG_DEBUG_LIST
85899 /*
85900 * Insert a new entry between two known consecutive entries.
85901 *
85902 @@ -19,21 +21,40 @@
85903 * the prev/next entries already!
85904 */
85905
85906 +static bool __list_add_debug(struct list_head *new,
85907 + struct list_head *prev,
85908 + struct list_head *next)
85909 +{
85910 + if (unlikely(next->prev != prev)) {
85911 + printk(KERN_ERR "list_add corruption. next->prev should be "
85912 + "prev (%p), but was %p. (next=%p).\n",
85913 + prev, next->prev, next);
85914 + BUG();
85915 + return false;
85916 + }
85917 + if (unlikely(prev->next != next)) {
85918 + printk(KERN_ERR "list_add corruption. prev->next should be "
85919 + "next (%p), but was %p. (prev=%p).\n",
85920 + next, prev->next, prev);
85921 + BUG();
85922 + return false;
85923 + }
85924 + if (unlikely(new == prev || new == next)) {
85925 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
85926 + new, prev, next);
85927 + BUG();
85928 + return false;
85929 + }
85930 + return true;
85931 +}
85932 +
85933 void __list_add(struct list_head *new,
85934 - struct list_head *prev,
85935 - struct list_head *next)
85936 + struct list_head *prev,
85937 + struct list_head *next)
85938 {
85939 - WARN(next->prev != prev,
85940 - "list_add corruption. next->prev should be "
85941 - "prev (%p), but was %p. (next=%p).\n",
85942 - prev, next->prev, next);
85943 - WARN(prev->next != next,
85944 - "list_add corruption. prev->next should be "
85945 - "next (%p), but was %p. (prev=%p).\n",
85946 - next, prev->next, prev);
85947 - WARN(new == prev || new == next,
85948 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85949 - new, prev, next);
85950 + if (!__list_add_debug(new, prev, next))
85951 + return;
85952 +
85953 next->prev = new;
85954 new->next = next;
85955 new->prev = prev;
85956 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
85957 }
85958 EXPORT_SYMBOL(__list_add);
85959
85960 -void __list_del_entry(struct list_head *entry)
85961 +static bool __list_del_entry_debug(struct list_head *entry)
85962 {
85963 struct list_head *prev, *next;
85964
85965 prev = entry->prev;
85966 next = entry->next;
85967
85968 - if (WARN(next == LIST_POISON1,
85969 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85970 - entry, LIST_POISON1) ||
85971 - WARN(prev == LIST_POISON2,
85972 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85973 - entry, LIST_POISON2) ||
85974 - WARN(prev->next != entry,
85975 - "list_del corruption. prev->next should be %p, "
85976 - "but was %p\n", entry, prev->next) ||
85977 - WARN(next->prev != entry,
85978 - "list_del corruption. next->prev should be %p, "
85979 - "but was %p\n", entry, next->prev))
85980 + if (unlikely(next == LIST_POISON1)) {
85981 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85982 + entry, LIST_POISON1);
85983 + BUG();
85984 + return false;
85985 + }
85986 + if (unlikely(prev == LIST_POISON2)) {
85987 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85988 + entry, LIST_POISON2);
85989 + BUG();
85990 + return false;
85991 + }
85992 + if (unlikely(entry->prev->next != entry)) {
85993 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
85994 + "but was %p\n", entry, prev->next);
85995 + BUG();
85996 + return false;
85997 + }
85998 + if (unlikely(entry->next->prev != entry)) {
85999 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
86000 + "but was %p\n", entry, next->prev);
86001 + BUG();
86002 + return false;
86003 + }
86004 + return true;
86005 +}
86006 +
86007 +void __list_del_entry(struct list_head *entry)
86008 +{
86009 + if (!__list_del_entry_debug(entry))
86010 return;
86011
86012 - __list_del(prev, next);
86013 + __list_del(entry->prev, entry->next);
86014 }
86015 EXPORT_SYMBOL(__list_del_entry);
86016
86017 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
86018 void __list_add_rcu(struct list_head *new,
86019 struct list_head *prev, struct list_head *next)
86020 {
86021 - WARN(next->prev != prev,
86022 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
86023 - prev, next->prev, next);
86024 - WARN(prev->next != next,
86025 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
86026 - next, prev->next, prev);
86027 + if (!__list_add_debug(new, prev, next))
86028 + return;
86029 +
86030 new->next = next;
86031 new->prev = prev;
86032 rcu_assign_pointer(list_next_rcu(prev), new);
86033 next->prev = new;
86034 }
86035 EXPORT_SYMBOL(__list_add_rcu);
86036 +#endif
86037 +
86038 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
86039 +{
86040 +#ifdef CONFIG_DEBUG_LIST
86041 + if (!__list_add_debug(new, prev, next))
86042 + return;
86043 +#endif
86044 +
86045 + pax_open_kernel();
86046 + next->prev = new;
86047 + new->next = next;
86048 + new->prev = prev;
86049 + prev->next = new;
86050 + pax_close_kernel();
86051 +}
86052 +EXPORT_SYMBOL(__pax_list_add);
86053 +
86054 +void pax_list_del(struct list_head *entry)
86055 +{
86056 +#ifdef CONFIG_DEBUG_LIST
86057 + if (!__list_del_entry_debug(entry))
86058 + return;
86059 +#endif
86060 +
86061 + pax_open_kernel();
86062 + __list_del(entry->prev, entry->next);
86063 + entry->next = LIST_POISON1;
86064 + entry->prev = LIST_POISON2;
86065 + pax_close_kernel();
86066 +}
86067 +EXPORT_SYMBOL(pax_list_del);
86068 +
86069 +void pax_list_del_init(struct list_head *entry)
86070 +{
86071 + pax_open_kernel();
86072 + __list_del(entry->prev, entry->next);
86073 + INIT_LIST_HEAD(entry);
86074 + pax_close_kernel();
86075 +}
86076 +EXPORT_SYMBOL(pax_list_del_init);
86077 +
86078 +void __pax_list_add_rcu(struct list_head *new,
86079 + struct list_head *prev, struct list_head *next)
86080 +{
86081 +#ifdef CONFIG_DEBUG_LIST
86082 + if (!__list_add_debug(new, prev, next))
86083 + return;
86084 +#endif
86085 +
86086 + pax_open_kernel();
86087 + new->next = next;
86088 + new->prev = prev;
86089 + rcu_assign_pointer(list_next_rcu(prev), new);
86090 + next->prev = new;
86091 + pax_close_kernel();
86092 +}
86093 +EXPORT_SYMBOL(__pax_list_add_rcu);
86094 +
86095 +void pax_list_del_rcu(struct list_head *entry)
86096 +{
86097 +#ifdef CONFIG_DEBUG_LIST
86098 + if (!__list_del_entry_debug(entry))
86099 + return;
86100 +#endif
86101 +
86102 + pax_open_kernel();
86103 + __list_del(entry->prev, entry->next);
86104 + entry->next = LIST_POISON1;
86105 + entry->prev = LIST_POISON2;
86106 + pax_close_kernel();
86107 +}
86108 +EXPORT_SYMBOL(pax_list_del_rcu);
86109 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
86110 index 7deeb62..144eb47 100644
86111 --- a/lib/percpu-refcount.c
86112 +++ b/lib/percpu-refcount.c
86113 @@ -29,7 +29,7 @@
86114 * can't hit 0 before we've added up all the percpu refs.
86115 */
86116
86117 -#define PCPU_COUNT_BIAS (1U << 31)
86118 +#define PCPU_COUNT_BIAS (1U << 30)
86119
86120 /**
86121 * percpu_ref_init - initialize a percpu refcount
86122 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
86123 index e796429..6e38f9f 100644
86124 --- a/lib/radix-tree.c
86125 +++ b/lib/radix-tree.c
86126 @@ -92,7 +92,7 @@ struct radix_tree_preload {
86127 int nr;
86128 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
86129 };
86130 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
86131 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
86132
86133 static inline void *ptr_to_indirect(void *ptr)
86134 {
86135 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
86136 index bb2b201..46abaf9 100644
86137 --- a/lib/strncpy_from_user.c
86138 +++ b/lib/strncpy_from_user.c
86139 @@ -21,7 +21,7 @@
86140 */
86141 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
86142 {
86143 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86144 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86145 long res = 0;
86146
86147 /*
86148 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
86149 index a28df52..3d55877 100644
86150 --- a/lib/strnlen_user.c
86151 +++ b/lib/strnlen_user.c
86152 @@ -26,7 +26,7 @@
86153 */
86154 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
86155 {
86156 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86157 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86158 long align, res = 0;
86159 unsigned long c;
86160
86161 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
86162 index d23762e..e21eab2 100644
86163 --- a/lib/swiotlb.c
86164 +++ b/lib/swiotlb.c
86165 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
86166
86167 void
86168 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
86169 - dma_addr_t dev_addr)
86170 + dma_addr_t dev_addr, struct dma_attrs *attrs)
86171 {
86172 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
86173
86174 diff --git a/lib/usercopy.c b/lib/usercopy.c
86175 index 4f5b1dd..7cab418 100644
86176 --- a/lib/usercopy.c
86177 +++ b/lib/usercopy.c
86178 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
86179 WARN(1, "Buffer overflow detected!\n");
86180 }
86181 EXPORT_SYMBOL(copy_from_user_overflow);
86182 +
86183 +void copy_to_user_overflow(void)
86184 +{
86185 + WARN(1, "Buffer overflow detected!\n");
86186 +}
86187 +EXPORT_SYMBOL(copy_to_user_overflow);
86188 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
86189 index 739a363..aa668d7 100644
86190 --- a/lib/vsprintf.c
86191 +++ b/lib/vsprintf.c
86192 @@ -16,6 +16,9 @@
86193 * - scnprintf and vscnprintf
86194 */
86195
86196 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86197 +#define __INCLUDED_BY_HIDESYM 1
86198 +#endif
86199 #include <stdarg.h>
86200 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
86201 #include <linux/types.h>
86202 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
86203 return number(buf, end, *(const netdev_features_t *)addr, spec);
86204 }
86205
86206 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86207 +int kptr_restrict __read_mostly = 2;
86208 +#else
86209 int kptr_restrict __read_mostly;
86210 +#endif
86211
86212 /*
86213 * Show a '%p' thing. A kernel extension is that the '%p' is followed
86214 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
86215 * - 'f' For simple symbolic function names without offset
86216 * - 'S' For symbolic direct pointers with offset
86217 * - 's' For symbolic direct pointers without offset
86218 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
86219 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
86220 * - 'B' For backtraced symbolic direct pointers with offset
86221 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
86222 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86223
86224 if (!ptr && *fmt != 'K') {
86225 /*
86226 - * Print (null) with the same width as a pointer so it makes
86227 + * Print (nil) with the same width as a pointer so it makes
86228 * tabular output look nice.
86229 */
86230 if (spec.field_width == -1)
86231 spec.field_width = default_width;
86232 - return string(buf, end, "(null)", spec);
86233 + return string(buf, end, "(nil)", spec);
86234 }
86235
86236 switch (*fmt) {
86237 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86238 /* Fallthrough */
86239 case 'S':
86240 case 's':
86241 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86242 + break;
86243 +#else
86244 + return symbol_string(buf, end, ptr, spec, fmt);
86245 +#endif
86246 + case 'A':
86247 case 'B':
86248 return symbol_string(buf, end, ptr, spec, fmt);
86249 case 'R':
86250 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86251 va_end(va);
86252 return buf;
86253 }
86254 + case 'P':
86255 + break;
86256 case 'K':
86257 /*
86258 * %pK cannot be used in IRQ context because its test
86259 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86260 return number(buf, end,
86261 (unsigned long long) *((phys_addr_t *)ptr), spec);
86262 }
86263 +
86264 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86265 + /* 'P' = approved pointers to copy to userland,
86266 + as in the /proc/kallsyms case, as we make it display nothing
86267 + for non-root users, and the real contents for root users
86268 + Also ignore 'K' pointers, since we force their NULLing for non-root users
86269 + above
86270 + */
86271 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
86272 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
86273 + dump_stack();
86274 + ptr = NULL;
86275 + }
86276 +#endif
86277 +
86278 spec.flags |= SMALL;
86279 if (spec.field_width == -1) {
86280 spec.field_width = default_width;
86281 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86282 typeof(type) value; \
86283 if (sizeof(type) == 8) { \
86284 args = PTR_ALIGN(args, sizeof(u32)); \
86285 - *(u32 *)&value = *(u32 *)args; \
86286 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
86287 + *(u32 *)&value = *(const u32 *)args; \
86288 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
86289 } else { \
86290 args = PTR_ALIGN(args, sizeof(type)); \
86291 - value = *(typeof(type) *)args; \
86292 + value = *(const typeof(type) *)args; \
86293 } \
86294 args += sizeof(type); \
86295 value; \
86296 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86297 case FORMAT_TYPE_STR: {
86298 const char *str_arg = args;
86299 args += strlen(str_arg) + 1;
86300 - str = string(str, end, (char *)str_arg, spec);
86301 + str = string(str, end, str_arg, spec);
86302 break;
86303 }
86304
86305 diff --git a/localversion-grsec b/localversion-grsec
86306 new file mode 100644
86307 index 0000000..7cd6065
86308 --- /dev/null
86309 +++ b/localversion-grsec
86310 @@ -0,0 +1 @@
86311 +-grsec
86312 diff --git a/mm/Kconfig b/mm/Kconfig
86313 index 6509d27..3c15063 100644
86314 --- a/mm/Kconfig
86315 +++ b/mm/Kconfig
86316 @@ -317,10 +317,11 @@ config KSM
86317 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
86318
86319 config DEFAULT_MMAP_MIN_ADDR
86320 - int "Low address space to protect from user allocation"
86321 + int "Low address space to protect from user allocation"
86322 depends on MMU
86323 - default 4096
86324 - help
86325 + default 32768 if ALPHA || ARM || PARISC || SPARC32
86326 + default 65536
86327 + help
86328 This is the portion of low virtual memory which should be protected
86329 from userspace allocation. Keeping a user from writing to low pages
86330 can help reduce the impact of kernel NULL pointer bugs.
86331 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
86332
86333 config HWPOISON_INJECT
86334 tristate "HWPoison pages injector"
86335 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
86336 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
86337 select PROC_PAGE_MONITOR
86338
86339 config NOMMU_INITIAL_TRIM_EXCESS
86340 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
86341 index e04454c..ca5be3e 100644
86342 --- a/mm/backing-dev.c
86343 +++ b/mm/backing-dev.c
86344 @@ -12,7 +12,7 @@
86345 #include <linux/device.h>
86346 #include <trace/events/writeback.h>
86347
86348 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
86349 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
86350
86351 struct backing_dev_info default_backing_dev_info = {
86352 .name = "default",
86353 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
86354 return err;
86355
86356 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
86357 - atomic_long_inc_return(&bdi_seq));
86358 + atomic_long_inc_return_unchecked(&bdi_seq));
86359 if (err) {
86360 bdi_destroy(bdi);
86361 return err;
86362 diff --git a/mm/filemap.c b/mm/filemap.c
86363 index 4b51ac1..5aa90ff 100644
86364 --- a/mm/filemap.c
86365 +++ b/mm/filemap.c
86366 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
86367 struct address_space *mapping = file->f_mapping;
86368
86369 if (!mapping->a_ops->readpage)
86370 - return -ENOEXEC;
86371 + return -ENODEV;
86372 file_accessed(file);
86373 vma->vm_ops = &generic_file_vm_ops;
86374 return 0;
86375 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
86376
86377 while (bytes) {
86378 char __user *buf = iov->iov_base + base;
86379 - int copy = min(bytes, iov->iov_len - base);
86380 + size_t copy = min(bytes, iov->iov_len - base);
86381
86382 base = 0;
86383 left = __copy_from_user_inatomic(vaddr, buf, copy);
86384 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
86385 BUG_ON(!in_atomic());
86386 kaddr = kmap_atomic(page);
86387 if (likely(i->nr_segs == 1)) {
86388 - int left;
86389 + size_t left;
86390 char __user *buf = i->iov->iov_base + i->iov_offset;
86391 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
86392 copied = bytes - left;
86393 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
86394
86395 kaddr = kmap(page);
86396 if (likely(i->nr_segs == 1)) {
86397 - int left;
86398 + size_t left;
86399 char __user *buf = i->iov->iov_base + i->iov_offset;
86400 left = __copy_from_user(kaddr + offset, buf, bytes);
86401 copied = bytes - left;
86402 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
86403 * zero-length segments (without overruning the iovec).
86404 */
86405 while (bytes || unlikely(i->count && !iov->iov_len)) {
86406 - int copy;
86407 + size_t copy;
86408
86409 copy = min(bytes, iov->iov_len - base);
86410 BUG_ON(!i->count || i->count < copy);
86411 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
86412 *pos = i_size_read(inode);
86413
86414 if (limit != RLIM_INFINITY) {
86415 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
86416 if (*pos >= limit) {
86417 send_sig(SIGXFSZ, current, 0);
86418 return -EFBIG;
86419 diff --git a/mm/fremap.c b/mm/fremap.c
86420 index 5bff081..d8189a9 100644
86421 --- a/mm/fremap.c
86422 +++ b/mm/fremap.c
86423 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
86424 retry:
86425 vma = find_vma(mm, start);
86426
86427 +#ifdef CONFIG_PAX_SEGMEXEC
86428 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
86429 + goto out;
86430 +#endif
86431 +
86432 /*
86433 * Make sure the vma is shared, that it supports prefaulting,
86434 * and that the remapped range is valid and fully within
86435 diff --git a/mm/highmem.c b/mm/highmem.c
86436 index b32b70c..e512eb0 100644
86437 --- a/mm/highmem.c
86438 +++ b/mm/highmem.c
86439 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
86440 * So no dangers, even with speculative execution.
86441 */
86442 page = pte_page(pkmap_page_table[i]);
86443 + pax_open_kernel();
86444 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
86445 -
86446 + pax_close_kernel();
86447 set_page_address(page, NULL);
86448 need_flush = 1;
86449 }
86450 @@ -198,9 +199,11 @@ start:
86451 }
86452 }
86453 vaddr = PKMAP_ADDR(last_pkmap_nr);
86454 +
86455 + pax_open_kernel();
86456 set_pte_at(&init_mm, vaddr,
86457 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
86458 -
86459 + pax_close_kernel();
86460 pkmap_count[last_pkmap_nr] = 1;
86461 set_page_address(page, (void *)vaddr);
86462
86463 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
86464 index b60f330..ee7de7e 100644
86465 --- a/mm/hugetlb.c
86466 +++ b/mm/hugetlb.c
86467 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
86468 struct hstate *h = &default_hstate;
86469 unsigned long tmp;
86470 int ret;
86471 + ctl_table_no_const hugetlb_table;
86472
86473 tmp = h->max_huge_pages;
86474
86475 if (write && h->order >= MAX_ORDER)
86476 return -EINVAL;
86477
86478 - table->data = &tmp;
86479 - table->maxlen = sizeof(unsigned long);
86480 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86481 + hugetlb_table = *table;
86482 + hugetlb_table.data = &tmp;
86483 + hugetlb_table.maxlen = sizeof(unsigned long);
86484 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86485 if (ret)
86486 goto out;
86487
86488 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
86489 struct hstate *h = &default_hstate;
86490 unsigned long tmp;
86491 int ret;
86492 + ctl_table_no_const hugetlb_table;
86493
86494 tmp = h->nr_overcommit_huge_pages;
86495
86496 if (write && h->order >= MAX_ORDER)
86497 return -EINVAL;
86498
86499 - table->data = &tmp;
86500 - table->maxlen = sizeof(unsigned long);
86501 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86502 + hugetlb_table = *table;
86503 + hugetlb_table.data = &tmp;
86504 + hugetlb_table.maxlen = sizeof(unsigned long);
86505 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86506 if (ret)
86507 goto out;
86508
86509 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
86510 return 1;
86511 }
86512
86513 +#ifdef CONFIG_PAX_SEGMEXEC
86514 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
86515 +{
86516 + struct mm_struct *mm = vma->vm_mm;
86517 + struct vm_area_struct *vma_m;
86518 + unsigned long address_m;
86519 + pte_t *ptep_m;
86520 +
86521 + vma_m = pax_find_mirror_vma(vma);
86522 + if (!vma_m)
86523 + return;
86524 +
86525 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86526 + address_m = address + SEGMEXEC_TASK_SIZE;
86527 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86528 + get_page(page_m);
86529 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86530 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86531 +}
86532 +#endif
86533 +
86534 /*
86535 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86536 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86537 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86538 make_huge_pte(vma, new_page, 1));
86539 page_remove_rmap(old_page);
86540 hugepage_add_new_anon_rmap(new_page, vma, address);
86541 +
86542 +#ifdef CONFIG_PAX_SEGMEXEC
86543 + pax_mirror_huge_pte(vma, address, new_page);
86544 +#endif
86545 +
86546 /* Make the old page be freed below */
86547 new_page = old_page;
86548 }
86549 @@ -2821,6 +2851,10 @@ retry:
86550 && (vma->vm_flags & VM_SHARED)));
86551 set_huge_pte_at(mm, address, ptep, new_pte);
86552
86553 +#ifdef CONFIG_PAX_SEGMEXEC
86554 + pax_mirror_huge_pte(vma, address, page);
86555 +#endif
86556 +
86557 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86558 /* Optimization, do the COW without a second fault */
86559 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86560 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86561 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86562 struct hstate *h = hstate_vma(vma);
86563
86564 +#ifdef CONFIG_PAX_SEGMEXEC
86565 + struct vm_area_struct *vma_m;
86566 +#endif
86567 +
86568 address &= huge_page_mask(h);
86569
86570 ptep = huge_pte_offset(mm, address);
86571 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86572 VM_FAULT_SET_HINDEX(hstate_index(h));
86573 }
86574
86575 +#ifdef CONFIG_PAX_SEGMEXEC
86576 + vma_m = pax_find_mirror_vma(vma);
86577 + if (vma_m) {
86578 + unsigned long address_m;
86579 +
86580 + if (vma->vm_start > vma_m->vm_start) {
86581 + address_m = address;
86582 + address -= SEGMEXEC_TASK_SIZE;
86583 + vma = vma_m;
86584 + h = hstate_vma(vma);
86585 + } else
86586 + address_m = address + SEGMEXEC_TASK_SIZE;
86587 +
86588 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86589 + return VM_FAULT_OOM;
86590 + address_m &= HPAGE_MASK;
86591 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86592 + }
86593 +#endif
86594 +
86595 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86596 if (!ptep)
86597 return VM_FAULT_OOM;
86598 diff --git a/mm/internal.h b/mm/internal.h
86599 index 4390ac6..fc60373c 100644
86600 --- a/mm/internal.h
86601 +++ b/mm/internal.h
86602 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86603 * in mm/page_alloc.c
86604 */
86605 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86606 +extern void free_compound_page(struct page *page);
86607 extern void prep_compound_page(struct page *page, unsigned long order);
86608 #ifdef CONFIG_MEMORY_FAILURE
86609 extern bool is_free_buddy_page(struct page *page);
86610 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86611
86612 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86613 unsigned long, unsigned long,
86614 - unsigned long, unsigned long);
86615 + unsigned long, unsigned long) __intentional_overflow(-1);
86616
86617 extern void set_pageblock_order(void);
86618 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86619 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86620 index c8d7f31..2dbeffd 100644
86621 --- a/mm/kmemleak.c
86622 +++ b/mm/kmemleak.c
86623 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86624
86625 for (i = 0; i < object->trace_len; i++) {
86626 void *ptr = (void *)object->trace[i];
86627 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86628 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86629 }
86630 }
86631
86632 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86633 return -ENOMEM;
86634 }
86635
86636 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86637 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86638 &kmemleak_fops);
86639 if (!dentry)
86640 pr_warning("Failed to create the debugfs kmemleak file\n");
86641 diff --git a/mm/maccess.c b/mm/maccess.c
86642 index d53adf9..03a24bf 100644
86643 --- a/mm/maccess.c
86644 +++ b/mm/maccess.c
86645 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86646 set_fs(KERNEL_DS);
86647 pagefault_disable();
86648 ret = __copy_from_user_inatomic(dst,
86649 - (__force const void __user *)src, size);
86650 + (const void __force_user *)src, size);
86651 pagefault_enable();
86652 set_fs(old_fs);
86653
86654 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86655
86656 set_fs(KERNEL_DS);
86657 pagefault_disable();
86658 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86659 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86660 pagefault_enable();
86661 set_fs(old_fs);
86662
86663 diff --git a/mm/madvise.c b/mm/madvise.c
86664 index 7055883..aafb1ed 100644
86665 --- a/mm/madvise.c
86666 +++ b/mm/madvise.c
86667 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86668 pgoff_t pgoff;
86669 unsigned long new_flags = vma->vm_flags;
86670
86671 +#ifdef CONFIG_PAX_SEGMEXEC
86672 + struct vm_area_struct *vma_m;
86673 +#endif
86674 +
86675 switch (behavior) {
86676 case MADV_NORMAL:
86677 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86678 @@ -126,6 +130,13 @@ success:
86679 /*
86680 * vm_flags is protected by the mmap_sem held in write mode.
86681 */
86682 +
86683 +#ifdef CONFIG_PAX_SEGMEXEC
86684 + vma_m = pax_find_mirror_vma(vma);
86685 + if (vma_m)
86686 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86687 +#endif
86688 +
86689 vma->vm_flags = new_flags;
86690
86691 out:
86692 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86693 struct vm_area_struct ** prev,
86694 unsigned long start, unsigned long end)
86695 {
86696 +
86697 +#ifdef CONFIG_PAX_SEGMEXEC
86698 + struct vm_area_struct *vma_m;
86699 +#endif
86700 +
86701 *prev = vma;
86702 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86703 return -EINVAL;
86704 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86705 zap_page_range(vma, start, end - start, &details);
86706 } else
86707 zap_page_range(vma, start, end - start, NULL);
86708 +
86709 +#ifdef CONFIG_PAX_SEGMEXEC
86710 + vma_m = pax_find_mirror_vma(vma);
86711 + if (vma_m) {
86712 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86713 + struct zap_details details = {
86714 + .nonlinear_vma = vma_m,
86715 + .last_index = ULONG_MAX,
86716 + };
86717 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86718 + } else
86719 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86720 + }
86721 +#endif
86722 +
86723 return 0;
86724 }
86725
86726 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86727 if (end < start)
86728 return error;
86729
86730 +#ifdef CONFIG_PAX_SEGMEXEC
86731 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86732 + if (end > SEGMEXEC_TASK_SIZE)
86733 + return error;
86734 + } else
86735 +#endif
86736 +
86737 + if (end > TASK_SIZE)
86738 + return error;
86739 +
86740 error = 0;
86741 if (end == start)
86742 return error;
86743 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
86744 index aa44621..99011b3 100644
86745 --- a/mm/memcontrol.c
86746 +++ b/mm/memcontrol.c
86747 @@ -2772,6 +2772,8 @@ done:
86748 return 0;
86749 nomem:
86750 *ptr = NULL;
86751 + if (gfp_mask & __GFP_NOFAIL)
86752 + return 0;
86753 return -ENOMEM;
86754 bypass:
86755 *ptr = root_mem_cgroup;
86756 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86757 index 2c13aa7..64cbc3f 100644
86758 --- a/mm/memory-failure.c
86759 +++ b/mm/memory-failure.c
86760 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86761
86762 int sysctl_memory_failure_recovery __read_mostly = 1;
86763
86764 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86765 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86766
86767 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86768
86769 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86770 pfn, t->comm, t->pid);
86771 si.si_signo = SIGBUS;
86772 si.si_errno = 0;
86773 - si.si_addr = (void *)addr;
86774 + si.si_addr = (void __user *)addr;
86775 #ifdef __ARCH_SI_TRAPNO
86776 si.si_trapno = trapno;
86777 #endif
86778 @@ -760,7 +760,7 @@ static struct page_state {
86779 unsigned long res;
86780 char *msg;
86781 int (*action)(struct page *p, unsigned long pfn);
86782 -} error_states[] = {
86783 +} __do_const error_states[] = {
86784 { reserved, reserved, "reserved kernel", me_kernel },
86785 /*
86786 * free pages are specially detected outside this table:
86787 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86788 nr_pages = 1 << compound_order(hpage);
86789 else /* normal page or thp */
86790 nr_pages = 1;
86791 - atomic_long_add(nr_pages, &num_poisoned_pages);
86792 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86793
86794 /*
86795 * We need/can do nothing about count=0 pages.
86796 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86797 if (!PageHWPoison(hpage)
86798 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86799 || (p != hpage && TestSetPageHWPoison(hpage))) {
86800 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86801 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86802 return 0;
86803 }
86804 set_page_hwpoison_huge_page(hpage);
86805 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86806 }
86807 if (hwpoison_filter(p)) {
86808 if (TestClearPageHWPoison(p))
86809 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86810 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86811 unlock_page(hpage);
86812 put_page(hpage);
86813 return 0;
86814 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86815 return 0;
86816 }
86817 if (TestClearPageHWPoison(p))
86818 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86819 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86820 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86821 return 0;
86822 }
86823 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86824 */
86825 if (TestClearPageHWPoison(page)) {
86826 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86827 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86828 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86829 freeit = 1;
86830 if (PageHuge(page))
86831 clear_page_hwpoison_huge_page(page);
86832 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86833 } else {
86834 set_page_hwpoison_huge_page(hpage);
86835 dequeue_hwpoisoned_huge_page(hpage);
86836 - atomic_long_add(1 << compound_trans_order(hpage),
86837 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86838 &num_poisoned_pages);
86839 }
86840 return ret;
86841 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86842 if (PageHuge(page)) {
86843 set_page_hwpoison_huge_page(hpage);
86844 dequeue_hwpoisoned_huge_page(hpage);
86845 - atomic_long_add(1 << compound_trans_order(hpage),
86846 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86847 &num_poisoned_pages);
86848 } else {
86849 SetPageHWPoison(page);
86850 - atomic_long_inc(&num_poisoned_pages);
86851 + atomic_long_inc_unchecked(&num_poisoned_pages);
86852 }
86853 }
86854 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86855 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86856 put_page(page);
86857 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86858 SetPageHWPoison(page);
86859 - atomic_long_inc(&num_poisoned_pages);
86860 + atomic_long_inc_unchecked(&num_poisoned_pages);
86861 return 0;
86862 }
86863
86864 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86865 if (!is_free_buddy_page(page))
86866 pr_info("soft offline: %#lx: page leaked\n",
86867 pfn);
86868 - atomic_long_inc(&num_poisoned_pages);
86869 + atomic_long_inc_unchecked(&num_poisoned_pages);
86870 }
86871 } else {
86872 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86873 diff --git a/mm/memory.c b/mm/memory.c
86874 index 168a090..bfa069a 100644
86875 --- a/mm/memory.c
86876 +++ b/mm/memory.c
86877 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86878 free_pte_range(tlb, pmd, addr);
86879 } while (pmd++, addr = next, addr != end);
86880
86881 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86882 start &= PUD_MASK;
86883 if (start < floor)
86884 return;
86885 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86886 pmd = pmd_offset(pud, start);
86887 pud_clear(pud);
86888 pmd_free_tlb(tlb, pmd, start);
86889 +#endif
86890 +
86891 }
86892
86893 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86894 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86895 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86896 } while (pud++, addr = next, addr != end);
86897
86898 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86899 start &= PGDIR_MASK;
86900 if (start < floor)
86901 return;
86902 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86903 pud = pud_offset(pgd, start);
86904 pgd_clear(pgd);
86905 pud_free_tlb(tlb, pud, start);
86906 +#endif
86907 +
86908 }
86909
86910 /*
86911 @@ -1647,12 +1653,6 @@ no_page_table:
86912 return page;
86913 }
86914
86915 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86916 -{
86917 - return stack_guard_page_start(vma, addr) ||
86918 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86919 -}
86920 -
86921 /**
86922 * __get_user_pages() - pin user pages in memory
86923 * @tsk: task_struct of target task
86924 @@ -1739,10 +1739,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86925
86926 i = 0;
86927
86928 - do {
86929 + while (nr_pages) {
86930 struct vm_area_struct *vma;
86931
86932 - vma = find_extend_vma(mm, start);
86933 + vma = find_vma(mm, start);
86934 if (!vma && in_gate_area(mm, start)) {
86935 unsigned long pg = start & PAGE_MASK;
86936 pgd_t *pgd;
86937 @@ -1791,7 +1791,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86938 goto next_page;
86939 }
86940
86941 - if (!vma ||
86942 + if (!vma || start < vma->vm_start ||
86943 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86944 !(vm_flags & vma->vm_flags))
86945 return i ? : -EFAULT;
86946 @@ -1820,11 +1820,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86947 int ret;
86948 unsigned int fault_flags = 0;
86949
86950 - /* For mlock, just skip the stack guard page. */
86951 - if (foll_flags & FOLL_MLOCK) {
86952 - if (stack_guard_page(vma, start))
86953 - goto next_page;
86954 - }
86955 if (foll_flags & FOLL_WRITE)
86956 fault_flags |= FAULT_FLAG_WRITE;
86957 if (nonblocking)
86958 @@ -1904,7 +1899,7 @@ next_page:
86959 start += page_increm * PAGE_SIZE;
86960 nr_pages -= page_increm;
86961 } while (nr_pages && start < vma->vm_end);
86962 - } while (nr_pages);
86963 + }
86964 return i;
86965 }
86966 EXPORT_SYMBOL(__get_user_pages);
86967 @@ -2111,6 +2106,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86968 page_add_file_rmap(page);
86969 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86970
86971 +#ifdef CONFIG_PAX_SEGMEXEC
86972 + pax_mirror_file_pte(vma, addr, page, ptl);
86973 +#endif
86974 +
86975 retval = 0;
86976 pte_unmap_unlock(pte, ptl);
86977 return retval;
86978 @@ -2155,9 +2154,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86979 if (!page_count(page))
86980 return -EINVAL;
86981 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86982 +
86983 +#ifdef CONFIG_PAX_SEGMEXEC
86984 + struct vm_area_struct *vma_m;
86985 +#endif
86986 +
86987 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86988 BUG_ON(vma->vm_flags & VM_PFNMAP);
86989 vma->vm_flags |= VM_MIXEDMAP;
86990 +
86991 +#ifdef CONFIG_PAX_SEGMEXEC
86992 + vma_m = pax_find_mirror_vma(vma);
86993 + if (vma_m)
86994 + vma_m->vm_flags |= VM_MIXEDMAP;
86995 +#endif
86996 +
86997 }
86998 return insert_page(vma, addr, page, vma->vm_page_prot);
86999 }
87000 @@ -2240,6 +2251,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
87001 unsigned long pfn)
87002 {
87003 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
87004 + BUG_ON(vma->vm_mirror);
87005
87006 if (addr < vma->vm_start || addr >= vma->vm_end)
87007 return -EFAULT;
87008 @@ -2487,7 +2499,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
87009
87010 BUG_ON(pud_huge(*pud));
87011
87012 - pmd = pmd_alloc(mm, pud, addr);
87013 + pmd = (mm == &init_mm) ?
87014 + pmd_alloc_kernel(mm, pud, addr) :
87015 + pmd_alloc(mm, pud, addr);
87016 if (!pmd)
87017 return -ENOMEM;
87018 do {
87019 @@ -2507,7 +2521,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
87020 unsigned long next;
87021 int err;
87022
87023 - pud = pud_alloc(mm, pgd, addr);
87024 + pud = (mm == &init_mm) ?
87025 + pud_alloc_kernel(mm, pgd, addr) :
87026 + pud_alloc(mm, pgd, addr);
87027 if (!pud)
87028 return -ENOMEM;
87029 do {
87030 @@ -2595,6 +2611,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
87031 copy_user_highpage(dst, src, va, vma);
87032 }
87033
87034 +#ifdef CONFIG_PAX_SEGMEXEC
87035 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
87036 +{
87037 + struct mm_struct *mm = vma->vm_mm;
87038 + spinlock_t *ptl;
87039 + pte_t *pte, entry;
87040 +
87041 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
87042 + entry = *pte;
87043 + if (!pte_present(entry)) {
87044 + if (!pte_none(entry)) {
87045 + BUG_ON(pte_file(entry));
87046 + free_swap_and_cache(pte_to_swp_entry(entry));
87047 + pte_clear_not_present_full(mm, address, pte, 0);
87048 + }
87049 + } else {
87050 + struct page *page;
87051 +
87052 + flush_cache_page(vma, address, pte_pfn(entry));
87053 + entry = ptep_clear_flush(vma, address, pte);
87054 + BUG_ON(pte_dirty(entry));
87055 + page = vm_normal_page(vma, address, entry);
87056 + if (page) {
87057 + update_hiwater_rss(mm);
87058 + if (PageAnon(page))
87059 + dec_mm_counter_fast(mm, MM_ANONPAGES);
87060 + else
87061 + dec_mm_counter_fast(mm, MM_FILEPAGES);
87062 + page_remove_rmap(page);
87063 + page_cache_release(page);
87064 + }
87065 + }
87066 + pte_unmap_unlock(pte, ptl);
87067 +}
87068 +
87069 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
87070 + *
87071 + * the ptl of the lower mapped page is held on entry and is not released on exit
87072 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
87073 + */
87074 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87075 +{
87076 + struct mm_struct *mm = vma->vm_mm;
87077 + unsigned long address_m;
87078 + spinlock_t *ptl_m;
87079 + struct vm_area_struct *vma_m;
87080 + pmd_t *pmd_m;
87081 + pte_t *pte_m, entry_m;
87082 +
87083 + BUG_ON(!page_m || !PageAnon(page_m));
87084 +
87085 + vma_m = pax_find_mirror_vma(vma);
87086 + if (!vma_m)
87087 + return;
87088 +
87089 + BUG_ON(!PageLocked(page_m));
87090 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87091 + address_m = address + SEGMEXEC_TASK_SIZE;
87092 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87093 + pte_m = pte_offset_map(pmd_m, address_m);
87094 + ptl_m = pte_lockptr(mm, pmd_m);
87095 + if (ptl != ptl_m) {
87096 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87097 + if (!pte_none(*pte_m))
87098 + goto out;
87099 + }
87100 +
87101 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87102 + page_cache_get(page_m);
87103 + page_add_anon_rmap(page_m, vma_m, address_m);
87104 + inc_mm_counter_fast(mm, MM_ANONPAGES);
87105 + set_pte_at(mm, address_m, pte_m, entry_m);
87106 + update_mmu_cache(vma_m, address_m, pte_m);
87107 +out:
87108 + if (ptl != ptl_m)
87109 + spin_unlock(ptl_m);
87110 + pte_unmap(pte_m);
87111 + unlock_page(page_m);
87112 +}
87113 +
87114 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87115 +{
87116 + struct mm_struct *mm = vma->vm_mm;
87117 + unsigned long address_m;
87118 + spinlock_t *ptl_m;
87119 + struct vm_area_struct *vma_m;
87120 + pmd_t *pmd_m;
87121 + pte_t *pte_m, entry_m;
87122 +
87123 + BUG_ON(!page_m || PageAnon(page_m));
87124 +
87125 + vma_m = pax_find_mirror_vma(vma);
87126 + if (!vma_m)
87127 + return;
87128 +
87129 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87130 + address_m = address + SEGMEXEC_TASK_SIZE;
87131 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87132 + pte_m = pte_offset_map(pmd_m, address_m);
87133 + ptl_m = pte_lockptr(mm, pmd_m);
87134 + if (ptl != ptl_m) {
87135 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87136 + if (!pte_none(*pte_m))
87137 + goto out;
87138 + }
87139 +
87140 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87141 + page_cache_get(page_m);
87142 + page_add_file_rmap(page_m);
87143 + inc_mm_counter_fast(mm, MM_FILEPAGES);
87144 + set_pte_at(mm, address_m, pte_m, entry_m);
87145 + update_mmu_cache(vma_m, address_m, pte_m);
87146 +out:
87147 + if (ptl != ptl_m)
87148 + spin_unlock(ptl_m);
87149 + pte_unmap(pte_m);
87150 +}
87151 +
87152 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
87153 +{
87154 + struct mm_struct *mm = vma->vm_mm;
87155 + unsigned long address_m;
87156 + spinlock_t *ptl_m;
87157 + struct vm_area_struct *vma_m;
87158 + pmd_t *pmd_m;
87159 + pte_t *pte_m, entry_m;
87160 +
87161 + vma_m = pax_find_mirror_vma(vma);
87162 + if (!vma_m)
87163 + return;
87164 +
87165 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87166 + address_m = address + SEGMEXEC_TASK_SIZE;
87167 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87168 + pte_m = pte_offset_map(pmd_m, address_m);
87169 + ptl_m = pte_lockptr(mm, pmd_m);
87170 + if (ptl != ptl_m) {
87171 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87172 + if (!pte_none(*pte_m))
87173 + goto out;
87174 + }
87175 +
87176 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
87177 + set_pte_at(mm, address_m, pte_m, entry_m);
87178 +out:
87179 + if (ptl != ptl_m)
87180 + spin_unlock(ptl_m);
87181 + pte_unmap(pte_m);
87182 +}
87183 +
87184 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
87185 +{
87186 + struct page *page_m;
87187 + pte_t entry;
87188 +
87189 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
87190 + goto out;
87191 +
87192 + entry = *pte;
87193 + page_m = vm_normal_page(vma, address, entry);
87194 + if (!page_m)
87195 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
87196 + else if (PageAnon(page_m)) {
87197 + if (pax_find_mirror_vma(vma)) {
87198 + pte_unmap_unlock(pte, ptl);
87199 + lock_page(page_m);
87200 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
87201 + if (pte_same(entry, *pte))
87202 + pax_mirror_anon_pte(vma, address, page_m, ptl);
87203 + else
87204 + unlock_page(page_m);
87205 + }
87206 + } else
87207 + pax_mirror_file_pte(vma, address, page_m, ptl);
87208 +
87209 +out:
87210 + pte_unmap_unlock(pte, ptl);
87211 +}
87212 +#endif
87213 +
87214 /*
87215 * This routine handles present pages, when users try to write
87216 * to a shared page. It is done by copying the page to a new address
87217 @@ -2811,6 +3007,12 @@ gotten:
87218 */
87219 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87220 if (likely(pte_same(*page_table, orig_pte))) {
87221 +
87222 +#ifdef CONFIG_PAX_SEGMEXEC
87223 + if (pax_find_mirror_vma(vma))
87224 + BUG_ON(!trylock_page(new_page));
87225 +#endif
87226 +
87227 if (old_page) {
87228 if (!PageAnon(old_page)) {
87229 dec_mm_counter_fast(mm, MM_FILEPAGES);
87230 @@ -2862,6 +3064,10 @@ gotten:
87231 page_remove_rmap(old_page);
87232 }
87233
87234 +#ifdef CONFIG_PAX_SEGMEXEC
87235 + pax_mirror_anon_pte(vma, address, new_page, ptl);
87236 +#endif
87237 +
87238 /* Free the old page.. */
87239 new_page = old_page;
87240 ret |= VM_FAULT_WRITE;
87241 @@ -3139,6 +3345,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87242 swap_free(entry);
87243 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
87244 try_to_free_swap(page);
87245 +
87246 +#ifdef CONFIG_PAX_SEGMEXEC
87247 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
87248 +#endif
87249 +
87250 unlock_page(page);
87251 if (page != swapcache) {
87252 /*
87253 @@ -3162,6 +3373,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87254
87255 /* No need to invalidate - it was non-present before */
87256 update_mmu_cache(vma, address, page_table);
87257 +
87258 +#ifdef CONFIG_PAX_SEGMEXEC
87259 + pax_mirror_anon_pte(vma, address, page, ptl);
87260 +#endif
87261 +
87262 unlock:
87263 pte_unmap_unlock(page_table, ptl);
87264 out:
87265 @@ -3181,40 +3397,6 @@ out_release:
87266 }
87267
87268 /*
87269 - * This is like a special single-page "expand_{down|up}wards()",
87270 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
87271 - * doesn't hit another vma.
87272 - */
87273 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
87274 -{
87275 - address &= PAGE_MASK;
87276 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
87277 - struct vm_area_struct *prev = vma->vm_prev;
87278 -
87279 - /*
87280 - * Is there a mapping abutting this one below?
87281 - *
87282 - * That's only ok if it's the same stack mapping
87283 - * that has gotten split..
87284 - */
87285 - if (prev && prev->vm_end == address)
87286 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
87287 -
87288 - expand_downwards(vma, address - PAGE_SIZE);
87289 - }
87290 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
87291 - struct vm_area_struct *next = vma->vm_next;
87292 -
87293 - /* As VM_GROWSDOWN but s/below/above/ */
87294 - if (next && next->vm_start == address + PAGE_SIZE)
87295 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
87296 -
87297 - expand_upwards(vma, address + PAGE_SIZE);
87298 - }
87299 - return 0;
87300 -}
87301 -
87302 -/*
87303 * We enter with non-exclusive mmap_sem (to exclude vma changes,
87304 * but allow concurrent faults), and pte mapped but not yet locked.
87305 * We return with mmap_sem still held, but pte unmapped and unlocked.
87306 @@ -3223,27 +3405,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87307 unsigned long address, pte_t *page_table, pmd_t *pmd,
87308 unsigned int flags)
87309 {
87310 - struct page *page;
87311 + struct page *page = NULL;
87312 spinlock_t *ptl;
87313 pte_t entry;
87314
87315 - pte_unmap(page_table);
87316 -
87317 - /* Check if we need to add a guard page to the stack */
87318 - if (check_stack_guard_page(vma, address) < 0)
87319 - return VM_FAULT_SIGBUS;
87320 -
87321 - /* Use the zero-page for reads */
87322 if (!(flags & FAULT_FLAG_WRITE)) {
87323 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
87324 vma->vm_page_prot));
87325 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87326 + ptl = pte_lockptr(mm, pmd);
87327 + spin_lock(ptl);
87328 if (!pte_none(*page_table))
87329 goto unlock;
87330 goto setpte;
87331 }
87332
87333 /* Allocate our own private page. */
87334 + pte_unmap(page_table);
87335 +
87336 if (unlikely(anon_vma_prepare(vma)))
87337 goto oom;
87338 page = alloc_zeroed_user_highpage_movable(vma, address);
87339 @@ -3267,6 +3445,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87340 if (!pte_none(*page_table))
87341 goto release;
87342
87343 +#ifdef CONFIG_PAX_SEGMEXEC
87344 + if (pax_find_mirror_vma(vma))
87345 + BUG_ON(!trylock_page(page));
87346 +#endif
87347 +
87348 inc_mm_counter_fast(mm, MM_ANONPAGES);
87349 page_add_new_anon_rmap(page, vma, address);
87350 setpte:
87351 @@ -3274,6 +3457,12 @@ setpte:
87352
87353 /* No need to invalidate - it was non-present before */
87354 update_mmu_cache(vma, address, page_table);
87355 +
87356 +#ifdef CONFIG_PAX_SEGMEXEC
87357 + if (page)
87358 + pax_mirror_anon_pte(vma, address, page, ptl);
87359 +#endif
87360 +
87361 unlock:
87362 pte_unmap_unlock(page_table, ptl);
87363 return 0;
87364 @@ -3417,6 +3606,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87365 */
87366 /* Only go through if we didn't race with anybody else... */
87367 if (likely(pte_same(*page_table, orig_pte))) {
87368 +
87369 +#ifdef CONFIG_PAX_SEGMEXEC
87370 + if (anon && pax_find_mirror_vma(vma))
87371 + BUG_ON(!trylock_page(page));
87372 +#endif
87373 +
87374 flush_icache_page(vma, page);
87375 entry = mk_pte(page, vma->vm_page_prot);
87376 if (flags & FAULT_FLAG_WRITE)
87377 @@ -3438,6 +3633,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87378
87379 /* no need to invalidate: a not-present page won't be cached */
87380 update_mmu_cache(vma, address, page_table);
87381 +
87382 +#ifdef CONFIG_PAX_SEGMEXEC
87383 + if (anon)
87384 + pax_mirror_anon_pte(vma, address, page, ptl);
87385 + else
87386 + pax_mirror_file_pte(vma, address, page, ptl);
87387 +#endif
87388 +
87389 } else {
87390 if (cow_page)
87391 mem_cgroup_uncharge_page(cow_page);
87392 @@ -3748,6 +3951,12 @@ int handle_pte_fault(struct mm_struct *mm,
87393 if (flags & FAULT_FLAG_WRITE)
87394 flush_tlb_fix_spurious_fault(vma, address);
87395 }
87396 +
87397 +#ifdef CONFIG_PAX_SEGMEXEC
87398 + pax_mirror_pte(vma, address, pte, pmd, ptl);
87399 + return 0;
87400 +#endif
87401 +
87402 unlock:
87403 pte_unmap_unlock(pte, ptl);
87404 return 0;
87405 @@ -3764,6 +3973,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87406 pmd_t *pmd;
87407 pte_t *pte;
87408
87409 +#ifdef CONFIG_PAX_SEGMEXEC
87410 + struct vm_area_struct *vma_m;
87411 +#endif
87412 +
87413 __set_current_state(TASK_RUNNING);
87414
87415 count_vm_event(PGFAULT);
87416 @@ -3775,6 +3988,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87417 if (unlikely(is_vm_hugetlb_page(vma)))
87418 return hugetlb_fault(mm, vma, address, flags);
87419
87420 +#ifdef CONFIG_PAX_SEGMEXEC
87421 + vma_m = pax_find_mirror_vma(vma);
87422 + if (vma_m) {
87423 + unsigned long address_m;
87424 + pgd_t *pgd_m;
87425 + pud_t *pud_m;
87426 + pmd_t *pmd_m;
87427 +
87428 + if (vma->vm_start > vma_m->vm_start) {
87429 + address_m = address;
87430 + address -= SEGMEXEC_TASK_SIZE;
87431 + vma = vma_m;
87432 + } else
87433 + address_m = address + SEGMEXEC_TASK_SIZE;
87434 +
87435 + pgd_m = pgd_offset(mm, address_m);
87436 + pud_m = pud_alloc(mm, pgd_m, address_m);
87437 + if (!pud_m)
87438 + return VM_FAULT_OOM;
87439 + pmd_m = pmd_alloc(mm, pud_m, address_m);
87440 + if (!pmd_m)
87441 + return VM_FAULT_OOM;
87442 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
87443 + return VM_FAULT_OOM;
87444 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
87445 + }
87446 +#endif
87447 +
87448 retry:
87449 pgd = pgd_offset(mm, address);
87450 pud = pud_alloc(mm, pgd, address);
87451 @@ -3873,6 +4114,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87452 spin_unlock(&mm->page_table_lock);
87453 return 0;
87454 }
87455 +
87456 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87457 +{
87458 + pud_t *new = pud_alloc_one(mm, address);
87459 + if (!new)
87460 + return -ENOMEM;
87461 +
87462 + smp_wmb(); /* See comment in __pte_alloc */
87463 +
87464 + spin_lock(&mm->page_table_lock);
87465 + if (pgd_present(*pgd)) /* Another has populated it */
87466 + pud_free(mm, new);
87467 + else
87468 + pgd_populate_kernel(mm, pgd, new);
87469 + spin_unlock(&mm->page_table_lock);
87470 + return 0;
87471 +}
87472 #endif /* __PAGETABLE_PUD_FOLDED */
87473
87474 #ifndef __PAGETABLE_PMD_FOLDED
87475 @@ -3903,6 +4161,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
87476 spin_unlock(&mm->page_table_lock);
87477 return 0;
87478 }
87479 +
87480 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
87481 +{
87482 + pmd_t *new = pmd_alloc_one(mm, address);
87483 + if (!new)
87484 + return -ENOMEM;
87485 +
87486 + smp_wmb(); /* See comment in __pte_alloc */
87487 +
87488 + spin_lock(&mm->page_table_lock);
87489 +#ifndef __ARCH_HAS_4LEVEL_HACK
87490 + if (pud_present(*pud)) /* Another has populated it */
87491 + pmd_free(mm, new);
87492 + else
87493 + pud_populate_kernel(mm, pud, new);
87494 +#else
87495 + if (pgd_present(*pud)) /* Another has populated it */
87496 + pmd_free(mm, new);
87497 + else
87498 + pgd_populate_kernel(mm, pud, new);
87499 +#endif /* __ARCH_HAS_4LEVEL_HACK */
87500 + spin_unlock(&mm->page_table_lock);
87501 + return 0;
87502 +}
87503 #endif /* __PAGETABLE_PMD_FOLDED */
87504
87505 #if !defined(__HAVE_ARCH_GATE_AREA)
87506 @@ -3916,7 +4198,7 @@ static int __init gate_vma_init(void)
87507 gate_vma.vm_start = FIXADDR_USER_START;
87508 gate_vma.vm_end = FIXADDR_USER_END;
87509 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
87510 - gate_vma.vm_page_prot = __P101;
87511 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
87512
87513 return 0;
87514 }
87515 @@ -4050,8 +4332,8 @@ out:
87516 return ret;
87517 }
87518
87519 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87520 - void *buf, int len, int write)
87521 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87522 + void *buf, size_t len, int write)
87523 {
87524 resource_size_t phys_addr;
87525 unsigned long prot = 0;
87526 @@ -4077,8 +4359,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
87527 * Access another process' address space as given in mm. If non-NULL, use the
87528 * given task for page fault accounting.
87529 */
87530 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87531 - unsigned long addr, void *buf, int len, int write)
87532 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87533 + unsigned long addr, void *buf, size_t len, int write)
87534 {
87535 struct vm_area_struct *vma;
87536 void *old_buf = buf;
87537 @@ -4086,7 +4368,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87538 down_read(&mm->mmap_sem);
87539 /* ignore errors, just check how much was successfully transferred */
87540 while (len) {
87541 - int bytes, ret, offset;
87542 + ssize_t bytes, ret, offset;
87543 void *maddr;
87544 struct page *page = NULL;
87545
87546 @@ -4145,8 +4427,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87547 *
87548 * The caller must hold a reference on @mm.
87549 */
87550 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87551 - void *buf, int len, int write)
87552 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87553 + void *buf, size_t len, int write)
87554 {
87555 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87556 }
87557 @@ -4156,11 +4438,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87558 * Source/target buffer must be kernel space,
87559 * Do not walk the page table directly, use get_user_pages
87560 */
87561 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87562 - void *buf, int len, int write)
87563 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87564 + void *buf, size_t len, int write)
87565 {
87566 struct mm_struct *mm;
87567 - int ret;
87568 + ssize_t ret;
87569
87570 mm = get_task_mm(tsk);
87571 if (!mm)
87572 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87573 index 4baf12e..5497066 100644
87574 --- a/mm/mempolicy.c
87575 +++ b/mm/mempolicy.c
87576 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87577 unsigned long vmstart;
87578 unsigned long vmend;
87579
87580 +#ifdef CONFIG_PAX_SEGMEXEC
87581 + struct vm_area_struct *vma_m;
87582 +#endif
87583 +
87584 vma = find_vma(mm, start);
87585 if (!vma || vma->vm_start > start)
87586 return -EFAULT;
87587 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87588 err = vma_replace_policy(vma, new_pol);
87589 if (err)
87590 goto out;
87591 +
87592 +#ifdef CONFIG_PAX_SEGMEXEC
87593 + vma_m = pax_find_mirror_vma(vma);
87594 + if (vma_m) {
87595 + err = vma_replace_policy(vma_m, new_pol);
87596 + if (err)
87597 + goto out;
87598 + }
87599 +#endif
87600 +
87601 }
87602
87603 out:
87604 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87605
87606 if (end < start)
87607 return -EINVAL;
87608 +
87609 +#ifdef CONFIG_PAX_SEGMEXEC
87610 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87611 + if (end > SEGMEXEC_TASK_SIZE)
87612 + return -EINVAL;
87613 + } else
87614 +#endif
87615 +
87616 + if (end > TASK_SIZE)
87617 + return -EINVAL;
87618 +
87619 if (end == start)
87620 return 0;
87621
87622 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87623 */
87624 tcred = __task_cred(task);
87625 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87626 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87627 - !capable(CAP_SYS_NICE)) {
87628 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87629 rcu_read_unlock();
87630 err = -EPERM;
87631 goto out_put;
87632 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87633 goto out;
87634 }
87635
87636 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87637 + if (mm != current->mm &&
87638 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87639 + mmput(mm);
87640 + err = -EPERM;
87641 + goto out;
87642 + }
87643 +#endif
87644 +
87645 err = do_migrate_pages(mm, old, new,
87646 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87647
87648 diff --git a/mm/migrate.c b/mm/migrate.c
87649 index d22f6f0..f12a8d0 100644
87650 --- a/mm/migrate.c
87651 +++ b/mm/migrate.c
87652 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87653 */
87654 tcred = __task_cred(task);
87655 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87656 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87657 - !capable(CAP_SYS_NICE)) {
87658 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87659 rcu_read_unlock();
87660 err = -EPERM;
87661 goto out;
87662 diff --git a/mm/mlock.c b/mm/mlock.c
87663 index 79b7cf7..37472bf 100644
87664 --- a/mm/mlock.c
87665 +++ b/mm/mlock.c
87666 @@ -13,6 +13,7 @@
87667 #include <linux/pagemap.h>
87668 #include <linux/mempolicy.h>
87669 #include <linux/syscalls.h>
87670 +#include <linux/security.h>
87671 #include <linux/sched.h>
87672 #include <linux/export.h>
87673 #include <linux/rmap.h>
87674 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87675 {
87676 unsigned long nstart, end, tmp;
87677 struct vm_area_struct * vma, * prev;
87678 - int error;
87679 + int error = 0;
87680
87681 VM_BUG_ON(start & ~PAGE_MASK);
87682 VM_BUG_ON(len != PAGE_ALIGN(len));
87683 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87684 return -EINVAL;
87685 if (end == start)
87686 return 0;
87687 + if (end > TASK_SIZE)
87688 + return -EINVAL;
87689 +
87690 vma = find_vma(current->mm, start);
87691 if (!vma || vma->vm_start > start)
87692 return -ENOMEM;
87693 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87694 for (nstart = start ; ; ) {
87695 vm_flags_t newflags;
87696
87697 +#ifdef CONFIG_PAX_SEGMEXEC
87698 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87699 + break;
87700 +#endif
87701 +
87702 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87703
87704 newflags = vma->vm_flags & ~VM_LOCKED;
87705 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87706 lock_limit >>= PAGE_SHIFT;
87707
87708 /* check against resource limits */
87709 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87710 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87711 error = do_mlock(start, len, 1);
87712 up_write(&current->mm->mmap_sem);
87713 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87714 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87715 vm_flags_t newflags;
87716
87717 +#ifdef CONFIG_PAX_SEGMEXEC
87718 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87719 + break;
87720 +#endif
87721 +
87722 newflags = vma->vm_flags & ~VM_LOCKED;
87723 if (flags & MCL_CURRENT)
87724 newflags |= VM_LOCKED;
87725
87726 /* Ignore errors */
87727 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87728 + cond_resched();
87729 }
87730 out:
87731 return 0;
87732 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87733 lock_limit >>= PAGE_SHIFT;
87734
87735 ret = -ENOMEM;
87736 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87737 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87738 capable(CAP_IPC_LOCK))
87739 ret = do_mlockall(flags);
87740 diff --git a/mm/mmap.c b/mm/mmap.c
87741 index f9c97d1..3468d3b 100644
87742 --- a/mm/mmap.c
87743 +++ b/mm/mmap.c
87744 @@ -36,6 +36,7 @@
87745 #include <linux/sched/sysctl.h>
87746 #include <linux/notifier.h>
87747 #include <linux/memory.h>
87748 +#include <linux/random.h>
87749
87750 #include <asm/uaccess.h>
87751 #include <asm/cacheflush.h>
87752 @@ -52,6 +53,16 @@
87753 #define arch_rebalance_pgtables(addr, len) (addr)
87754 #endif
87755
87756 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87757 +{
87758 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87759 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87760 + up_read(&mm->mmap_sem);
87761 + BUG();
87762 + }
87763 +#endif
87764 +}
87765 +
87766 static void unmap_region(struct mm_struct *mm,
87767 struct vm_area_struct *vma, struct vm_area_struct *prev,
87768 unsigned long start, unsigned long end);
87769 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87770 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87771 *
87772 */
87773 -pgprot_t protection_map[16] = {
87774 +pgprot_t protection_map[16] __read_only = {
87775 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87776 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87777 };
87778
87779 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87780 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87781 {
87782 - return __pgprot(pgprot_val(protection_map[vm_flags &
87783 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87784 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87785 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87786 +
87787 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87788 + if (!(__supported_pte_mask & _PAGE_NX) &&
87789 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87790 + (vm_flags & (VM_READ | VM_WRITE)))
87791 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87792 +#endif
87793 +
87794 + return prot;
87795 }
87796 EXPORT_SYMBOL(vm_get_page_prot);
87797
87798 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87799 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87800 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87801 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87802 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87803 /*
87804 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87805 * other variables. It can be updated by several CPUs frequently.
87806 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87807 struct vm_area_struct *next = vma->vm_next;
87808
87809 might_sleep();
87810 + BUG_ON(vma->vm_mirror);
87811 if (vma->vm_ops && vma->vm_ops->close)
87812 vma->vm_ops->close(vma);
87813 if (vma->vm_file)
87814 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87815 * not page aligned -Ram Gupta
87816 */
87817 rlim = rlimit(RLIMIT_DATA);
87818 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87819 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87820 (mm->end_data - mm->start_data) > rlim)
87821 goto out;
87822 @@ -933,6 +956,12 @@ static int
87823 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87824 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87825 {
87826 +
87827 +#ifdef CONFIG_PAX_SEGMEXEC
87828 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87829 + return 0;
87830 +#endif
87831 +
87832 if (is_mergeable_vma(vma, file, vm_flags) &&
87833 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87834 if (vma->vm_pgoff == vm_pgoff)
87835 @@ -952,6 +981,12 @@ static int
87836 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87837 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87838 {
87839 +
87840 +#ifdef CONFIG_PAX_SEGMEXEC
87841 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87842 + return 0;
87843 +#endif
87844 +
87845 if (is_mergeable_vma(vma, file, vm_flags) &&
87846 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87847 pgoff_t vm_pglen;
87848 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87849 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87850 struct vm_area_struct *prev, unsigned long addr,
87851 unsigned long end, unsigned long vm_flags,
87852 - struct anon_vma *anon_vma, struct file *file,
87853 + struct anon_vma *anon_vma, struct file *file,
87854 pgoff_t pgoff, struct mempolicy *policy)
87855 {
87856 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87857 struct vm_area_struct *area, *next;
87858 int err;
87859
87860 +#ifdef CONFIG_PAX_SEGMEXEC
87861 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87862 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87863 +
87864 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87865 +#endif
87866 +
87867 /*
87868 * We later require that vma->vm_flags == vm_flags,
87869 * so this tests vma->vm_flags & VM_SPECIAL, too.
87870 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87871 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87872 next = next->vm_next;
87873
87874 +#ifdef CONFIG_PAX_SEGMEXEC
87875 + if (prev)
87876 + prev_m = pax_find_mirror_vma(prev);
87877 + if (area)
87878 + area_m = pax_find_mirror_vma(area);
87879 + if (next)
87880 + next_m = pax_find_mirror_vma(next);
87881 +#endif
87882 +
87883 /*
87884 * Can it merge with the predecessor?
87885 */
87886 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87887 /* cases 1, 6 */
87888 err = vma_adjust(prev, prev->vm_start,
87889 next->vm_end, prev->vm_pgoff, NULL);
87890 - } else /* cases 2, 5, 7 */
87891 +
87892 +#ifdef CONFIG_PAX_SEGMEXEC
87893 + if (!err && prev_m)
87894 + err = vma_adjust(prev_m, prev_m->vm_start,
87895 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87896 +#endif
87897 +
87898 + } else { /* cases 2, 5, 7 */
87899 err = vma_adjust(prev, prev->vm_start,
87900 end, prev->vm_pgoff, NULL);
87901 +
87902 +#ifdef CONFIG_PAX_SEGMEXEC
87903 + if (!err && prev_m)
87904 + err = vma_adjust(prev_m, prev_m->vm_start,
87905 + end_m, prev_m->vm_pgoff, NULL);
87906 +#endif
87907 +
87908 + }
87909 if (err)
87910 return NULL;
87911 khugepaged_enter_vma_merge(prev);
87912 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87913 mpol_equal(policy, vma_policy(next)) &&
87914 can_vma_merge_before(next, vm_flags,
87915 anon_vma, file, pgoff+pglen)) {
87916 - if (prev && addr < prev->vm_end) /* case 4 */
87917 + if (prev && addr < prev->vm_end) { /* case 4 */
87918 err = vma_adjust(prev, prev->vm_start,
87919 addr, prev->vm_pgoff, NULL);
87920 - else /* cases 3, 8 */
87921 +
87922 +#ifdef CONFIG_PAX_SEGMEXEC
87923 + if (!err && prev_m)
87924 + err = vma_adjust(prev_m, prev_m->vm_start,
87925 + addr_m, prev_m->vm_pgoff, NULL);
87926 +#endif
87927 +
87928 + } else { /* cases 3, 8 */
87929 err = vma_adjust(area, addr, next->vm_end,
87930 next->vm_pgoff - pglen, NULL);
87931 +
87932 +#ifdef CONFIG_PAX_SEGMEXEC
87933 + if (!err && area_m)
87934 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87935 + next_m->vm_pgoff - pglen, NULL);
87936 +#endif
87937 +
87938 + }
87939 if (err)
87940 return NULL;
87941 khugepaged_enter_vma_merge(area);
87942 @@ -1165,8 +1246,10 @@ none:
87943 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87944 struct file *file, long pages)
87945 {
87946 - const unsigned long stack_flags
87947 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87948 +
87949 +#ifdef CONFIG_PAX_RANDMMAP
87950 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87951 +#endif
87952
87953 mm->total_vm += pages;
87954
87955 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87956 mm->shared_vm += pages;
87957 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87958 mm->exec_vm += pages;
87959 - } else if (flags & stack_flags)
87960 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87961 mm->stack_vm += pages;
87962 }
87963 #endif /* CONFIG_PROC_FS */
87964 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87965 * (the exception is when the underlying filesystem is noexec
87966 * mounted, in which case we dont add PROT_EXEC.)
87967 */
87968 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87969 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87970 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87971 prot |= PROT_EXEC;
87972
87973 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87974 /* Obtain the address to map to. we verify (or select) it and ensure
87975 * that it represents a valid section of the address space.
87976 */
87977 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87978 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87979 if (addr & ~PAGE_MASK)
87980 return addr;
87981
87982 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87983 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87984 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87985
87986 +#ifdef CONFIG_PAX_MPROTECT
87987 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87988 +
87989 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87990 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87991 + mm->binfmt->handle_mmap)
87992 + mm->binfmt->handle_mmap(file);
87993 +#endif
87994 +
87995 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87996 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87997 + gr_log_rwxmmap(file);
87998 +
87999 +#ifdef CONFIG_PAX_EMUPLT
88000 + vm_flags &= ~VM_EXEC;
88001 +#else
88002 + return -EPERM;
88003 +#endif
88004 +
88005 + }
88006 +
88007 + if (!(vm_flags & VM_EXEC))
88008 + vm_flags &= ~VM_MAYEXEC;
88009 +#else
88010 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88011 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88012 +#endif
88013 + else
88014 + vm_flags &= ~VM_MAYWRITE;
88015 + }
88016 +#endif
88017 +
88018 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88019 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
88020 + vm_flags &= ~VM_PAGEEXEC;
88021 +#endif
88022 +
88023 if (flags & MAP_LOCKED)
88024 if (!can_do_mlock())
88025 return -EPERM;
88026 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88027 locked += mm->locked_vm;
88028 lock_limit = rlimit(RLIMIT_MEMLOCK);
88029 lock_limit >>= PAGE_SHIFT;
88030 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88031 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
88032 return -EAGAIN;
88033 }
88034 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88035 vm_flags |= VM_NORESERVE;
88036 }
88037
88038 + if (!gr_acl_handle_mmap(file, prot))
88039 + return -EACCES;
88040 +
88041 addr = mmap_region(file, addr, len, vm_flags, pgoff);
88042 if (!IS_ERR_VALUE(addr) &&
88043 ((vm_flags & VM_LOCKED) ||
88044 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
88045 vm_flags_t vm_flags = vma->vm_flags;
88046
88047 /* If it was private or non-writable, the write bit is already clear */
88048 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
88049 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
88050 return 0;
88051
88052 /* The backer wishes to know when pages are first written to? */
88053 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88054 unsigned long charged = 0;
88055 struct inode *inode = file ? file_inode(file) : NULL;
88056
88057 +#ifdef CONFIG_PAX_SEGMEXEC
88058 + struct vm_area_struct *vma_m = NULL;
88059 +#endif
88060 +
88061 + /*
88062 + * mm->mmap_sem is required to protect against another thread
88063 + * changing the mappings in case we sleep.
88064 + */
88065 + verify_mm_writelocked(mm);
88066 +
88067 /* Check against address space limit. */
88068 +
88069 +#ifdef CONFIG_PAX_RANDMMAP
88070 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88071 +#endif
88072 +
88073 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
88074 unsigned long nr_pages;
88075
88076 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88077
88078 /* Clear old maps */
88079 error = -ENOMEM;
88080 -munmap_back:
88081 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88082 if (do_munmap(mm, addr, len))
88083 return -ENOMEM;
88084 - goto munmap_back;
88085 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88086 }
88087
88088 /*
88089 @@ -1536,6 +1674,16 @@ munmap_back:
88090 goto unacct_error;
88091 }
88092
88093 +#ifdef CONFIG_PAX_SEGMEXEC
88094 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
88095 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88096 + if (!vma_m) {
88097 + error = -ENOMEM;
88098 + goto free_vma;
88099 + }
88100 + }
88101 +#endif
88102 +
88103 vma->vm_mm = mm;
88104 vma->vm_start = addr;
88105 vma->vm_end = addr + len;
88106 @@ -1560,6 +1708,13 @@ munmap_back:
88107 if (error)
88108 goto unmap_and_free_vma;
88109
88110 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88111 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
88112 + vma->vm_flags |= VM_PAGEEXEC;
88113 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88114 + }
88115 +#endif
88116 +
88117 /* Can addr have changed??
88118 *
88119 * Answer: Yes, several device drivers can do it in their
88120 @@ -1598,6 +1753,11 @@ munmap_back:
88121 vma_link(mm, vma, prev, rb_link, rb_parent);
88122 file = vma->vm_file;
88123
88124 +#ifdef CONFIG_PAX_SEGMEXEC
88125 + if (vma_m)
88126 + BUG_ON(pax_mirror_vma(vma_m, vma));
88127 +#endif
88128 +
88129 /* Once vma denies write, undo our temporary denial count */
88130 if (correct_wcount)
88131 atomic_inc(&inode->i_writecount);
88132 @@ -1605,6 +1765,7 @@ out:
88133 perf_event_mmap(vma);
88134
88135 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
88136 + track_exec_limit(mm, addr, addr + len, vm_flags);
88137 if (vm_flags & VM_LOCKED) {
88138 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
88139 vma == get_gate_vma(current->mm)))
88140 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
88141 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
88142 charged = 0;
88143 free_vma:
88144 +
88145 +#ifdef CONFIG_PAX_SEGMEXEC
88146 + if (vma_m)
88147 + kmem_cache_free(vm_area_cachep, vma_m);
88148 +#endif
88149 +
88150 kmem_cache_free(vm_area_cachep, vma);
88151 unacct_error:
88152 if (charged)
88153 @@ -1635,7 +1802,63 @@ unacct_error:
88154 return error;
88155 }
88156
88157 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88158 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
88159 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
88160 +{
88161 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
88162 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
88163 +
88164 + return 0;
88165 +}
88166 +#endif
88167 +
88168 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
88169 +{
88170 + if (!vma) {
88171 +#ifdef CONFIG_STACK_GROWSUP
88172 + if (addr > sysctl_heap_stack_gap)
88173 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
88174 + else
88175 + vma = find_vma(current->mm, 0);
88176 + if (vma && (vma->vm_flags & VM_GROWSUP))
88177 + return false;
88178 +#endif
88179 + return true;
88180 + }
88181 +
88182 + if (addr + len > vma->vm_start)
88183 + return false;
88184 +
88185 + if (vma->vm_flags & VM_GROWSDOWN)
88186 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
88187 +#ifdef CONFIG_STACK_GROWSUP
88188 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
88189 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
88190 +#endif
88191 + else if (offset)
88192 + return offset <= vma->vm_start - addr - len;
88193 +
88194 + return true;
88195 +}
88196 +
88197 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
88198 +{
88199 + if (vma->vm_start < len)
88200 + return -ENOMEM;
88201 +
88202 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
88203 + if (offset <= vma->vm_start - len)
88204 + return vma->vm_start - len - offset;
88205 + else
88206 + return -ENOMEM;
88207 + }
88208 +
88209 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
88210 + return vma->vm_start - len - sysctl_heap_stack_gap;
88211 + return -ENOMEM;
88212 +}
88213 +
88214 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
88215 {
88216 /*
88217 * We implement the search by looking for an rbtree node that
88218 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88219 }
88220 }
88221
88222 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
88223 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
88224 check_current:
88225 /* Check if current node has a suitable gap */
88226 if (gap_start > high_limit)
88227 return -ENOMEM;
88228 +
88229 + if (gap_end - gap_start > info->threadstack_offset)
88230 + gap_start += info->threadstack_offset;
88231 + else
88232 + gap_start = gap_end;
88233 +
88234 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88235 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88236 + gap_start += sysctl_heap_stack_gap;
88237 + else
88238 + gap_start = gap_end;
88239 + }
88240 + if (vma->vm_flags & VM_GROWSDOWN) {
88241 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88242 + gap_end -= sysctl_heap_stack_gap;
88243 + else
88244 + gap_end = gap_start;
88245 + }
88246 if (gap_end >= low_limit && gap_end - gap_start >= length)
88247 goto found;
88248
88249 @@ -1737,7 +1978,7 @@ found:
88250 return gap_start;
88251 }
88252
88253 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
88254 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
88255 {
88256 struct mm_struct *mm = current->mm;
88257 struct vm_area_struct *vma;
88258 @@ -1791,6 +2032,24 @@ check_current:
88259 gap_end = vma->vm_start;
88260 if (gap_end < low_limit)
88261 return -ENOMEM;
88262 +
88263 + if (gap_end - gap_start > info->threadstack_offset)
88264 + gap_end -= info->threadstack_offset;
88265 + else
88266 + gap_end = gap_start;
88267 +
88268 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88269 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88270 + gap_start += sysctl_heap_stack_gap;
88271 + else
88272 + gap_start = gap_end;
88273 + }
88274 + if (vma->vm_flags & VM_GROWSDOWN) {
88275 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88276 + gap_end -= sysctl_heap_stack_gap;
88277 + else
88278 + gap_end = gap_start;
88279 + }
88280 if (gap_start <= high_limit && gap_end - gap_start >= length)
88281 goto found;
88282
88283 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88284 struct mm_struct *mm = current->mm;
88285 struct vm_area_struct *vma;
88286 struct vm_unmapped_area_info info;
88287 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88288
88289 if (len > TASK_SIZE)
88290 return -ENOMEM;
88291 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88292 if (flags & MAP_FIXED)
88293 return addr;
88294
88295 +#ifdef CONFIG_PAX_RANDMMAP
88296 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88297 +#endif
88298 +
88299 if (addr) {
88300 addr = PAGE_ALIGN(addr);
88301 vma = find_vma(mm, addr);
88302 - if (TASK_SIZE - len >= addr &&
88303 - (!vma || addr + len <= vma->vm_start))
88304 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88305 return addr;
88306 }
88307
88308 info.flags = 0;
88309 info.length = len;
88310 info.low_limit = TASK_UNMAPPED_BASE;
88311 +
88312 +#ifdef CONFIG_PAX_RANDMMAP
88313 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88314 + info.low_limit += mm->delta_mmap;
88315 +#endif
88316 +
88317 info.high_limit = TASK_SIZE;
88318 info.align_mask = 0;
88319 + info.threadstack_offset = offset;
88320 return vm_unmapped_area(&info);
88321 }
88322 #endif
88323 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88324 struct mm_struct *mm = current->mm;
88325 unsigned long addr = addr0;
88326 struct vm_unmapped_area_info info;
88327 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88328
88329 /* requested length too big for entire address space */
88330 if (len > TASK_SIZE)
88331 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88332 if (flags & MAP_FIXED)
88333 return addr;
88334
88335 +#ifdef CONFIG_PAX_RANDMMAP
88336 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88337 +#endif
88338 +
88339 /* requesting a specific address */
88340 if (addr) {
88341 addr = PAGE_ALIGN(addr);
88342 vma = find_vma(mm, addr);
88343 - if (TASK_SIZE - len >= addr &&
88344 - (!vma || addr + len <= vma->vm_start))
88345 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88346 return addr;
88347 }
88348
88349 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88350 info.low_limit = PAGE_SIZE;
88351 info.high_limit = mm->mmap_base;
88352 info.align_mask = 0;
88353 + info.threadstack_offset = offset;
88354 addr = vm_unmapped_area(&info);
88355
88356 /*
88357 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88358 VM_BUG_ON(addr != -ENOMEM);
88359 info.flags = 0;
88360 info.low_limit = TASK_UNMAPPED_BASE;
88361 +
88362 +#ifdef CONFIG_PAX_RANDMMAP
88363 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88364 + info.low_limit += mm->delta_mmap;
88365 +#endif
88366 +
88367 info.high_limit = TASK_SIZE;
88368 addr = vm_unmapped_area(&info);
88369 }
88370 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
88371 return vma;
88372 }
88373
88374 +#ifdef CONFIG_PAX_SEGMEXEC
88375 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
88376 +{
88377 + struct vm_area_struct *vma_m;
88378 +
88379 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
88380 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
88381 + BUG_ON(vma->vm_mirror);
88382 + return NULL;
88383 + }
88384 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
88385 + vma_m = vma->vm_mirror;
88386 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
88387 + BUG_ON(vma->vm_file != vma_m->vm_file);
88388 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
88389 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
88390 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
88391 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
88392 + return vma_m;
88393 +}
88394 +#endif
88395 +
88396 /*
88397 * Verify that the stack growth is acceptable and
88398 * update accounting. This is shared with both the
88399 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88400 return -ENOMEM;
88401
88402 /* Stack limit test */
88403 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
88404 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
88405 return -ENOMEM;
88406
88407 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88408 locked = mm->locked_vm + grow;
88409 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88410 limit >>= PAGE_SHIFT;
88411 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88412 if (locked > limit && !capable(CAP_IPC_LOCK))
88413 return -ENOMEM;
88414 }
88415 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88416 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88417 * vma is the last one with address > vma->vm_end. Have to extend vma.
88418 */
88419 +#ifndef CONFIG_IA64
88420 +static
88421 +#endif
88422 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88423 {
88424 int error;
88425 + bool locknext;
88426
88427 if (!(vma->vm_flags & VM_GROWSUP))
88428 return -EFAULT;
88429
88430 + /* Also guard against wrapping around to address 0. */
88431 + if (address < PAGE_ALIGN(address+1))
88432 + address = PAGE_ALIGN(address+1);
88433 + else
88434 + return -ENOMEM;
88435 +
88436 /*
88437 * We must make sure the anon_vma is allocated
88438 * so that the anon_vma locking is not a noop.
88439 */
88440 if (unlikely(anon_vma_prepare(vma)))
88441 return -ENOMEM;
88442 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
88443 + if (locknext && anon_vma_prepare(vma->vm_next))
88444 + return -ENOMEM;
88445 vma_lock_anon_vma(vma);
88446 + if (locknext)
88447 + vma_lock_anon_vma(vma->vm_next);
88448
88449 /*
88450 * vma->vm_start/vm_end cannot change under us because the caller
88451 * is required to hold the mmap_sem in read mode. We need the
88452 - * anon_vma lock to serialize against concurrent expand_stacks.
88453 - * Also guard against wrapping around to address 0.
88454 + * anon_vma locks to serialize against concurrent expand_stacks
88455 + * and expand_upwards.
88456 */
88457 - if (address < PAGE_ALIGN(address+4))
88458 - address = PAGE_ALIGN(address+4);
88459 - else {
88460 - vma_unlock_anon_vma(vma);
88461 - return -ENOMEM;
88462 - }
88463 error = 0;
88464
88465 /* Somebody else might have raced and expanded it already */
88466 - if (address > vma->vm_end) {
88467 + 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)
88468 + error = -ENOMEM;
88469 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
88470 unsigned long size, grow;
88471
88472 size = address - vma->vm_start;
88473 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88474 }
88475 }
88476 }
88477 + if (locknext)
88478 + vma_unlock_anon_vma(vma->vm_next);
88479 vma_unlock_anon_vma(vma);
88480 khugepaged_enter_vma_merge(vma);
88481 validate_mm(vma->vm_mm);
88482 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
88483 unsigned long address)
88484 {
88485 int error;
88486 + bool lockprev = false;
88487 + struct vm_area_struct *prev;
88488
88489 /*
88490 * We must make sure the anon_vma is allocated
88491 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
88492 if (error)
88493 return error;
88494
88495 + prev = vma->vm_prev;
88496 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
88497 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
88498 +#endif
88499 + if (lockprev && anon_vma_prepare(prev))
88500 + return -ENOMEM;
88501 + if (lockprev)
88502 + vma_lock_anon_vma(prev);
88503 +
88504 vma_lock_anon_vma(vma);
88505
88506 /*
88507 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
88508 */
88509
88510 /* Somebody else might have raced and expanded it already */
88511 - if (address < vma->vm_start) {
88512 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
88513 + error = -ENOMEM;
88514 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
88515 unsigned long size, grow;
88516
88517 +#ifdef CONFIG_PAX_SEGMEXEC
88518 + struct vm_area_struct *vma_m;
88519 +
88520 + vma_m = pax_find_mirror_vma(vma);
88521 +#endif
88522 +
88523 size = vma->vm_end - address;
88524 grow = (vma->vm_start - address) >> PAGE_SHIFT;
88525
88526 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
88527 vma->vm_pgoff -= grow;
88528 anon_vma_interval_tree_post_update_vma(vma);
88529 vma_gap_update(vma);
88530 +
88531 +#ifdef CONFIG_PAX_SEGMEXEC
88532 + if (vma_m) {
88533 + anon_vma_interval_tree_pre_update_vma(vma_m);
88534 + vma_m->vm_start -= grow << PAGE_SHIFT;
88535 + vma_m->vm_pgoff -= grow;
88536 + anon_vma_interval_tree_post_update_vma(vma_m);
88537 + vma_gap_update(vma_m);
88538 + }
88539 +#endif
88540 +
88541 spin_unlock(&vma->vm_mm->page_table_lock);
88542
88543 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88544 perf_event_mmap(vma);
88545 }
88546 }
88547 }
88548 vma_unlock_anon_vma(vma);
88549 + if (lockprev)
88550 + vma_unlock_anon_vma(prev);
88551 khugepaged_enter_vma_merge(vma);
88552 validate_mm(vma->vm_mm);
88553 return error;
88554 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88555 do {
88556 long nrpages = vma_pages(vma);
88557
88558 +#ifdef CONFIG_PAX_SEGMEXEC
88559 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88560 + vma = remove_vma(vma);
88561 + continue;
88562 + }
88563 +#endif
88564 +
88565 if (vma->vm_flags & VM_ACCOUNT)
88566 nr_accounted += nrpages;
88567 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88568 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88569 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88570 vma->vm_prev = NULL;
88571 do {
88572 +
88573 +#ifdef CONFIG_PAX_SEGMEXEC
88574 + if (vma->vm_mirror) {
88575 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88576 + vma->vm_mirror->vm_mirror = NULL;
88577 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88578 + vma->vm_mirror = NULL;
88579 + }
88580 +#endif
88581 +
88582 vma_rb_erase(vma, &mm->mm_rb);
88583 mm->map_count--;
88584 tail_vma = vma;
88585 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88586 struct vm_area_struct *new;
88587 int err = -ENOMEM;
88588
88589 +#ifdef CONFIG_PAX_SEGMEXEC
88590 + struct vm_area_struct *vma_m, *new_m = NULL;
88591 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88592 +#endif
88593 +
88594 if (is_vm_hugetlb_page(vma) && (addr &
88595 ~(huge_page_mask(hstate_vma(vma)))))
88596 return -EINVAL;
88597
88598 +#ifdef CONFIG_PAX_SEGMEXEC
88599 + vma_m = pax_find_mirror_vma(vma);
88600 +#endif
88601 +
88602 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88603 if (!new)
88604 goto out_err;
88605
88606 +#ifdef CONFIG_PAX_SEGMEXEC
88607 + if (vma_m) {
88608 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88609 + if (!new_m) {
88610 + kmem_cache_free(vm_area_cachep, new);
88611 + goto out_err;
88612 + }
88613 + }
88614 +#endif
88615 +
88616 /* most fields are the same, copy all, and then fixup */
88617 *new = *vma;
88618
88619 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88620 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88621 }
88622
88623 +#ifdef CONFIG_PAX_SEGMEXEC
88624 + if (vma_m) {
88625 + *new_m = *vma_m;
88626 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88627 + new_m->vm_mirror = new;
88628 + new->vm_mirror = new_m;
88629 +
88630 + if (new_below)
88631 + new_m->vm_end = addr_m;
88632 + else {
88633 + new_m->vm_start = addr_m;
88634 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88635 + }
88636 + }
88637 +#endif
88638 +
88639 pol = mpol_dup(vma_policy(vma));
88640 if (IS_ERR(pol)) {
88641 err = PTR_ERR(pol);
88642 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88643 else
88644 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88645
88646 +#ifdef CONFIG_PAX_SEGMEXEC
88647 + if (!err && vma_m) {
88648 + if (anon_vma_clone(new_m, vma_m))
88649 + goto out_free_mpol;
88650 +
88651 + mpol_get(pol);
88652 + vma_set_policy(new_m, pol);
88653 +
88654 + if (new_m->vm_file)
88655 + get_file(new_m->vm_file);
88656 +
88657 + if (new_m->vm_ops && new_m->vm_ops->open)
88658 + new_m->vm_ops->open(new_m);
88659 +
88660 + if (new_below)
88661 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88662 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88663 + else
88664 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88665 +
88666 + if (err) {
88667 + if (new_m->vm_ops && new_m->vm_ops->close)
88668 + new_m->vm_ops->close(new_m);
88669 + if (new_m->vm_file)
88670 + fput(new_m->vm_file);
88671 + mpol_put(pol);
88672 + }
88673 + }
88674 +#endif
88675 +
88676 /* Success. */
88677 if (!err)
88678 return 0;
88679 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88680 new->vm_ops->close(new);
88681 if (new->vm_file)
88682 fput(new->vm_file);
88683 - unlink_anon_vmas(new);
88684 out_free_mpol:
88685 mpol_put(pol);
88686 out_free_vma:
88687 +
88688 +#ifdef CONFIG_PAX_SEGMEXEC
88689 + if (new_m) {
88690 + unlink_anon_vmas(new_m);
88691 + kmem_cache_free(vm_area_cachep, new_m);
88692 + }
88693 +#endif
88694 +
88695 + unlink_anon_vmas(new);
88696 kmem_cache_free(vm_area_cachep, new);
88697 out_err:
88698 return err;
88699 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88700 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88701 unsigned long addr, int new_below)
88702 {
88703 +
88704 +#ifdef CONFIG_PAX_SEGMEXEC
88705 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88706 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88707 + if (mm->map_count >= sysctl_max_map_count-1)
88708 + return -ENOMEM;
88709 + } else
88710 +#endif
88711 +
88712 if (mm->map_count >= sysctl_max_map_count)
88713 return -ENOMEM;
88714
88715 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88716 * work. This now handles partial unmappings.
88717 * Jeremy Fitzhardinge <jeremy@goop.org>
88718 */
88719 +#ifdef CONFIG_PAX_SEGMEXEC
88720 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88721 {
88722 + int ret = __do_munmap(mm, start, len);
88723 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88724 + return ret;
88725 +
88726 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88727 +}
88728 +
88729 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88730 +#else
88731 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88732 +#endif
88733 +{
88734 unsigned long end;
88735 struct vm_area_struct *vma, *prev, *last;
88736
88737 + /*
88738 + * mm->mmap_sem is required to protect against another thread
88739 + * changing the mappings in case we sleep.
88740 + */
88741 + verify_mm_writelocked(mm);
88742 +
88743 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88744 return -EINVAL;
88745
88746 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88747 /* Fix up all other VM information */
88748 remove_vma_list(mm, vma);
88749
88750 + track_exec_limit(mm, start, end, 0UL);
88751 +
88752 return 0;
88753 }
88754
88755 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88756 int ret;
88757 struct mm_struct *mm = current->mm;
88758
88759 +
88760 +#ifdef CONFIG_PAX_SEGMEXEC
88761 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88762 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88763 + return -EINVAL;
88764 +#endif
88765 +
88766 down_write(&mm->mmap_sem);
88767 ret = do_munmap(mm, start, len);
88768 up_write(&mm->mmap_sem);
88769 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88770 return vm_munmap(addr, len);
88771 }
88772
88773 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88774 -{
88775 -#ifdef CONFIG_DEBUG_VM
88776 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88777 - WARN_ON(1);
88778 - up_read(&mm->mmap_sem);
88779 - }
88780 -#endif
88781 -}
88782 -
88783 /*
88784 * this is really a simplified "do_mmap". it only handles
88785 * anonymous maps. eventually we may be able to do some
88786 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88787 struct rb_node ** rb_link, * rb_parent;
88788 pgoff_t pgoff = addr >> PAGE_SHIFT;
88789 int error;
88790 + unsigned long charged;
88791
88792 len = PAGE_ALIGN(len);
88793 if (!len)
88794 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88795
88796 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88797
88798 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88799 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88800 + flags &= ~VM_EXEC;
88801 +
88802 +#ifdef CONFIG_PAX_MPROTECT
88803 + if (mm->pax_flags & MF_PAX_MPROTECT)
88804 + flags &= ~VM_MAYEXEC;
88805 +#endif
88806 +
88807 + }
88808 +#endif
88809 +
88810 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88811 if (error & ~PAGE_MASK)
88812 return error;
88813
88814 + charged = len >> PAGE_SHIFT;
88815 +
88816 /*
88817 * mlock MCL_FUTURE?
88818 */
88819 if (mm->def_flags & VM_LOCKED) {
88820 unsigned long locked, lock_limit;
88821 - locked = len >> PAGE_SHIFT;
88822 + locked = charged;
88823 locked += mm->locked_vm;
88824 lock_limit = rlimit(RLIMIT_MEMLOCK);
88825 lock_limit >>= PAGE_SHIFT;
88826 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88827 /*
88828 * Clear old maps. this also does some error checking for us
88829 */
88830 - munmap_back:
88831 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88832 if (do_munmap(mm, addr, len))
88833 return -ENOMEM;
88834 - goto munmap_back;
88835 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88836 }
88837
88838 /* Check against address space limits *after* clearing old maps... */
88839 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88840 + if (!may_expand_vm(mm, charged))
88841 return -ENOMEM;
88842
88843 if (mm->map_count > sysctl_max_map_count)
88844 return -ENOMEM;
88845
88846 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88847 + if (security_vm_enough_memory_mm(mm, charged))
88848 return -ENOMEM;
88849
88850 /* Can we just expand an old private anonymous mapping? */
88851 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88852 */
88853 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88854 if (!vma) {
88855 - vm_unacct_memory(len >> PAGE_SHIFT);
88856 + vm_unacct_memory(charged);
88857 return -ENOMEM;
88858 }
88859
88860 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88861 vma_link(mm, vma, prev, rb_link, rb_parent);
88862 out:
88863 perf_event_mmap(vma);
88864 - mm->total_vm += len >> PAGE_SHIFT;
88865 + mm->total_vm += charged;
88866 if (flags & VM_LOCKED)
88867 - mm->locked_vm += (len >> PAGE_SHIFT);
88868 + mm->locked_vm += charged;
88869 + track_exec_limit(mm, addr, addr + len, flags);
88870 return addr;
88871 }
88872
88873 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88874 while (vma) {
88875 if (vma->vm_flags & VM_ACCOUNT)
88876 nr_accounted += vma_pages(vma);
88877 + vma->vm_mirror = NULL;
88878 vma = remove_vma(vma);
88879 }
88880 vm_unacct_memory(nr_accounted);
88881 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88882 struct vm_area_struct *prev;
88883 struct rb_node **rb_link, *rb_parent;
88884
88885 +#ifdef CONFIG_PAX_SEGMEXEC
88886 + struct vm_area_struct *vma_m = NULL;
88887 +#endif
88888 +
88889 + if (security_mmap_addr(vma->vm_start))
88890 + return -EPERM;
88891 +
88892 /*
88893 * The vm_pgoff of a purely anonymous vma should be irrelevant
88894 * until its first write fault, when page's anon_vma and index
88895 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88896 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88897 return -ENOMEM;
88898
88899 +#ifdef CONFIG_PAX_SEGMEXEC
88900 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88901 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88902 + if (!vma_m)
88903 + return -ENOMEM;
88904 + }
88905 +#endif
88906 +
88907 vma_link(mm, vma, prev, rb_link, rb_parent);
88908 +
88909 +#ifdef CONFIG_PAX_SEGMEXEC
88910 + if (vma_m)
88911 + BUG_ON(pax_mirror_vma(vma_m, vma));
88912 +#endif
88913 +
88914 return 0;
88915 }
88916
88917 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88918 struct mempolicy *pol;
88919 bool faulted_in_anon_vma = true;
88920
88921 + BUG_ON(vma->vm_mirror);
88922 +
88923 /*
88924 * If anonymous vma has not yet been faulted, update new pgoff
88925 * to match new location, to increase its chance of merging.
88926 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88927 return NULL;
88928 }
88929
88930 +#ifdef CONFIG_PAX_SEGMEXEC
88931 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88932 +{
88933 + struct vm_area_struct *prev_m;
88934 + struct rb_node **rb_link_m, *rb_parent_m;
88935 + struct mempolicy *pol_m;
88936 +
88937 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88938 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88939 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88940 + *vma_m = *vma;
88941 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88942 + if (anon_vma_clone(vma_m, vma))
88943 + return -ENOMEM;
88944 + pol_m = vma_policy(vma_m);
88945 + mpol_get(pol_m);
88946 + vma_set_policy(vma_m, pol_m);
88947 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88948 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88949 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88950 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88951 + if (vma_m->vm_file)
88952 + get_file(vma_m->vm_file);
88953 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88954 + vma_m->vm_ops->open(vma_m);
88955 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88956 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88957 + vma_m->vm_mirror = vma;
88958 + vma->vm_mirror = vma_m;
88959 + return 0;
88960 +}
88961 +#endif
88962 +
88963 /*
88964 * Return true if the calling process may expand its vm space by the passed
88965 * number of pages
88966 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88967
88968 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88969
88970 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88971 if (cur + npages > lim)
88972 return 0;
88973 return 1;
88974 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88975 vma->vm_start = addr;
88976 vma->vm_end = addr + len;
88977
88978 +#ifdef CONFIG_PAX_MPROTECT
88979 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88980 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88981 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88982 + return -EPERM;
88983 + if (!(vm_flags & VM_EXEC))
88984 + vm_flags &= ~VM_MAYEXEC;
88985 +#else
88986 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88987 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88988 +#endif
88989 + else
88990 + vm_flags &= ~VM_MAYWRITE;
88991 + }
88992 +#endif
88993 +
88994 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88995 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88996
88997 diff --git a/mm/mprotect.c b/mm/mprotect.c
88998 index 412ba2b..cb41d42 100644
88999 --- a/mm/mprotect.c
89000 +++ b/mm/mprotect.c
89001 @@ -23,10 +23,18 @@
89002 #include <linux/mmu_notifier.h>
89003 #include <linux/migrate.h>
89004 #include <linux/perf_event.h>
89005 +#include <linux/sched/sysctl.h>
89006 +
89007 +#ifdef CONFIG_PAX_MPROTECT
89008 +#include <linux/elf.h>
89009 +#include <linux/binfmts.h>
89010 +#endif
89011 +
89012 #include <asm/uaccess.h>
89013 #include <asm/pgtable.h>
89014 #include <asm/cacheflush.h>
89015 #include <asm/tlbflush.h>
89016 +#include <asm/mmu_context.h>
89017
89018 #ifndef pgprot_modify
89019 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
89020 @@ -236,6 +244,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
89021 return pages;
89022 }
89023
89024 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89025 +/* called while holding the mmap semaphor for writing except stack expansion */
89026 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
89027 +{
89028 + unsigned long oldlimit, newlimit = 0UL;
89029 +
89030 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
89031 + return;
89032 +
89033 + spin_lock(&mm->page_table_lock);
89034 + oldlimit = mm->context.user_cs_limit;
89035 + if ((prot & VM_EXEC) && oldlimit < end)
89036 + /* USER_CS limit moved up */
89037 + newlimit = end;
89038 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
89039 + /* USER_CS limit moved down */
89040 + newlimit = start;
89041 +
89042 + if (newlimit) {
89043 + mm->context.user_cs_limit = newlimit;
89044 +
89045 +#ifdef CONFIG_SMP
89046 + wmb();
89047 + cpus_clear(mm->context.cpu_user_cs_mask);
89048 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
89049 +#endif
89050 +
89051 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
89052 + }
89053 + spin_unlock(&mm->page_table_lock);
89054 + if (newlimit == end) {
89055 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
89056 +
89057 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
89058 + if (is_vm_hugetlb_page(vma))
89059 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
89060 + else
89061 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
89062 + }
89063 +}
89064 +#endif
89065 +
89066 int
89067 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89068 unsigned long start, unsigned long end, unsigned long newflags)
89069 @@ -248,11 +298,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89070 int error;
89071 int dirty_accountable = 0;
89072
89073 +#ifdef CONFIG_PAX_SEGMEXEC
89074 + struct vm_area_struct *vma_m = NULL;
89075 + unsigned long start_m, end_m;
89076 +
89077 + start_m = start + SEGMEXEC_TASK_SIZE;
89078 + end_m = end + SEGMEXEC_TASK_SIZE;
89079 +#endif
89080 +
89081 if (newflags == oldflags) {
89082 *pprev = vma;
89083 return 0;
89084 }
89085
89086 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
89087 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
89088 +
89089 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
89090 + return -ENOMEM;
89091 +
89092 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
89093 + return -ENOMEM;
89094 + }
89095 +
89096 /*
89097 * If we make a private mapping writable we increase our commit;
89098 * but (without finer accounting) cannot reduce our commit if we
89099 @@ -269,6 +337,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89100 }
89101 }
89102
89103 +#ifdef CONFIG_PAX_SEGMEXEC
89104 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
89105 + if (start != vma->vm_start) {
89106 + error = split_vma(mm, vma, start, 1);
89107 + if (error)
89108 + goto fail;
89109 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
89110 + *pprev = (*pprev)->vm_next;
89111 + }
89112 +
89113 + if (end != vma->vm_end) {
89114 + error = split_vma(mm, vma, end, 0);
89115 + if (error)
89116 + goto fail;
89117 + }
89118 +
89119 + if (pax_find_mirror_vma(vma)) {
89120 + error = __do_munmap(mm, start_m, end_m - start_m);
89121 + if (error)
89122 + goto fail;
89123 + } else {
89124 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89125 + if (!vma_m) {
89126 + error = -ENOMEM;
89127 + goto fail;
89128 + }
89129 + vma->vm_flags = newflags;
89130 + error = pax_mirror_vma(vma_m, vma);
89131 + if (error) {
89132 + vma->vm_flags = oldflags;
89133 + goto fail;
89134 + }
89135 + }
89136 + }
89137 +#endif
89138 +
89139 /*
89140 * First try to merge with previous and/or next vma.
89141 */
89142 @@ -299,9 +403,21 @@ success:
89143 * vm_flags and vm_page_prot are protected by the mmap_sem
89144 * held in write mode.
89145 */
89146 +
89147 +#ifdef CONFIG_PAX_SEGMEXEC
89148 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
89149 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
89150 +#endif
89151 +
89152 vma->vm_flags = newflags;
89153 +
89154 +#ifdef CONFIG_PAX_MPROTECT
89155 + if (mm->binfmt && mm->binfmt->handle_mprotect)
89156 + mm->binfmt->handle_mprotect(vma, newflags);
89157 +#endif
89158 +
89159 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
89160 - vm_get_page_prot(newflags));
89161 + vm_get_page_prot(vma->vm_flags));
89162
89163 if (vma_wants_writenotify(vma)) {
89164 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
89165 @@ -340,6 +456,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89166 end = start + len;
89167 if (end <= start)
89168 return -ENOMEM;
89169 +
89170 +#ifdef CONFIG_PAX_SEGMEXEC
89171 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
89172 + if (end > SEGMEXEC_TASK_SIZE)
89173 + return -EINVAL;
89174 + } else
89175 +#endif
89176 +
89177 + if (end > TASK_SIZE)
89178 + return -EINVAL;
89179 +
89180 if (!arch_validate_prot(prot))
89181 return -EINVAL;
89182
89183 @@ -347,7 +474,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89184 /*
89185 * Does the application expect PROT_READ to imply PROT_EXEC:
89186 */
89187 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89188 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89189 prot |= PROT_EXEC;
89190
89191 vm_flags = calc_vm_prot_bits(prot);
89192 @@ -379,6 +506,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89193 if (start > vma->vm_start)
89194 prev = vma;
89195
89196 +#ifdef CONFIG_PAX_MPROTECT
89197 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
89198 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
89199 +#endif
89200 +
89201 for (nstart = start ; ; ) {
89202 unsigned long newflags;
89203
89204 @@ -389,6 +521,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89205
89206 /* newflags >> 4 shift VM_MAY% in place of VM_% */
89207 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
89208 + if (prot & (PROT_WRITE | PROT_EXEC))
89209 + gr_log_rwxmprotect(vma);
89210 +
89211 + error = -EACCES;
89212 + goto out;
89213 + }
89214 +
89215 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
89216 error = -EACCES;
89217 goto out;
89218 }
89219 @@ -403,6 +543,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89220 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
89221 if (error)
89222 goto out;
89223 +
89224 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
89225 +
89226 nstart = tmp;
89227
89228 if (nstart < prev->vm_end)
89229 diff --git a/mm/mremap.c b/mm/mremap.c
89230 index 0843feb..4f5b2e6 100644
89231 --- a/mm/mremap.c
89232 +++ b/mm/mremap.c
89233 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
89234 continue;
89235 pte = ptep_get_and_clear(mm, old_addr, old_pte);
89236 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
89237 +
89238 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89239 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
89240 + pte = pte_exprotect(pte);
89241 +#endif
89242 +
89243 pte = move_soft_dirty_pte(pte);
89244 set_pte_at(mm, new_addr, new_pte, pte);
89245 }
89246 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
89247 if (is_vm_hugetlb_page(vma))
89248 goto Einval;
89249
89250 +#ifdef CONFIG_PAX_SEGMEXEC
89251 + if (pax_find_mirror_vma(vma))
89252 + goto Einval;
89253 +#endif
89254 +
89255 /* We can't remap across vm area boundaries */
89256 if (old_len > vma->vm_end - addr)
89257 goto Efault;
89258 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
89259 unsigned long ret = -EINVAL;
89260 unsigned long charged = 0;
89261 unsigned long map_flags;
89262 + unsigned long pax_task_size = TASK_SIZE;
89263
89264 if (new_addr & ~PAGE_MASK)
89265 goto out;
89266
89267 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
89268 +#ifdef CONFIG_PAX_SEGMEXEC
89269 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89270 + pax_task_size = SEGMEXEC_TASK_SIZE;
89271 +#endif
89272 +
89273 + pax_task_size -= PAGE_SIZE;
89274 +
89275 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
89276 goto out;
89277
89278 /* Check if the location we're moving into overlaps the
89279 * old location at all, and fail if it does.
89280 */
89281 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
89282 - goto out;
89283 -
89284 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
89285 + if (addr + old_len > new_addr && new_addr + new_len > addr)
89286 goto out;
89287
89288 ret = do_munmap(mm, new_addr, new_len);
89289 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89290 unsigned long ret = -EINVAL;
89291 unsigned long charged = 0;
89292 bool locked = false;
89293 + unsigned long pax_task_size = TASK_SIZE;
89294
89295 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
89296 return ret;
89297 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89298 if (!new_len)
89299 return ret;
89300
89301 +#ifdef CONFIG_PAX_SEGMEXEC
89302 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89303 + pax_task_size = SEGMEXEC_TASK_SIZE;
89304 +#endif
89305 +
89306 + pax_task_size -= PAGE_SIZE;
89307 +
89308 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
89309 + old_len > pax_task_size || addr > pax_task_size-old_len)
89310 + return ret;
89311 +
89312 down_write(&current->mm->mmap_sem);
89313
89314 if (flags & MREMAP_FIXED) {
89315 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89316 new_addr = addr;
89317 }
89318 ret = addr;
89319 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
89320 goto out;
89321 }
89322 }
89323 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89324 goto out;
89325 }
89326
89327 + map_flags = vma->vm_flags;
89328 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
89329 + if (!(ret & ~PAGE_MASK)) {
89330 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
89331 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
89332 + }
89333 }
89334 out:
89335 if (ret & ~PAGE_MASK)
89336 diff --git a/mm/nommu.c b/mm/nommu.c
89337 index ecd1f15..77039bd 100644
89338 --- a/mm/nommu.c
89339 +++ b/mm/nommu.c
89340 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
89341 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
89342 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89343 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89344 -int heap_stack_gap = 0;
89345
89346 atomic_long_t mmap_pages_allocated;
89347
89348 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
89349 EXPORT_SYMBOL(find_vma);
89350
89351 /*
89352 - * find a VMA
89353 - * - we don't extend stack VMAs under NOMMU conditions
89354 - */
89355 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
89356 -{
89357 - return find_vma(mm, addr);
89358 -}
89359 -
89360 -/*
89361 * expand a stack to a given address
89362 * - not supported under NOMMU conditions
89363 */
89364 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89365
89366 /* most fields are the same, copy all, and then fixup */
89367 *new = *vma;
89368 + INIT_LIST_HEAD(&new->anon_vma_chain);
89369 *region = *vma->vm_region;
89370 new->vm_region = region;
89371
89372 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
89373 }
89374 EXPORT_SYMBOL(generic_file_remap_pages);
89375
89376 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89377 - unsigned long addr, void *buf, int len, int write)
89378 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89379 + unsigned long addr, void *buf, size_t len, int write)
89380 {
89381 struct vm_area_struct *vma;
89382
89383 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89384 *
89385 * The caller must hold a reference on @mm.
89386 */
89387 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89388 - void *buf, int len, int write)
89389 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89390 + void *buf, size_t len, int write)
89391 {
89392 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89393 }
89394 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89395 * Access another process' address space.
89396 * - source/target buffer must be kernel space
89397 */
89398 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
89399 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
89400 {
89401 struct mm_struct *mm;
89402
89403 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
89404 index 241a746..41cd05d 100644
89405 --- a/mm/page-writeback.c
89406 +++ b/mm/page-writeback.c
89407 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
89408 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89409 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89410 */
89411 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89412 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89413 unsigned long thresh,
89414 unsigned long bg_thresh,
89415 unsigned long dirty,
89416 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89417 index b100255..54b13c5 100644
89418 --- a/mm/page_alloc.c
89419 +++ b/mm/page_alloc.c
89420 @@ -60,6 +60,7 @@
89421 #include <linux/page-debug-flags.h>
89422 #include <linux/hugetlb.h>
89423 #include <linux/sched/rt.h>
89424 +#include <linux/random.h>
89425
89426 #include <asm/sections.h>
89427 #include <asm/tlbflush.h>
89428 @@ -353,7 +354,7 @@ out:
89429 * This usage means that zero-order pages may not be compound.
89430 */
89431
89432 -static void free_compound_page(struct page *page)
89433 +void free_compound_page(struct page *page)
89434 {
89435 __free_pages_ok(page, compound_order(page));
89436 }
89437 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89438 int i;
89439 int bad = 0;
89440
89441 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89442 + unsigned long index = 1UL << order;
89443 +#endif
89444 +
89445 trace_mm_page_free(page, order);
89446 kmemcheck_free_shadow(page, order);
89447
89448 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89449 debug_check_no_obj_freed(page_address(page),
89450 PAGE_SIZE << order);
89451 }
89452 +
89453 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89454 + for (; index; --index)
89455 + sanitize_highpage(page + index - 1);
89456 +#endif
89457 +
89458 arch_free_page(page, order);
89459 kernel_map_pages(page, 1 << order, 0);
89460
89461 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
89462 local_irq_restore(flags);
89463 }
89464
89465 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89466 +bool __meminitdata extra_latent_entropy;
89467 +
89468 +static int __init setup_pax_extra_latent_entropy(char *str)
89469 +{
89470 + extra_latent_entropy = true;
89471 + return 0;
89472 +}
89473 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
89474 +
89475 +volatile u64 latent_entropy __latent_entropy;
89476 +EXPORT_SYMBOL(latent_entropy);
89477 +#endif
89478 +
89479 void __init __free_pages_bootmem(struct page *page, unsigned int order)
89480 {
89481 unsigned int nr_pages = 1 << order;
89482 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
89483 set_page_count(p, 0);
89484 }
89485
89486 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89487 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
89488 + u64 hash = 0;
89489 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
89490 + const u64 *data = lowmem_page_address(page);
89491 +
89492 + for (index = 0; index < end; index++)
89493 + hash ^= hash + data[index];
89494 + latent_entropy ^= hash;
89495 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
89496 + }
89497 +#endif
89498 +
89499 page_zone(page)->managed_pages += 1 << order;
89500 set_page_refcounted(page);
89501 __free_pages(page, order);
89502 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
89503 arch_alloc_page(page, order);
89504 kernel_map_pages(page, 1 << order, 1);
89505
89506 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
89507 if (gfp_flags & __GFP_ZERO)
89508 prep_zero_page(page, order, gfp_flags);
89509 +#endif
89510
89511 if (order && (gfp_flags & __GFP_COMP))
89512 prep_compound_page(page, order);
89513 diff --git a/mm/page_io.c b/mm/page_io.c
89514 index ba05b64..ef2f314 100644
89515 --- a/mm/page_io.c
89516 +++ b/mm/page_io.c
89517 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
89518 struct file *swap_file = sis->swap_file;
89519 struct address_space *mapping = swap_file->f_mapping;
89520 struct iovec iov = {
89521 - .iov_base = kmap(page),
89522 + .iov_base = (void __force_user *)kmap(page),
89523 .iov_len = PAGE_SIZE,
89524 };
89525
89526 diff --git a/mm/percpu.c b/mm/percpu.c
89527 index 8c8e08f..73a5cda 100644
89528 --- a/mm/percpu.c
89529 +++ b/mm/percpu.c
89530 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89531 static unsigned int pcpu_high_unit_cpu __read_mostly;
89532
89533 /* the address of the first chunk which starts with the kernel static area */
89534 -void *pcpu_base_addr __read_mostly;
89535 +void *pcpu_base_addr __read_only;
89536 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89537
89538 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89539 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89540 index fd26d04..0cea1b0 100644
89541 --- a/mm/process_vm_access.c
89542 +++ b/mm/process_vm_access.c
89543 @@ -13,6 +13,7 @@
89544 #include <linux/uio.h>
89545 #include <linux/sched.h>
89546 #include <linux/highmem.h>
89547 +#include <linux/security.h>
89548 #include <linux/ptrace.h>
89549 #include <linux/slab.h>
89550 #include <linux/syscalls.h>
89551 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89552 size_t iov_l_curr_offset = 0;
89553 ssize_t iov_len;
89554
89555 + return -ENOSYS; // PaX: until properly audited
89556 +
89557 /*
89558 * Work out how many pages of struct pages we're going to need
89559 * when eventually calling get_user_pages
89560 */
89561 for (i = 0; i < riovcnt; i++) {
89562 iov_len = rvec[i].iov_len;
89563 - if (iov_len > 0) {
89564 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89565 - + iov_len)
89566 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89567 - / PAGE_SIZE + 1;
89568 - nr_pages = max(nr_pages, nr_pages_iov);
89569 - }
89570 + if (iov_len <= 0)
89571 + continue;
89572 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89573 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89574 + nr_pages = max(nr_pages, nr_pages_iov);
89575 }
89576
89577 if (nr_pages == 0)
89578 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89579 goto free_proc_pages;
89580 }
89581
89582 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89583 + rc = -EPERM;
89584 + goto put_task_struct;
89585 + }
89586 +
89587 mm = mm_access(task, PTRACE_MODE_ATTACH);
89588 if (!mm || IS_ERR(mm)) {
89589 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89590 diff --git a/mm/rmap.c b/mm/rmap.c
89591 index b2e29ac..4168491 100644
89592 --- a/mm/rmap.c
89593 +++ b/mm/rmap.c
89594 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89595 struct anon_vma *anon_vma = vma->anon_vma;
89596 struct anon_vma_chain *avc;
89597
89598 +#ifdef CONFIG_PAX_SEGMEXEC
89599 + struct anon_vma_chain *avc_m = NULL;
89600 +#endif
89601 +
89602 might_sleep();
89603 if (unlikely(!anon_vma)) {
89604 struct mm_struct *mm = vma->vm_mm;
89605 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89606 if (!avc)
89607 goto out_enomem;
89608
89609 +#ifdef CONFIG_PAX_SEGMEXEC
89610 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89611 + if (!avc_m)
89612 + goto out_enomem_free_avc;
89613 +#endif
89614 +
89615 anon_vma = find_mergeable_anon_vma(vma);
89616 allocated = NULL;
89617 if (!anon_vma) {
89618 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89619 /* page_table_lock to protect against threads */
89620 spin_lock(&mm->page_table_lock);
89621 if (likely(!vma->anon_vma)) {
89622 +
89623 +#ifdef CONFIG_PAX_SEGMEXEC
89624 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89625 +
89626 + if (vma_m) {
89627 + BUG_ON(vma_m->anon_vma);
89628 + vma_m->anon_vma = anon_vma;
89629 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89630 + avc_m = NULL;
89631 + }
89632 +#endif
89633 +
89634 vma->anon_vma = anon_vma;
89635 anon_vma_chain_link(vma, avc, anon_vma);
89636 allocated = NULL;
89637 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89638
89639 if (unlikely(allocated))
89640 put_anon_vma(allocated);
89641 +
89642 +#ifdef CONFIG_PAX_SEGMEXEC
89643 + if (unlikely(avc_m))
89644 + anon_vma_chain_free(avc_m);
89645 +#endif
89646 +
89647 if (unlikely(avc))
89648 anon_vma_chain_free(avc);
89649 }
89650 return 0;
89651
89652 out_enomem_free_avc:
89653 +
89654 +#ifdef CONFIG_PAX_SEGMEXEC
89655 + if (avc_m)
89656 + anon_vma_chain_free(avc_m);
89657 +#endif
89658 +
89659 anon_vma_chain_free(avc);
89660 out_enomem:
89661 return -ENOMEM;
89662 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89663 * Attach the anon_vmas from src to dst.
89664 * Returns 0 on success, -ENOMEM on failure.
89665 */
89666 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89667 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89668 {
89669 struct anon_vma_chain *avc, *pavc;
89670 struct anon_vma *root = NULL;
89671 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89672 * the corresponding VMA in the parent process is attached to.
89673 * Returns 0 on success, non-zero on failure.
89674 */
89675 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89676 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89677 {
89678 struct anon_vma_chain *avc;
89679 struct anon_vma *anon_vma;
89680 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89681 void __init anon_vma_init(void)
89682 {
89683 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89684 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89685 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89686 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89687 + anon_vma_ctor);
89688 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89689 + SLAB_PANIC|SLAB_NO_SANITIZE);
89690 }
89691
89692 /*
89693 diff --git a/mm/shmem.c b/mm/shmem.c
89694 index e43dc55..930e3a2 100644
89695 --- a/mm/shmem.c
89696 +++ b/mm/shmem.c
89697 @@ -33,7 +33,7 @@
89698 #include <linux/swap.h>
89699 #include <linux/aio.h>
89700
89701 -static struct vfsmount *shm_mnt;
89702 +struct vfsmount *shm_mnt;
89703
89704 #ifdef CONFIG_SHMEM
89705 /*
89706 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89707 #define BOGO_DIRENT_SIZE 20
89708
89709 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89710 -#define SHORT_SYMLINK_LEN 128
89711 +#define SHORT_SYMLINK_LEN 64
89712
89713 /*
89714 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89715 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89716 static int shmem_xattr_validate(const char *name)
89717 {
89718 struct { const char *prefix; size_t len; } arr[] = {
89719 +
89720 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89721 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89722 +#endif
89723 +
89724 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89725 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89726 };
89727 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89728 if (err)
89729 return err;
89730
89731 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89732 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89733 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89734 + return -EOPNOTSUPP;
89735 + if (size > 8)
89736 + return -EINVAL;
89737 + }
89738 +#endif
89739 +
89740 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89741 }
89742
89743 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89744 int err = -ENOMEM;
89745
89746 /* Round up to L1_CACHE_BYTES to resist false sharing */
89747 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89748 - L1_CACHE_BYTES), GFP_KERNEL);
89749 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89750 if (!sbinfo)
89751 return -ENOMEM;
89752
89753 diff --git a/mm/slab.c b/mm/slab.c
89754 index 2580db0..0523956 100644
89755 --- a/mm/slab.c
89756 +++ b/mm/slab.c
89757 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89758 if ((x)->max_freeable < i) \
89759 (x)->max_freeable = i; \
89760 } while (0)
89761 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89762 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89763 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89764 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89765 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89766 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89767 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89768 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89769 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89770 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89771 #else
89772 #define STATS_INC_ACTIVE(x) do { } while (0)
89773 #define STATS_DEC_ACTIVE(x) do { } while (0)
89774 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89775 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89776 #define STATS_INC_FREEHIT(x) do { } while (0)
89777 #define STATS_INC_FREEMISS(x) do { } while (0)
89778 +#define STATS_INC_SANITIZED(x) do { } while (0)
89779 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89780 #endif
89781
89782 #if DEBUG
89783 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89784 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89785 */
89786 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89787 - const struct slab *slab, void *obj)
89788 + const struct slab *slab, const void *obj)
89789 {
89790 u32 offset = (obj - slab->s_mem);
89791 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89792 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89793 */
89794
89795 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89796 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89797 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89798
89799 if (INDEX_AC != INDEX_NODE)
89800 kmalloc_caches[INDEX_NODE] =
89801 create_kmalloc_cache("kmalloc-node",
89802 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89803 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89804
89805 slab_early_init = 0;
89806
89807 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89808 struct array_cache *ac = cpu_cache_get(cachep);
89809
89810 check_irq_off();
89811 +
89812 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89813 + if (pax_sanitize_slab) {
89814 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89815 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89816 +
89817 + if (cachep->ctor)
89818 + cachep->ctor(objp);
89819 +
89820 + STATS_INC_SANITIZED(cachep);
89821 + } else
89822 + STATS_INC_NOT_SANITIZED(cachep);
89823 + }
89824 +#endif
89825 +
89826 kmemleak_free_recursive(objp, cachep->flags);
89827 objp = cache_free_debugcheck(cachep, objp, caller);
89828
89829 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89830
89831 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89832 return;
89833 + VM_BUG_ON(!virt_addr_valid(objp));
89834 local_irq_save(flags);
89835 kfree_debugcheck(objp);
89836 c = virt_to_cache(objp);
89837 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89838 }
89839 /* cpu stats */
89840 {
89841 - unsigned long allochit = atomic_read(&cachep->allochit);
89842 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89843 - unsigned long freehit = atomic_read(&cachep->freehit);
89844 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89845 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89846 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89847 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89848 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89849
89850 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89851 allochit, allocmiss, freehit, freemiss);
89852 }
89853 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89854 + {
89855 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89856 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89857 +
89858 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89859 + }
89860 +#endif
89861 #endif
89862 }
89863
89864 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89865 static int __init slab_proc_init(void)
89866 {
89867 #ifdef CONFIG_DEBUG_SLAB_LEAK
89868 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89869 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89870 #endif
89871 return 0;
89872 }
89873 module_init(slab_proc_init);
89874 #endif
89875
89876 +bool is_usercopy_object(const void *ptr)
89877 +{
89878 + struct page *page;
89879 + struct kmem_cache *cachep;
89880 +
89881 + if (ZERO_OR_NULL_PTR(ptr))
89882 + return false;
89883 +
89884 + if (!slab_is_available())
89885 + return false;
89886 +
89887 + if (!virt_addr_valid(ptr))
89888 + return false;
89889 +
89890 + page = virt_to_head_page(ptr);
89891 +
89892 + if (!PageSlab(page))
89893 + return false;
89894 +
89895 + cachep = page->slab_cache;
89896 + return cachep->flags & SLAB_USERCOPY;
89897 +}
89898 +
89899 +#ifdef CONFIG_PAX_USERCOPY
89900 +const char *check_heap_object(const void *ptr, unsigned long n)
89901 +{
89902 + struct page *page;
89903 + struct kmem_cache *cachep;
89904 + struct slab *slabp;
89905 + unsigned int objnr;
89906 + unsigned long offset;
89907 +
89908 + if (ZERO_OR_NULL_PTR(ptr))
89909 + return "<null>";
89910 +
89911 + if (!virt_addr_valid(ptr))
89912 + return NULL;
89913 +
89914 + page = virt_to_head_page(ptr);
89915 +
89916 + if (!PageSlab(page))
89917 + return NULL;
89918 +
89919 + cachep = page->slab_cache;
89920 + if (!(cachep->flags & SLAB_USERCOPY))
89921 + return cachep->name;
89922 +
89923 + slabp = page->slab_page;
89924 + objnr = obj_to_index(cachep, slabp, ptr);
89925 + BUG_ON(objnr >= cachep->num);
89926 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89927 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89928 + return NULL;
89929 +
89930 + return cachep->name;
89931 +}
89932 +#endif
89933 +
89934 /**
89935 * ksize - get the actual amount of memory allocated for a given object
89936 * @objp: Pointer to the object
89937 diff --git a/mm/slab.h b/mm/slab.h
89938 index a535033..2f98fe5 100644
89939 --- a/mm/slab.h
89940 +++ b/mm/slab.h
89941 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89942 /* The slab cache that manages slab cache information */
89943 extern struct kmem_cache *kmem_cache;
89944
89945 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89946 +#ifdef CONFIG_X86_64
89947 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89948 +#else
89949 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89950 +#endif
89951 +extern bool pax_sanitize_slab;
89952 +#endif
89953 +
89954 unsigned long calculate_alignment(unsigned long flags,
89955 unsigned long align, unsigned long size);
89956
89957 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89958
89959 /* Legal flag mask for kmem_cache_create(), for various configurations */
89960 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89961 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89962 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89963 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89964
89965 #if defined(CONFIG_DEBUG_SLAB)
89966 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89967 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89968 return s;
89969
89970 page = virt_to_head_page(x);
89971 +
89972 + BUG_ON(!PageSlab(page));
89973 +
89974 cachep = page->slab_cache;
89975 if (slab_equal_or_root(cachep, s))
89976 return cachep;
89977 diff --git a/mm/slab_common.c b/mm/slab_common.c
89978 index 538bade..36fed99 100644
89979 --- a/mm/slab_common.c
89980 +++ b/mm/slab_common.c
89981 @@ -22,11 +22,22 @@
89982
89983 #include "slab.h"
89984
89985 -enum slab_state slab_state;
89986 +enum slab_state slab_state __read_only;
89987 LIST_HEAD(slab_caches);
89988 DEFINE_MUTEX(slab_mutex);
89989 struct kmem_cache *kmem_cache;
89990
89991 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89992 +bool pax_sanitize_slab __read_only = true;
89993 +static int __init pax_sanitize_slab_setup(char *str)
89994 +{
89995 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89996 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89997 + return 1;
89998 +}
89999 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
90000 +#endif
90001 +
90002 #ifdef CONFIG_DEBUG_VM
90003 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
90004 size_t size)
90005 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
90006
90007 err = __kmem_cache_create(s, flags);
90008 if (!err) {
90009 - s->refcount = 1;
90010 + atomic_set(&s->refcount, 1);
90011 list_add(&s->list, &slab_caches);
90012 memcg_cache_list_add(memcg, s);
90013 } else {
90014 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
90015
90016 get_online_cpus();
90017 mutex_lock(&slab_mutex);
90018 - s->refcount--;
90019 - if (!s->refcount) {
90020 + if (atomic_dec_and_test(&s->refcount)) {
90021 list_del(&s->list);
90022
90023 if (!__kmem_cache_shutdown(s)) {
90024 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
90025 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
90026 name, size, err);
90027
90028 - s->refcount = -1; /* Exempt from merging for now */
90029 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
90030 }
90031
90032 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90033 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90034
90035 create_boot_cache(s, name, size, flags);
90036 list_add(&s->list, &slab_caches);
90037 - s->refcount = 1;
90038 + atomic_set(&s->refcount, 1);
90039 return s;
90040 }
90041
90042 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
90043 EXPORT_SYMBOL(kmalloc_dma_caches);
90044 #endif
90045
90046 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90047 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
90048 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
90049 +#endif
90050 +
90051 /*
90052 * Conversion table for small slabs sizes / 8 to the index in the
90053 * kmalloc array. This is necessary for slabs < 192 since we have non power
90054 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
90055 return kmalloc_dma_caches[index];
90056
90057 #endif
90058 +
90059 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90060 + if (unlikely((flags & GFP_USERCOPY)))
90061 + return kmalloc_usercopy_caches[index];
90062 +
90063 +#endif
90064 +
90065 return kmalloc_caches[index];
90066 }
90067
90068 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
90069 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
90070 if (!kmalloc_caches[i]) {
90071 kmalloc_caches[i] = create_kmalloc_cache(NULL,
90072 - 1 << i, flags);
90073 + 1 << i, SLAB_USERCOPY | flags);
90074 }
90075
90076 /*
90077 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
90078 * earlier power of two caches
90079 */
90080 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
90081 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
90082 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
90083
90084 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
90085 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
90086 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
90087 }
90088
90089 /* Kmalloc array is now usable */
90090 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
90091 }
90092 }
90093 #endif
90094 +
90095 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90096 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
90097 + struct kmem_cache *s = kmalloc_caches[i];
90098 +
90099 + if (s) {
90100 + int size = kmalloc_size(i);
90101 + char *n = kasprintf(GFP_NOWAIT,
90102 + "usercopy-kmalloc-%d", size);
90103 +
90104 + BUG_ON(!n);
90105 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
90106 + size, SLAB_USERCOPY | flags);
90107 + }
90108 + }
90109 +#endif
90110 +
90111 }
90112 #endif /* !CONFIG_SLOB */
90113
90114 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
90115 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
90116 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
90117 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
90118 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90119 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
90120 +#endif
90121 #endif
90122 seq_putc(m, '\n');
90123 }
90124 diff --git a/mm/slob.c b/mm/slob.c
90125 index 91bd3f2..e2f549e 100644
90126 --- a/mm/slob.c
90127 +++ b/mm/slob.c
90128 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
90129 /*
90130 * Return the size of a slob block.
90131 */
90132 -static slobidx_t slob_units(slob_t *s)
90133 +static slobidx_t slob_units(const slob_t *s)
90134 {
90135 if (s->units > 0)
90136 return s->units;
90137 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
90138 /*
90139 * Return the next free slob block pointer after this one.
90140 */
90141 -static slob_t *slob_next(slob_t *s)
90142 +static slob_t *slob_next(const slob_t *s)
90143 {
90144 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
90145 slobidx_t next;
90146 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
90147 /*
90148 * Returns true if s is the last free block in its page.
90149 */
90150 -static int slob_last(slob_t *s)
90151 +static int slob_last(const slob_t *s)
90152 {
90153 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
90154 }
90155
90156 -static void *slob_new_pages(gfp_t gfp, int order, int node)
90157 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
90158 {
90159 - void *page;
90160 + struct page *page;
90161
90162 #ifdef CONFIG_NUMA
90163 if (node != NUMA_NO_NODE)
90164 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
90165 if (!page)
90166 return NULL;
90167
90168 - return page_address(page);
90169 + __SetPageSlab(page);
90170 + return page;
90171 }
90172
90173 -static void slob_free_pages(void *b, int order)
90174 +static void slob_free_pages(struct page *sp, int order)
90175 {
90176 if (current->reclaim_state)
90177 current->reclaim_state->reclaimed_slab += 1 << order;
90178 - free_pages((unsigned long)b, order);
90179 + __ClearPageSlab(sp);
90180 + page_mapcount_reset(sp);
90181 + sp->private = 0;
90182 + __free_pages(sp, order);
90183 }
90184
90185 /*
90186 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
90187
90188 /* Not enough space: must allocate a new page */
90189 if (!b) {
90190 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90191 - if (!b)
90192 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90193 + if (!sp)
90194 return NULL;
90195 - sp = virt_to_page(b);
90196 - __SetPageSlab(sp);
90197 + b = page_address(sp);
90198
90199 spin_lock_irqsave(&slob_lock, flags);
90200 sp->units = SLOB_UNITS(PAGE_SIZE);
90201 sp->freelist = b;
90202 + sp->private = 0;
90203 INIT_LIST_HEAD(&sp->list);
90204 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
90205 set_slob_page_free(sp, slob_list);
90206 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
90207 if (slob_page_free(sp))
90208 clear_slob_page_free(sp);
90209 spin_unlock_irqrestore(&slob_lock, flags);
90210 - __ClearPageSlab(sp);
90211 - page_mapcount_reset(sp);
90212 - slob_free_pages(b, 0);
90213 + slob_free_pages(sp, 0);
90214 return;
90215 }
90216
90217 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90218 + if (pax_sanitize_slab)
90219 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
90220 +#endif
90221 +
90222 if (!slob_page_free(sp)) {
90223 /* This slob page is about to become partially free. Easy! */
90224 sp->units = units;
90225 @@ -424,11 +431,10 @@ out:
90226 */
90227
90228 static __always_inline void *
90229 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90230 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
90231 {
90232 - unsigned int *m;
90233 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90234 - void *ret;
90235 + slob_t *m;
90236 + void *ret = NULL;
90237
90238 gfp &= gfp_allowed_mask;
90239
90240 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90241
90242 if (!m)
90243 return NULL;
90244 - *m = size;
90245 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
90246 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
90247 + m[0].units = size;
90248 + m[1].units = align;
90249 ret = (void *)m + align;
90250
90251 trace_kmalloc_node(caller, ret,
90252 size, size + align, gfp, node);
90253 } else {
90254 unsigned int order = get_order(size);
90255 + struct page *page;
90256
90257 if (likely(order))
90258 gfp |= __GFP_COMP;
90259 - ret = slob_new_pages(gfp, order, node);
90260 + page = slob_new_pages(gfp, order, node);
90261 + if (page) {
90262 + ret = page_address(page);
90263 + page->private = size;
90264 + }
90265
90266 trace_kmalloc_node(caller, ret,
90267 size, PAGE_SIZE << order, gfp, node);
90268 }
90269
90270 - kmemleak_alloc(ret, size, 1, gfp);
90271 + return ret;
90272 +}
90273 +
90274 +static __always_inline void *
90275 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90276 +{
90277 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90278 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
90279 +
90280 + if (!ZERO_OR_NULL_PTR(ret))
90281 + kmemleak_alloc(ret, size, 1, gfp);
90282 return ret;
90283 }
90284
90285 @@ -493,34 +517,112 @@ void kfree(const void *block)
90286 return;
90287 kmemleak_free(block);
90288
90289 + VM_BUG_ON(!virt_addr_valid(block));
90290 sp = virt_to_page(block);
90291 - if (PageSlab(sp)) {
90292 + VM_BUG_ON(!PageSlab(sp));
90293 + if (!sp->private) {
90294 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90295 - unsigned int *m = (unsigned int *)(block - align);
90296 - slob_free(m, *m + align);
90297 - } else
90298 + slob_t *m = (slob_t *)(block - align);
90299 + slob_free(m, m[0].units + align);
90300 + } else {
90301 + __ClearPageSlab(sp);
90302 + page_mapcount_reset(sp);
90303 + sp->private = 0;
90304 __free_pages(sp, compound_order(sp));
90305 + }
90306 }
90307 EXPORT_SYMBOL(kfree);
90308
90309 +bool is_usercopy_object(const void *ptr)
90310 +{
90311 + if (!slab_is_available())
90312 + return false;
90313 +
90314 + // PAX: TODO
90315 +
90316 + return false;
90317 +}
90318 +
90319 +#ifdef CONFIG_PAX_USERCOPY
90320 +const char *check_heap_object(const void *ptr, unsigned long n)
90321 +{
90322 + struct page *page;
90323 + const slob_t *free;
90324 + const void *base;
90325 + unsigned long flags;
90326 +
90327 + if (ZERO_OR_NULL_PTR(ptr))
90328 + return "<null>";
90329 +
90330 + if (!virt_addr_valid(ptr))
90331 + return NULL;
90332 +
90333 + page = virt_to_head_page(ptr);
90334 + if (!PageSlab(page))
90335 + return NULL;
90336 +
90337 + if (page->private) {
90338 + base = page;
90339 + if (base <= ptr && n <= page->private - (ptr - base))
90340 + return NULL;
90341 + return "<slob>";
90342 + }
90343 +
90344 + /* some tricky double walking to find the chunk */
90345 + spin_lock_irqsave(&slob_lock, flags);
90346 + base = (void *)((unsigned long)ptr & PAGE_MASK);
90347 + free = page->freelist;
90348 +
90349 + while (!slob_last(free) && (void *)free <= ptr) {
90350 + base = free + slob_units(free);
90351 + free = slob_next(free);
90352 + }
90353 +
90354 + while (base < (void *)free) {
90355 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
90356 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
90357 + int offset;
90358 +
90359 + if (ptr < base + align)
90360 + break;
90361 +
90362 + offset = ptr - base - align;
90363 + if (offset >= m) {
90364 + base += size;
90365 + continue;
90366 + }
90367 +
90368 + if (n > m - offset)
90369 + break;
90370 +
90371 + spin_unlock_irqrestore(&slob_lock, flags);
90372 + return NULL;
90373 + }
90374 +
90375 + spin_unlock_irqrestore(&slob_lock, flags);
90376 + return "<slob>";
90377 +}
90378 +#endif
90379 +
90380 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
90381 size_t ksize(const void *block)
90382 {
90383 struct page *sp;
90384 int align;
90385 - unsigned int *m;
90386 + slob_t *m;
90387
90388 BUG_ON(!block);
90389 if (unlikely(block == ZERO_SIZE_PTR))
90390 return 0;
90391
90392 sp = virt_to_page(block);
90393 - if (unlikely(!PageSlab(sp)))
90394 - return PAGE_SIZE << compound_order(sp);
90395 + VM_BUG_ON(!PageSlab(sp));
90396 + if (sp->private)
90397 + return sp->private;
90398
90399 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90400 - m = (unsigned int *)(block - align);
90401 - return SLOB_UNITS(*m) * SLOB_UNIT;
90402 + m = (slob_t *)(block - align);
90403 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
90404 }
90405 EXPORT_SYMBOL(ksize);
90406
90407 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90408
90409 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90410 {
90411 - void *b;
90412 + void *b = NULL;
90413
90414 flags &= gfp_allowed_mask;
90415
90416 lockdep_trace_alloc(flags);
90417
90418 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90419 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
90420 +#else
90421 if (c->size < PAGE_SIZE) {
90422 b = slob_alloc(c->size, flags, c->align, node);
90423 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90424 SLOB_UNITS(c->size) * SLOB_UNIT,
90425 flags, node);
90426 } else {
90427 - b = slob_new_pages(flags, get_order(c->size), node);
90428 + struct page *sp;
90429 +
90430 + sp = slob_new_pages(flags, get_order(c->size), node);
90431 + if (sp) {
90432 + b = page_address(sp);
90433 + sp->private = c->size;
90434 + }
90435 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90436 PAGE_SIZE << get_order(c->size),
90437 flags, node);
90438 }
90439 +#endif
90440
90441 if (b && c->ctor)
90442 c->ctor(b);
90443 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
90444
90445 static void __kmem_cache_free(void *b, int size)
90446 {
90447 - if (size < PAGE_SIZE)
90448 + struct page *sp;
90449 +
90450 + sp = virt_to_page(b);
90451 + BUG_ON(!PageSlab(sp));
90452 + if (!sp->private)
90453 slob_free(b, size);
90454 else
90455 - slob_free_pages(b, get_order(size));
90456 + slob_free_pages(sp, get_order(size));
90457 }
90458
90459 static void kmem_rcu_free(struct rcu_head *head)
90460 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
90461
90462 void kmem_cache_free(struct kmem_cache *c, void *b)
90463 {
90464 + int size = c->size;
90465 +
90466 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90467 + if (size + c->align < PAGE_SIZE) {
90468 + size += c->align;
90469 + b -= c->align;
90470 + }
90471 +#endif
90472 +
90473 kmemleak_free_recursive(b, c->flags);
90474 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
90475 struct slob_rcu *slob_rcu;
90476 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
90477 - slob_rcu->size = c->size;
90478 + slob_rcu = b + (size - sizeof(struct slob_rcu));
90479 + slob_rcu->size = size;
90480 call_rcu(&slob_rcu->head, kmem_rcu_free);
90481 } else {
90482 - __kmem_cache_free(b, c->size);
90483 + __kmem_cache_free(b, size);
90484 }
90485
90486 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90487 + trace_kfree(_RET_IP_, b);
90488 +#else
90489 trace_kmem_cache_free(_RET_IP_, b);
90490 +#endif
90491 +
90492 }
90493 EXPORT_SYMBOL(kmem_cache_free);
90494
90495 diff --git a/mm/slub.c b/mm/slub.c
90496 index e3ba1f2..bd45dac 100644
90497 --- a/mm/slub.c
90498 +++ b/mm/slub.c
90499 @@ -207,7 +207,7 @@ struct track {
90500
90501 enum track_item { TRACK_ALLOC, TRACK_FREE };
90502
90503 -#ifdef CONFIG_SYSFS
90504 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90505 static int sysfs_slab_add(struct kmem_cache *);
90506 static int sysfs_slab_alias(struct kmem_cache *, const char *);
90507 static void sysfs_slab_remove(struct kmem_cache *);
90508 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
90509 if (!t->addr)
90510 return;
90511
90512 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
90513 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
90514 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
90515 #ifdef CONFIG_STACKTRACE
90516 {
90517 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
90518
90519 slab_free_hook(s, x);
90520
90521 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90522 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90523 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90524 + if (s->ctor)
90525 + s->ctor(x);
90526 + }
90527 +#endif
90528 +
90529 redo:
90530 /*
90531 * Determine the currently cpus per cpu slab.
90532 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90533 * Merge control. If this is set then no merging of slab caches will occur.
90534 * (Could be removed. This was introduced to pacify the merge skeptics.)
90535 */
90536 -static int slub_nomerge;
90537 +static int slub_nomerge = 1;
90538
90539 /*
90540 * Calculate the order of allocation given an slab object size.
90541 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90542 s->inuse = size;
90543
90544 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90545 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90546 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90547 +#endif
90548 s->ctor)) {
90549 /*
90550 * Relocate free pointer after the object if it is not
90551 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90552 EXPORT_SYMBOL(__kmalloc_node);
90553 #endif
90554
90555 +bool is_usercopy_object(const void *ptr)
90556 +{
90557 + struct page *page;
90558 + struct kmem_cache *s;
90559 +
90560 + if (ZERO_OR_NULL_PTR(ptr))
90561 + return false;
90562 +
90563 + if (!slab_is_available())
90564 + return false;
90565 +
90566 + if (!virt_addr_valid(ptr))
90567 + return false;
90568 +
90569 + page = virt_to_head_page(ptr);
90570 +
90571 + if (!PageSlab(page))
90572 + return false;
90573 +
90574 + s = page->slab_cache;
90575 + return s->flags & SLAB_USERCOPY;
90576 +}
90577 +
90578 +#ifdef CONFIG_PAX_USERCOPY
90579 +const char *check_heap_object(const void *ptr, unsigned long n)
90580 +{
90581 + struct page *page;
90582 + struct kmem_cache *s;
90583 + unsigned long offset;
90584 +
90585 + if (ZERO_OR_NULL_PTR(ptr))
90586 + return "<null>";
90587 +
90588 + if (!virt_addr_valid(ptr))
90589 + return NULL;
90590 +
90591 + page = virt_to_head_page(ptr);
90592 +
90593 + if (!PageSlab(page))
90594 + return NULL;
90595 +
90596 + s = page->slab_cache;
90597 + if (!(s->flags & SLAB_USERCOPY))
90598 + return s->name;
90599 +
90600 + offset = (ptr - page_address(page)) % s->size;
90601 + if (offset <= s->object_size && n <= s->object_size - offset)
90602 + return NULL;
90603 +
90604 + return s->name;
90605 +}
90606 +#endif
90607 +
90608 size_t ksize(const void *object)
90609 {
90610 struct page *page;
90611 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90612 if (unlikely(ZERO_OR_NULL_PTR(x)))
90613 return;
90614
90615 + VM_BUG_ON(!virt_addr_valid(x));
90616 page = virt_to_head_page(x);
90617 if (unlikely(!PageSlab(page))) {
90618 BUG_ON(!PageCompound(page));
90619 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90620 /*
90621 * We may have set a slab to be unmergeable during bootstrap.
90622 */
90623 - if (s->refcount < 0)
90624 + if (atomic_read(&s->refcount) < 0)
90625 return 1;
90626
90627 return 0;
90628 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90629
90630 s = find_mergeable(memcg, size, align, flags, name, ctor);
90631 if (s) {
90632 - s->refcount++;
90633 + atomic_inc(&s->refcount);
90634 /*
90635 * Adjust the object sizes so that we clear
90636 * the complete object on kzalloc.
90637 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90638 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90639
90640 if (sysfs_slab_alias(s, name)) {
90641 - s->refcount--;
90642 + atomic_dec(&s->refcount);
90643 s = NULL;
90644 }
90645 }
90646 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90647 }
90648 #endif
90649
90650 -#ifdef CONFIG_SYSFS
90651 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90652 static int count_inuse(struct page *page)
90653 {
90654 return page->inuse;
90655 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90656 validate_slab_cache(kmalloc_caches[9]);
90657 }
90658 #else
90659 -#ifdef CONFIG_SYSFS
90660 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90661 static void resiliency_test(void) {};
90662 #endif
90663 #endif
90664
90665 -#ifdef CONFIG_SYSFS
90666 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90667 enum slab_stat_type {
90668 SL_ALL, /* All slabs */
90669 SL_PARTIAL, /* Only partially allocated slabs */
90670 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90671
90672 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90673 {
90674 - return sprintf(buf, "%d\n", s->refcount - 1);
90675 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90676 }
90677 SLAB_ATTR_RO(aliases);
90678
90679 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90680 SLAB_ATTR_RO(cache_dma);
90681 #endif
90682
90683 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90684 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90685 +{
90686 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90687 +}
90688 +SLAB_ATTR_RO(usercopy);
90689 +#endif
90690 +
90691 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90692 {
90693 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90694 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90695 #ifdef CONFIG_ZONE_DMA
90696 &cache_dma_attr.attr,
90697 #endif
90698 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90699 + &usercopy_attr.attr,
90700 +#endif
90701 #ifdef CONFIG_NUMA
90702 &remote_node_defrag_ratio_attr.attr,
90703 #endif
90704 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90705 return name;
90706 }
90707
90708 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90709 static int sysfs_slab_add(struct kmem_cache *s)
90710 {
90711 int err;
90712 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90713 }
90714
90715 s->kobj.kset = slab_kset;
90716 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90717 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90718 if (err) {
90719 kobject_put(&s->kobj);
90720 return err;
90721 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90722 kobject_del(&s->kobj);
90723 kobject_put(&s->kobj);
90724 }
90725 +#endif
90726
90727 /*
90728 * Need to buffer aliases during bootup until sysfs becomes
90729 @@ -5213,6 +5291,7 @@ struct saved_alias {
90730
90731 static struct saved_alias *alias_list;
90732
90733 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90734 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90735 {
90736 struct saved_alias *al;
90737 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90738 alias_list = al;
90739 return 0;
90740 }
90741 +#endif
90742
90743 static int __init slab_sysfs_init(void)
90744 {
90745 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90746 index 27eeab3..7c3f7f2 100644
90747 --- a/mm/sparse-vmemmap.c
90748 +++ b/mm/sparse-vmemmap.c
90749 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90750 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90751 if (!p)
90752 return NULL;
90753 - pud_populate(&init_mm, pud, p);
90754 + pud_populate_kernel(&init_mm, pud, p);
90755 }
90756 return pud;
90757 }
90758 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90759 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90760 if (!p)
90761 return NULL;
90762 - pgd_populate(&init_mm, pgd, p);
90763 + pgd_populate_kernel(&init_mm, pgd, p);
90764 }
90765 return pgd;
90766 }
90767 diff --git a/mm/sparse.c b/mm/sparse.c
90768 index 308d503..3dbbd04 100644
90769 --- a/mm/sparse.c
90770 +++ b/mm/sparse.c
90771 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90772
90773 for (i = 0; i < PAGES_PER_SECTION; i++) {
90774 if (PageHWPoison(&memmap[i])) {
90775 - atomic_long_sub(1, &num_poisoned_pages);
90776 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90777 ClearPageHWPoison(&memmap[i]);
90778 }
90779 }
90780 diff --git a/mm/swap.c b/mm/swap.c
90781 index c899502..d4dc2cd 100644
90782 --- a/mm/swap.c
90783 +++ b/mm/swap.c
90784 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
90785
90786 __page_cache_release(page);
90787 dtor = get_compound_page_dtor(page);
90788 + if (!PageHuge(page))
90789 + BUG_ON(dtor != free_compound_page);
90790 (*dtor)(page);
90791 }
90792
90793 diff --git a/mm/swapfile.c b/mm/swapfile.c
90794 index 6cf2e60..d204b3e 100644
90795 --- a/mm/swapfile.c
90796 +++ b/mm/swapfile.c
90797 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90798
90799 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90800 /* Activity counter to indicate that a swapon or swapoff has occurred */
90801 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90802 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90803
90804 static inline unsigned char swap_count(unsigned char ent)
90805 {
90806 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90807 }
90808 filp_close(swap_file, NULL);
90809 err = 0;
90810 - atomic_inc(&proc_poll_event);
90811 + atomic_inc_unchecked(&proc_poll_event);
90812 wake_up_interruptible(&proc_poll_wait);
90813
90814 out_dput:
90815 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90816
90817 poll_wait(file, &proc_poll_wait, wait);
90818
90819 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90820 - seq->poll_event = atomic_read(&proc_poll_event);
90821 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90822 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90823 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90824 }
90825
90826 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90827 return ret;
90828
90829 seq = file->private_data;
90830 - seq->poll_event = atomic_read(&proc_poll_event);
90831 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90832 return 0;
90833 }
90834
90835 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90836 (frontswap_map) ? "FS" : "");
90837
90838 mutex_unlock(&swapon_mutex);
90839 - atomic_inc(&proc_poll_event);
90840 + atomic_inc_unchecked(&proc_poll_event);
90841 wake_up_interruptible(&proc_poll_wait);
90842
90843 if (S_ISREG(inode->i_mode))
90844 diff --git a/mm/util.c b/mm/util.c
90845 index 7441c41..c3de793 100644
90846 --- a/mm/util.c
90847 +++ b/mm/util.c
90848 @@ -294,6 +294,12 @@ done:
90849 void arch_pick_mmap_layout(struct mm_struct *mm)
90850 {
90851 mm->mmap_base = TASK_UNMAPPED_BASE;
90852 +
90853 +#ifdef CONFIG_PAX_RANDMMAP
90854 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90855 + mm->mmap_base += mm->delta_mmap;
90856 +#endif
90857 +
90858 mm->get_unmapped_area = arch_get_unmapped_area;
90859 }
90860 #endif
90861 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90862 index 13a5495..6707d97 100644
90863 --- a/mm/vmalloc.c
90864 +++ b/mm/vmalloc.c
90865 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90866
90867 pte = pte_offset_kernel(pmd, addr);
90868 do {
90869 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90870 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90871 +
90872 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90873 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90874 + BUG_ON(!pte_exec(*pte));
90875 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90876 + continue;
90877 + }
90878 +#endif
90879 +
90880 + {
90881 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90882 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90883 + }
90884 } while (pte++, addr += PAGE_SIZE, addr != end);
90885 }
90886
90887 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90888 pte = pte_alloc_kernel(pmd, addr);
90889 if (!pte)
90890 return -ENOMEM;
90891 +
90892 + pax_open_kernel();
90893 do {
90894 struct page *page = pages[*nr];
90895
90896 - if (WARN_ON(!pte_none(*pte)))
90897 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90898 + if (pgprot_val(prot) & _PAGE_NX)
90899 +#endif
90900 +
90901 + if (!pte_none(*pte)) {
90902 + pax_close_kernel();
90903 + WARN_ON(1);
90904 return -EBUSY;
90905 - if (WARN_ON(!page))
90906 + }
90907 + if (!page) {
90908 + pax_close_kernel();
90909 + WARN_ON(1);
90910 return -ENOMEM;
90911 + }
90912 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90913 (*nr)++;
90914 } while (pte++, addr += PAGE_SIZE, addr != end);
90915 + pax_close_kernel();
90916 return 0;
90917 }
90918
90919 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90920 pmd_t *pmd;
90921 unsigned long next;
90922
90923 - pmd = pmd_alloc(&init_mm, pud, addr);
90924 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90925 if (!pmd)
90926 return -ENOMEM;
90927 do {
90928 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90929 pud_t *pud;
90930 unsigned long next;
90931
90932 - pud = pud_alloc(&init_mm, pgd, addr);
90933 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90934 if (!pud)
90935 return -ENOMEM;
90936 do {
90937 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90938 if (addr >= MODULES_VADDR && addr < MODULES_END)
90939 return 1;
90940 #endif
90941 +
90942 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90943 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90944 + return 1;
90945 +#endif
90946 +
90947 return is_vmalloc_addr(x);
90948 }
90949
90950 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90951
90952 if (!pgd_none(*pgd)) {
90953 pud_t *pud = pud_offset(pgd, addr);
90954 +#ifdef CONFIG_X86
90955 + if (!pud_large(*pud))
90956 +#endif
90957 if (!pud_none(*pud)) {
90958 pmd_t *pmd = pmd_offset(pud, addr);
90959 +#ifdef CONFIG_X86
90960 + if (!pmd_large(*pmd))
90961 +#endif
90962 if (!pmd_none(*pmd)) {
90963 pte_t *ptep, pte;
90964
90965 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90966 * Allocate a region of KVA of the specified size and alignment, within the
90967 * vstart and vend.
90968 */
90969 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90970 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90971 unsigned long align,
90972 unsigned long vstart, unsigned long vend,
90973 int node, gfp_t gfp_mask)
90974 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90975 struct vm_struct *area;
90976
90977 BUG_ON(in_interrupt());
90978 +
90979 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90980 + if (flags & VM_KERNEXEC) {
90981 + if (start != VMALLOC_START || end != VMALLOC_END)
90982 + return NULL;
90983 + start = (unsigned long)MODULES_EXEC_VADDR;
90984 + end = (unsigned long)MODULES_EXEC_END;
90985 + }
90986 +#endif
90987 +
90988 if (flags & VM_IOREMAP)
90989 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90990
90991 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90992 if (count > totalram_pages)
90993 return NULL;
90994
90995 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90996 + if (!(pgprot_val(prot) & _PAGE_NX))
90997 + flags |= VM_KERNEXEC;
90998 +#endif
90999 +
91000 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
91001 __builtin_return_address(0));
91002 if (!area)
91003 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
91004 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
91005 goto fail;
91006
91007 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91008 + if (!(pgprot_val(prot) & _PAGE_NX))
91009 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
91010 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
91011 + else
91012 +#endif
91013 +
91014 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
91015 start, end, node, gfp_mask, caller);
91016 if (!area)
91017 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
91018 * For tight control over page level allocator and protection flags
91019 * use __vmalloc() instead.
91020 */
91021 -
91022 void *vmalloc_exec(unsigned long size)
91023 {
91024 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
91025 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
91026 NUMA_NO_NODE, __builtin_return_address(0));
91027 }
91028
91029 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
91030 {
91031 struct vm_struct *area;
91032
91033 + BUG_ON(vma->vm_mirror);
91034 +
91035 size = PAGE_ALIGN(size);
91036
91037 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
91038 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
91039 v->addr, v->addr + v->size, v->size);
91040
91041 if (v->caller)
91042 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91043 + seq_printf(m, " %pK", v->caller);
91044 +#else
91045 seq_printf(m, " %pS", v->caller);
91046 +#endif
91047
91048 if (v->nr_pages)
91049 seq_printf(m, " pages=%d", v->nr_pages);
91050 diff --git a/mm/vmstat.c b/mm/vmstat.c
91051 index 20c2ef4..15e7ab7 100644
91052 --- a/mm/vmstat.c
91053 +++ b/mm/vmstat.c
91054 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
91055 *
91056 * vm_stat contains the global counters
91057 */
91058 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91059 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91060 EXPORT_SYMBOL(vm_stat);
91061
91062 #ifdef CONFIG_SMP
91063 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
91064 v = p->vm_stat_diff[i];
91065 p->vm_stat_diff[i] = 0;
91066 local_irq_restore(flags);
91067 - atomic_long_add(v, &zone->vm_stat[i]);
91068 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91069 global_diff[i] += v;
91070 #ifdef CONFIG_NUMA
91071 /* 3 seconds idle till flush */
91072 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
91073
91074 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
91075 if (global_diff[i])
91076 - atomic_long_add(global_diff[i], &vm_stat[i]);
91077 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
91078 }
91079
91080 /*
91081 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
91082 if (pset->vm_stat_diff[i]) {
91083 int v = pset->vm_stat_diff[i];
91084 pset->vm_stat_diff[i] = 0;
91085 - atomic_long_add(v, &zone->vm_stat[i]);
91086 - atomic_long_add(v, &vm_stat[i]);
91087 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91088 + atomic_long_add_unchecked(v, &vm_stat[i]);
91089 }
91090 }
91091 #endif
91092 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
91093 start_cpu_timer(cpu);
91094 #endif
91095 #ifdef CONFIG_PROC_FS
91096 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
91097 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
91098 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
91099 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
91100 + {
91101 + mode_t gr_mode = S_IRUGO;
91102 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
91103 + gr_mode = S_IRUSR;
91104 +#endif
91105 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
91106 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
91107 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
91108 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
91109 +#else
91110 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
91111 +#endif
91112 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
91113 + }
91114 #endif
91115 return 0;
91116 }
91117 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
91118 index 2fb2d88..8c06e40 100644
91119 --- a/net/8021q/vlan.c
91120 +++ b/net/8021q/vlan.c
91121 @@ -469,7 +469,7 @@ out:
91122 return NOTIFY_DONE;
91123 }
91124
91125 -static struct notifier_block vlan_notifier_block __read_mostly = {
91126 +static struct notifier_block vlan_notifier_block = {
91127 .notifier_call = vlan_device_event,
91128 };
91129
91130 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
91131 err = -EPERM;
91132 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
91133 break;
91134 - if ((args.u.name_type >= 0) &&
91135 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
91136 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
91137 struct vlan_net *vn;
91138
91139 vn = net_generic(net, vlan_net_id);
91140 diff --git a/net/9p/mod.c b/net/9p/mod.c
91141 index 6ab36ae..6f1841b 100644
91142 --- a/net/9p/mod.c
91143 +++ b/net/9p/mod.c
91144 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
91145 void v9fs_register_trans(struct p9_trans_module *m)
91146 {
91147 spin_lock(&v9fs_trans_lock);
91148 - list_add_tail(&m->list, &v9fs_trans_list);
91149 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
91150 spin_unlock(&v9fs_trans_lock);
91151 }
91152 EXPORT_SYMBOL(v9fs_register_trans);
91153 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
91154 void v9fs_unregister_trans(struct p9_trans_module *m)
91155 {
91156 spin_lock(&v9fs_trans_lock);
91157 - list_del_init(&m->list);
91158 + pax_list_del_init((struct list_head *)&m->list);
91159 spin_unlock(&v9fs_trans_lock);
91160 }
91161 EXPORT_SYMBOL(v9fs_unregister_trans);
91162 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
91163 index 3ffda1b..fceac96 100644
91164 --- a/net/9p/trans_fd.c
91165 +++ b/net/9p/trans_fd.c
91166 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
91167 oldfs = get_fs();
91168 set_fs(get_ds());
91169 /* The cast to a user pointer is valid due to the set_fs() */
91170 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
91171 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
91172 set_fs(oldfs);
91173
91174 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
91175 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
91176 index 876fbe8..8bbea9f 100644
91177 --- a/net/atm/atm_misc.c
91178 +++ b/net/atm/atm_misc.c
91179 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
91180 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
91181 return 1;
91182 atm_return(vcc, truesize);
91183 - atomic_inc(&vcc->stats->rx_drop);
91184 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91185 return 0;
91186 }
91187 EXPORT_SYMBOL(atm_charge);
91188 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
91189 }
91190 }
91191 atm_return(vcc, guess);
91192 - atomic_inc(&vcc->stats->rx_drop);
91193 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91194 return NULL;
91195 }
91196 EXPORT_SYMBOL(atm_alloc_charge);
91197 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
91198
91199 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91200 {
91201 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91202 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91203 __SONET_ITEMS
91204 #undef __HANDLE_ITEM
91205 }
91206 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
91207
91208 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91209 {
91210 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91211 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
91212 __SONET_ITEMS
91213 #undef __HANDLE_ITEM
91214 }
91215 diff --git a/net/atm/lec.h b/net/atm/lec.h
91216 index 4149db1..f2ab682 100644
91217 --- a/net/atm/lec.h
91218 +++ b/net/atm/lec.h
91219 @@ -48,7 +48,7 @@ struct lane2_ops {
91220 const u8 *tlvs, u32 sizeoftlvs);
91221 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
91222 const u8 *tlvs, u32 sizeoftlvs);
91223 -};
91224 +} __no_const;
91225
91226 /*
91227 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
91228 diff --git a/net/atm/proc.c b/net/atm/proc.c
91229 index bbb6461..cf04016 100644
91230 --- a/net/atm/proc.c
91231 +++ b/net/atm/proc.c
91232 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
91233 const struct k_atm_aal_stats *stats)
91234 {
91235 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
91236 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
91237 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
91238 - atomic_read(&stats->rx_drop));
91239 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
91240 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
91241 + atomic_read_unchecked(&stats->rx_drop));
91242 }
91243
91244 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
91245 diff --git a/net/atm/resources.c b/net/atm/resources.c
91246 index 0447d5d..3cf4728 100644
91247 --- a/net/atm/resources.c
91248 +++ b/net/atm/resources.c
91249 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
91250 static void copy_aal_stats(struct k_atm_aal_stats *from,
91251 struct atm_aal_stats *to)
91252 {
91253 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91254 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91255 __AAL_STAT_ITEMS
91256 #undef __HANDLE_ITEM
91257 }
91258 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
91259 static void subtract_aal_stats(struct k_atm_aal_stats *from,
91260 struct atm_aal_stats *to)
91261 {
91262 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91263 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
91264 __AAL_STAT_ITEMS
91265 #undef __HANDLE_ITEM
91266 }
91267 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
91268 index 919a5ce..cc6b444 100644
91269 --- a/net/ax25/sysctl_net_ax25.c
91270 +++ b/net/ax25/sysctl_net_ax25.c
91271 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
91272 {
91273 char path[sizeof("net/ax25/") + IFNAMSIZ];
91274 int k;
91275 - struct ctl_table *table;
91276 + ctl_table_no_const *table;
91277
91278 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
91279 if (!table)
91280 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
91281 index 62da527..aa27535 100644
91282 --- a/net/batman-adv/bat_iv_ogm.c
91283 +++ b/net/batman-adv/bat_iv_ogm.c
91284 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
91285
91286 /* randomize initial seqno to avoid collision */
91287 get_random_bytes(&random_seqno, sizeof(random_seqno));
91288 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91289 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91290
91291 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
91292 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
91293 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
91294 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
91295
91296 /* change sequence number to network order */
91297 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
91298 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
91299 batadv_ogm_packet->seqno = htonl(seqno);
91300 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
91301 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
91302
91303 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
91304 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
91305 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
91306 return;
91307
91308 /* could be changed by schedule_own_packet() */
91309 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
91310 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
91311
91312 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
91313 has_directlink_flag = 1;
91314 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
91315 index c478e6b..469fd2f 100644
91316 --- a/net/batman-adv/hard-interface.c
91317 +++ b/net/batman-adv/hard-interface.c
91318 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
91319 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
91320 dev_add_pack(&hard_iface->batman_adv_ptype);
91321
91322 - atomic_set(&hard_iface->frag_seqno, 1);
91323 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
91324 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
91325 hard_iface->net_dev->name);
91326
91327 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
91328 index 33b6144..3212ac5 100644
91329 --- a/net/batman-adv/soft-interface.c
91330 +++ b/net/batman-adv/soft-interface.c
91331 @@ -261,7 +261,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
91332 primary_if->net_dev->dev_addr, ETH_ALEN);
91333
91334 /* set broadcast sequence number */
91335 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
91336 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
91337 bcast_packet->seqno = htonl(seqno);
91338
91339 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
91340 @@ -481,7 +481,7 @@ static int batadv_softif_init_late(struct net_device *dev)
91341 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
91342
91343 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
91344 - atomic_set(&bat_priv->bcast_seqno, 1);
91345 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
91346 atomic_set(&bat_priv->tt.vn, 0);
91347 atomic_set(&bat_priv->tt.local_changes, 0);
91348 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
91349 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
91350 index b2c94e1..3d47e07 100644
91351 --- a/net/batman-adv/types.h
91352 +++ b/net/batman-adv/types.h
91353 @@ -51,7 +51,7 @@
91354 struct batadv_hard_iface_bat_iv {
91355 unsigned char *ogm_buff;
91356 int ogm_buff_len;
91357 - atomic_t ogm_seqno;
91358 + atomic_unchecked_t ogm_seqno;
91359 };
91360
91361 /**
91362 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
91363 int16_t if_num;
91364 char if_status;
91365 struct net_device *net_dev;
91366 - atomic_t frag_seqno;
91367 + atomic_unchecked_t frag_seqno;
91368 uint8_t num_bcasts;
91369 struct kobject *hardif_obj;
91370 atomic_t refcount;
91371 @@ -560,7 +560,7 @@ struct batadv_priv {
91372 #ifdef CONFIG_BATMAN_ADV_DEBUG
91373 atomic_t log_level;
91374 #endif
91375 - atomic_t bcast_seqno;
91376 + atomic_unchecked_t bcast_seqno;
91377 atomic_t bcast_queue_left;
91378 atomic_t batman_queue_left;
91379 char num_ifaces;
91380 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
91381 index 857e1b8..5ad07b2 100644
91382 --- a/net/batman-adv/unicast.c
91383 +++ b/net/batman-adv/unicast.c
91384 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
91385 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
91386 frag2->flags = large_tail;
91387
91388 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91389 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91390 frag1->seqno = htons(seqno - 1);
91391 frag2->seqno = htons(seqno);
91392
91393 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
91394 index 9bd7d95..6c4884f 100644
91395 --- a/net/bluetooth/hci_sock.c
91396 +++ b/net/bluetooth/hci_sock.c
91397 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
91398 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
91399 }
91400
91401 - len = min_t(unsigned int, len, sizeof(uf));
91402 + len = min((size_t)len, sizeof(uf));
91403 if (copy_from_user(&uf, optval, len)) {
91404 err = -EFAULT;
91405 break;
91406 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91407 index 8c3499b..2661c6a 100644
91408 --- a/net/bluetooth/l2cap_core.c
91409 +++ b/net/bluetooth/l2cap_core.c
91410 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91411 break;
91412
91413 case L2CAP_CONF_RFC:
91414 - if (olen == sizeof(rfc))
91415 - memcpy(&rfc, (void *)val, olen);
91416 + if (olen != sizeof(rfc))
91417 + break;
91418 +
91419 + memcpy(&rfc, (void *)val, olen);
91420
91421 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
91422 rfc.mode != chan->mode)
91423 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
91424 index 0098af8..fb5a31f 100644
91425 --- a/net/bluetooth/l2cap_sock.c
91426 +++ b/net/bluetooth/l2cap_sock.c
91427 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91428 struct sock *sk = sock->sk;
91429 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
91430 struct l2cap_options opts;
91431 - int len, err = 0;
91432 + int err = 0;
91433 + size_t len = optlen;
91434 u32 opt;
91435
91436 BT_DBG("sk %p", sk);
91437 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91438 opts.max_tx = chan->max_tx;
91439 opts.txwin_size = chan->tx_win;
91440
91441 - len = min_t(unsigned int, sizeof(opts), optlen);
91442 + len = min(sizeof(opts), len);
91443 if (copy_from_user((char *) &opts, optval, len)) {
91444 err = -EFAULT;
91445 break;
91446 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91447 struct bt_security sec;
91448 struct bt_power pwr;
91449 struct l2cap_conn *conn;
91450 - int len, err = 0;
91451 + int err = 0;
91452 + size_t len = optlen;
91453 u32 opt;
91454
91455 BT_DBG("sk %p", sk);
91456 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91457
91458 sec.level = BT_SECURITY_LOW;
91459
91460 - len = min_t(unsigned int, sizeof(sec), optlen);
91461 + len = min(sizeof(sec), len);
91462 if (copy_from_user((char *) &sec, optval, len)) {
91463 err = -EFAULT;
91464 break;
91465 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91466
91467 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
91468
91469 - len = min_t(unsigned int, sizeof(pwr), optlen);
91470 + len = min(sizeof(pwr), len);
91471 if (copy_from_user((char *) &pwr, optval, len)) {
91472 err = -EFAULT;
91473 break;
91474 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
91475 index 30b3721..c1bd0a0 100644
91476 --- a/net/bluetooth/rfcomm/sock.c
91477 +++ b/net/bluetooth/rfcomm/sock.c
91478 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91479 struct sock *sk = sock->sk;
91480 struct bt_security sec;
91481 int err = 0;
91482 - size_t len;
91483 + size_t len = optlen;
91484 u32 opt;
91485
91486 BT_DBG("sk %p", sk);
91487 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91488
91489 sec.level = BT_SECURITY_LOW;
91490
91491 - len = min_t(unsigned int, sizeof(sec), optlen);
91492 + len = min(sizeof(sec), len);
91493 if (copy_from_user((char *) &sec, optval, len)) {
91494 err = -EFAULT;
91495 break;
91496 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
91497 index b6e44ad..5b0d514 100644
91498 --- a/net/bluetooth/rfcomm/tty.c
91499 +++ b/net/bluetooth/rfcomm/tty.c
91500 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
91501 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
91502
91503 spin_lock_irqsave(&dev->port.lock, flags);
91504 - if (dev->port.count > 0) {
91505 + if (atomic_read(&dev->port.count) > 0) {
91506 spin_unlock_irqrestore(&dev->port.lock, flags);
91507 return;
91508 }
91509 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
91510 return -ENODEV;
91511
91512 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91513 - dev->channel, dev->port.count);
91514 + dev->channel, atomic_read(&dev->port.count));
91515
91516 spin_lock_irqsave(&dev->port.lock, flags);
91517 - if (++dev->port.count > 1) {
91518 + if (atomic_inc_return(&dev->port.count) > 1) {
91519 spin_unlock_irqrestore(&dev->port.lock, flags);
91520 return 0;
91521 }
91522 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91523 return;
91524
91525 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91526 - dev->port.count);
91527 + atomic_read(&dev->port.count));
91528
91529 spin_lock_irqsave(&dev->port.lock, flags);
91530 - if (!--dev->port.count) {
91531 + if (!atomic_dec_return(&dev->port.count)) {
91532 spin_unlock_irqrestore(&dev->port.lock, flags);
91533 if (dev->tty_dev->parent)
91534 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91535 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
91536 index 5180938..7c470c3 100644
91537 --- a/net/bridge/netfilter/ebt_ulog.c
91538 +++ b/net/bridge/netfilter/ebt_ulog.c
91539 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91540 ub->qlen++;
91541
91542 pm = nlmsg_data(nlh);
91543 + memset(pm, 0, sizeof(*pm));
91544
91545 /* Fill in the ulog data */
91546 pm->version = EBT_ULOG_VERSION;
91547 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91548 pm->hook = hooknr;
91549 if (uloginfo->prefix != NULL)
91550 strcpy(pm->prefix, uloginfo->prefix);
91551 - else
91552 - *(pm->prefix) = '\0';
91553
91554 if (in) {
91555 strcpy(pm->physindev, in->name);
91556 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91557 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
91558 else
91559 strcpy(pm->indev, in->name);
91560 - } else
91561 - pm->indev[0] = pm->physindev[0] = '\0';
91562 + }
91563
91564 if (out) {
91565 /* If out exists, then out is a bridge port */
91566 strcpy(pm->physoutdev, out->name);
91567 /* rcu_read_lock()ed by nf_hook_slow */
91568 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
91569 - } else
91570 - pm->outdev[0] = pm->physoutdev[0] = '\0';
91571 + }
91572
91573 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
91574 BUG();
91575 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91576 index ac78024..161a80c 100644
91577 --- a/net/bridge/netfilter/ebtables.c
91578 +++ b/net/bridge/netfilter/ebtables.c
91579 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91580 tmp.valid_hooks = t->table->valid_hooks;
91581 }
91582 mutex_unlock(&ebt_mutex);
91583 - if (copy_to_user(user, &tmp, *len) != 0){
91584 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91585 BUGPRINT("c2u Didn't work\n");
91586 ret = -EFAULT;
91587 break;
91588 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91589 goto out;
91590 tmp.valid_hooks = t->valid_hooks;
91591
91592 - if (copy_to_user(user, &tmp, *len) != 0) {
91593 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91594 ret = -EFAULT;
91595 break;
91596 }
91597 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91598 tmp.entries_size = t->table->entries_size;
91599 tmp.valid_hooks = t->table->valid_hooks;
91600
91601 - if (copy_to_user(user, &tmp, *len) != 0) {
91602 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91603 ret = -EFAULT;
91604 break;
91605 }
91606 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91607 index 0f45522..dab651f 100644
91608 --- a/net/caif/cfctrl.c
91609 +++ b/net/caif/cfctrl.c
91610 @@ -10,6 +10,7 @@
91611 #include <linux/spinlock.h>
91612 #include <linux/slab.h>
91613 #include <linux/pkt_sched.h>
91614 +#include <linux/sched.h>
91615 #include <net/caif/caif_layer.h>
91616 #include <net/caif/cfpkt.h>
91617 #include <net/caif/cfctrl.h>
91618 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91619 memset(&dev_info, 0, sizeof(dev_info));
91620 dev_info.id = 0xff;
91621 cfsrvl_init(&this->serv, 0, &dev_info, false);
91622 - atomic_set(&this->req_seq_no, 1);
91623 - atomic_set(&this->rsp_seq_no, 1);
91624 + atomic_set_unchecked(&this->req_seq_no, 1);
91625 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91626 this->serv.layer.receive = cfctrl_recv;
91627 sprintf(this->serv.layer.name, "ctrl");
91628 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91629 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91630 struct cfctrl_request_info *req)
91631 {
91632 spin_lock_bh(&ctrl->info_list_lock);
91633 - atomic_inc(&ctrl->req_seq_no);
91634 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91635 + atomic_inc_unchecked(&ctrl->req_seq_no);
91636 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91637 list_add_tail(&req->list, &ctrl->list);
91638 spin_unlock_bh(&ctrl->info_list_lock);
91639 }
91640 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91641 if (p != first)
91642 pr_warn("Requests are not received in order\n");
91643
91644 - atomic_set(&ctrl->rsp_seq_no,
91645 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91646 p->sequence_no);
91647 list_del(&p->list);
91648 goto out;
91649 diff --git a/net/can/af_can.c b/net/can/af_can.c
91650 index 3ab8dd2..b9aef13 100644
91651 --- a/net/can/af_can.c
91652 +++ b/net/can/af_can.c
91653 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91654 };
91655
91656 /* notifier block for netdevice event */
91657 -static struct notifier_block can_netdev_notifier __read_mostly = {
91658 +static struct notifier_block can_netdev_notifier = {
91659 .notifier_call = can_notifier,
91660 };
91661
91662 diff --git a/net/can/gw.c b/net/can/gw.c
91663 index 2f291f9..98c986a 100644
91664 --- a/net/can/gw.c
91665 +++ b/net/can/gw.c
91666 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91667 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91668
91669 static HLIST_HEAD(cgw_list);
91670 -static struct notifier_block notifier;
91671
91672 static struct kmem_cache *cgw_cache __read_mostly;
91673
91674 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91675 return err;
91676 }
91677
91678 +static struct notifier_block notifier = {
91679 + .notifier_call = cgw_notifier
91680 +};
91681 +
91682 static __init int cgw_module_init(void)
91683 {
91684 /* sanitize given module parameter */
91685 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91686 return -ENOMEM;
91687
91688 /* set notifier */
91689 - notifier.notifier_call = cgw_notifier;
91690 register_netdevice_notifier(&notifier);
91691
91692 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91693 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91694 index eb0a46a..5f3bae8 100644
91695 --- a/net/ceph/messenger.c
91696 +++ b/net/ceph/messenger.c
91697 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91698 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91699
91700 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91701 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91702 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91703
91704 static struct page *zero_page; /* used in certain error cases */
91705
91706 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91707 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91708 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91709
91710 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91711 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91712 s = addr_str[i];
91713
91714 switch (ss->ss_family) {
91715 diff --git a/net/compat.c b/net/compat.c
91716 index 8903258..24e30e5 100644
91717 --- a/net/compat.c
91718 +++ b/net/compat.c
91719 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91720 return -EFAULT;
91721 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
91722 return -EINVAL;
91723 - kmsg->msg_name = compat_ptr(tmp1);
91724 - kmsg->msg_iov = compat_ptr(tmp2);
91725 - kmsg->msg_control = compat_ptr(tmp3);
91726 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91727 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91728 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91729 return 0;
91730 }
91731
91732 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91733
91734 if (kern_msg->msg_namelen) {
91735 if (mode == VERIFY_READ) {
91736 - int err = move_addr_to_kernel(kern_msg->msg_name,
91737 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91738 kern_msg->msg_namelen,
91739 kern_address);
91740 if (err < 0)
91741 @@ -98,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91742 kern_msg->msg_name = NULL;
91743
91744 tot_len = iov_from_user_compat_to_kern(kern_iov,
91745 - (struct compat_iovec __user *)kern_msg->msg_iov,
91746 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91747 kern_msg->msg_iovlen);
91748 if (tot_len >= 0)
91749 kern_msg->msg_iov = kern_iov;
91750 @@ -118,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91751
91752 #define CMSG_COMPAT_FIRSTHDR(msg) \
91753 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91754 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91755 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91756 (struct compat_cmsghdr __user *)NULL)
91757
91758 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91759 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91760 (ucmlen) <= (unsigned long) \
91761 ((mhdr)->msg_controllen - \
91762 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91763 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91764
91765 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91766 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91767 {
91768 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91769 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91770 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91771 msg->msg_controllen)
91772 return NULL;
91773 return (struct compat_cmsghdr __user *)ptr;
91774 @@ -221,7 +221,7 @@ Efault:
91775
91776 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91777 {
91778 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91779 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91780 struct compat_cmsghdr cmhdr;
91781 struct compat_timeval ctv;
91782 struct compat_timespec cts[3];
91783 @@ -277,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91784
91785 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91786 {
91787 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91788 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91789 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91790 int fdnum = scm->fp->count;
91791 struct file **fp = scm->fp->fp;
91792 @@ -365,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91793 return -EFAULT;
91794 old_fs = get_fs();
91795 set_fs(KERNEL_DS);
91796 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91797 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91798 set_fs(old_fs);
91799
91800 return err;
91801 @@ -426,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91802 len = sizeof(ktime);
91803 old_fs = get_fs();
91804 set_fs(KERNEL_DS);
91805 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91806 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91807 set_fs(old_fs);
91808
91809 if (!err) {
91810 @@ -569,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91811 case MCAST_JOIN_GROUP:
91812 case MCAST_LEAVE_GROUP:
91813 {
91814 - struct compat_group_req __user *gr32 = (void *)optval;
91815 + struct compat_group_req __user *gr32 = (void __user *)optval;
91816 struct group_req __user *kgr =
91817 compat_alloc_user_space(sizeof(struct group_req));
91818 u32 interface;
91819 @@ -590,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91820 case MCAST_BLOCK_SOURCE:
91821 case MCAST_UNBLOCK_SOURCE:
91822 {
91823 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91824 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91825 struct group_source_req __user *kgsr = compat_alloc_user_space(
91826 sizeof(struct group_source_req));
91827 u32 interface;
91828 @@ -611,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91829 }
91830 case MCAST_MSFILTER:
91831 {
91832 - struct compat_group_filter __user *gf32 = (void *)optval;
91833 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91834 struct group_filter __user *kgf;
91835 u32 interface, fmode, numsrc;
91836
91837 @@ -649,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91838 char __user *optval, int __user *optlen,
91839 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91840 {
91841 - struct compat_group_filter __user *gf32 = (void *)optval;
91842 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91843 struct group_filter __user *kgf;
91844 int __user *koptlen;
91845 u32 interface, fmode, numsrc;
91846 @@ -807,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91847
91848 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91849 return -EINVAL;
91850 - if (copy_from_user(a, args, nas[call]))
91851 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91852 return -EFAULT;
91853 a0 = a[0];
91854 a1 = a[1];
91855 diff --git a/net/core/datagram.c b/net/core/datagram.c
91856 index 8ab48cd..57b1a80 100644
91857 --- a/net/core/datagram.c
91858 +++ b/net/core/datagram.c
91859 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91860 }
91861
91862 kfree_skb(skb);
91863 - atomic_inc(&sk->sk_drops);
91864 + atomic_inc_unchecked(&sk->sk_drops);
91865 sk_mem_reclaim_partial(sk);
91866
91867 return err;
91868 diff --git a/net/core/dev.c b/net/core/dev.c
91869 index 26755dd..2a232de 100644
91870 --- a/net/core/dev.c
91871 +++ b/net/core/dev.c
91872 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91873 {
91874 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91875 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91876 - atomic_long_inc(&dev->rx_dropped);
91877 + atomic_long_inc_unchecked(&dev->rx_dropped);
91878 kfree_skb(skb);
91879 return NET_RX_DROP;
91880 }
91881 }
91882
91883 if (unlikely(!is_skb_forwardable(dev, skb))) {
91884 - atomic_long_inc(&dev->rx_dropped);
91885 + atomic_long_inc_unchecked(&dev->rx_dropped);
91886 kfree_skb(skb);
91887 return NET_RX_DROP;
91888 }
91889 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91890
91891 struct dev_gso_cb {
91892 void (*destructor)(struct sk_buff *skb);
91893 -};
91894 +} __no_const;
91895
91896 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91897
91898 @@ -3206,7 +3206,7 @@ enqueue:
91899
91900 local_irq_restore(flags);
91901
91902 - atomic_long_inc(&skb->dev->rx_dropped);
91903 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91904 kfree_skb(skb);
91905 return NET_RX_DROP;
91906 }
91907 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91908 }
91909 EXPORT_SYMBOL(netif_rx_ni);
91910
91911 -static void net_tx_action(struct softirq_action *h)
91912 +static __latent_entropy void net_tx_action(void)
91913 {
91914 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91915
91916 @@ -3612,7 +3612,7 @@ ncls:
91917 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91918 } else {
91919 drop:
91920 - atomic_long_inc(&skb->dev->rx_dropped);
91921 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91922 kfree_skb(skb);
91923 /* Jamal, now you will not able to escape explaining
91924 * me how you were going to use this. :-)
91925 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91926 }
91927 EXPORT_SYMBOL(netif_napi_del);
91928
91929 -static void net_rx_action(struct softirq_action *h)
91930 +static __latent_entropy void net_rx_action(void)
91931 {
91932 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91933 unsigned long time_limit = jiffies + 2;
91934 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91935 } else {
91936 netdev_stats_to_stats64(storage, &dev->stats);
91937 }
91938 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91939 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91940 return storage;
91941 }
91942 EXPORT_SYMBOL(dev_get_stats);
91943 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91944 index 5b7d0e1..cb960fc 100644
91945 --- a/net/core/dev_ioctl.c
91946 +++ b/net/core/dev_ioctl.c
91947 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91948 if (no_module && capable(CAP_NET_ADMIN))
91949 no_module = request_module("netdev-%s", name);
91950 if (no_module && capable(CAP_SYS_MODULE)) {
91951 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91952 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91953 +#else
91954 if (!request_module("%s", name))
91955 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91956 name);
91957 +#endif
91958 }
91959 }
91960 EXPORT_SYMBOL(dev_load);
91961 diff --git a/net/core/flow.c b/net/core/flow.c
91962 index dfa602c..3103d88 100644
91963 --- a/net/core/flow.c
91964 +++ b/net/core/flow.c
91965 @@ -61,7 +61,7 @@ struct flow_cache {
91966 struct timer_list rnd_timer;
91967 };
91968
91969 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91970 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91971 EXPORT_SYMBOL(flow_cache_genid);
91972 static struct flow_cache flow_cache_global;
91973 static struct kmem_cache *flow_cachep __read_mostly;
91974 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91975
91976 static int flow_entry_valid(struct flow_cache_entry *fle)
91977 {
91978 - if (atomic_read(&flow_cache_genid) != fle->genid)
91979 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91980 return 0;
91981 if (fle->object && !fle->object->ops->check(fle->object))
91982 return 0;
91983 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91984 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91985 fcp->hash_count++;
91986 }
91987 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91988 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91989 flo = fle->object;
91990 if (!flo)
91991 goto ret_object;
91992 @@ -279,7 +279,7 @@ nocache:
91993 }
91994 flo = resolver(net, key, family, dir, flo, ctx);
91995 if (fle) {
91996 - fle->genid = atomic_read(&flow_cache_genid);
91997 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91998 if (!IS_ERR(flo))
91999 fle->object = flo;
92000 else
92001 diff --git a/net/core/iovec.c b/net/core/iovec.c
92002 index de178e4..1dabd8b 100644
92003 --- a/net/core/iovec.c
92004 +++ b/net/core/iovec.c
92005 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92006 if (m->msg_namelen) {
92007 if (mode == VERIFY_READ) {
92008 void __user *namep;
92009 - namep = (void __user __force *) m->msg_name;
92010 + namep = (void __force_user *) m->msg_name;
92011 err = move_addr_to_kernel(namep, m->msg_namelen,
92012 address);
92013 if (err < 0)
92014 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92015 }
92016
92017 size = m->msg_iovlen * sizeof(struct iovec);
92018 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
92019 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
92020 return -EFAULT;
92021
92022 m->msg_iov = iov;
92023 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
92024 index 60533db..14842cc 100644
92025 --- a/net/core/neighbour.c
92026 +++ b/net/core/neighbour.c
92027 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
92028 void __user *buffer, size_t *lenp, loff_t *ppos)
92029 {
92030 int size, ret;
92031 - struct ctl_table tmp = *ctl;
92032 + ctl_table_no_const tmp = *ctl;
92033
92034 tmp.extra1 = &zero;
92035 tmp.extra2 = &unres_qlen_max;
92036 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
92037 index 2bf8329..7960607 100644
92038 --- a/net/core/net-procfs.c
92039 +++ b/net/core/net-procfs.c
92040 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
92041 else
92042 seq_printf(seq, "%04x", ntohs(pt->type));
92043
92044 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92045 + seq_printf(seq, " %-8s %pf\n",
92046 + pt->dev ? pt->dev->name : "", NULL);
92047 +#else
92048 seq_printf(seq, " %-8s %pf\n",
92049 pt->dev ? pt->dev->name : "", pt->func);
92050 +#endif
92051 }
92052
92053 return 0;
92054 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
92055 index 981fed3..536af34 100644
92056 --- a/net/core/net-sysfs.c
92057 +++ b/net/core/net-sysfs.c
92058 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
92059 }
92060 EXPORT_SYMBOL(netdev_class_remove_file);
92061
92062 -int netdev_kobject_init(void)
92063 +int __init netdev_kobject_init(void)
92064 {
92065 kobj_ns_type_register(&net_ns_type_operations);
92066 return class_register(&net_class);
92067 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
92068 index f9765203..9feaef8 100644
92069 --- a/net/core/net_namespace.c
92070 +++ b/net/core/net_namespace.c
92071 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
92072 int error;
92073 LIST_HEAD(net_exit_list);
92074
92075 - list_add_tail(&ops->list, list);
92076 + pax_list_add_tail((struct list_head *)&ops->list, list);
92077 if (ops->init || (ops->id && ops->size)) {
92078 for_each_net(net) {
92079 error = ops_init(ops, net);
92080 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
92081
92082 out_undo:
92083 /* If I have an error cleanup all namespaces I initialized */
92084 - list_del(&ops->list);
92085 + pax_list_del((struct list_head *)&ops->list);
92086 ops_exit_list(ops, &net_exit_list);
92087 ops_free_list(ops, &net_exit_list);
92088 return error;
92089 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
92090 struct net *net;
92091 LIST_HEAD(net_exit_list);
92092
92093 - list_del(&ops->list);
92094 + pax_list_del((struct list_head *)&ops->list);
92095 for_each_net(net)
92096 list_add_tail(&net->exit_list, &net_exit_list);
92097 ops_exit_list(ops, &net_exit_list);
92098 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
92099 mutex_lock(&net_mutex);
92100 error = register_pernet_operations(&pernet_list, ops);
92101 if (!error && (first_device == &pernet_list))
92102 - first_device = &ops->list;
92103 + first_device = (struct list_head *)&ops->list;
92104 mutex_unlock(&net_mutex);
92105 return error;
92106 }
92107 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
92108 index fc75c9e..8c8e9be 100644
92109 --- a/net/core/netpoll.c
92110 +++ b/net/core/netpoll.c
92111 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92112 struct udphdr *udph;
92113 struct iphdr *iph;
92114 struct ethhdr *eth;
92115 - static atomic_t ip_ident;
92116 + static atomic_unchecked_t ip_ident;
92117 struct ipv6hdr *ip6h;
92118
92119 udp_len = len + sizeof(*udph);
92120 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92121 put_unaligned(0x45, (unsigned char *)iph);
92122 iph->tos = 0;
92123 put_unaligned(htons(ip_len), &(iph->tot_len));
92124 - iph->id = htons(atomic_inc_return(&ip_ident));
92125 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
92126 iph->frag_off = 0;
92127 iph->ttl = 64;
92128 iph->protocol = IPPROTO_UDP;
92129 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
92130 index ca198c1d1..125372f 100644
92131 --- a/net/core/rtnetlink.c
92132 +++ b/net/core/rtnetlink.c
92133 @@ -58,7 +58,7 @@ struct rtnl_link {
92134 rtnl_doit_func doit;
92135 rtnl_dumpit_func dumpit;
92136 rtnl_calcit_func calcit;
92137 -};
92138 +} __no_const;
92139
92140 static DEFINE_MUTEX(rtnl_mutex);
92141
92142 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
92143 if (rtnl_link_ops_get(ops->kind))
92144 return -EEXIST;
92145
92146 - if (!ops->dellink)
92147 - ops->dellink = unregister_netdevice_queue;
92148 + if (!ops->dellink) {
92149 + pax_open_kernel();
92150 + *(void **)&ops->dellink = unregister_netdevice_queue;
92151 + pax_close_kernel();
92152 + }
92153
92154 - list_add_tail(&ops->list, &link_ops);
92155 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
92156 return 0;
92157 }
92158 EXPORT_SYMBOL_GPL(__rtnl_link_register);
92159 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
92160 for_each_net(net) {
92161 __rtnl_kill_links(net, ops);
92162 }
92163 - list_del(&ops->list);
92164 + pax_list_del((struct list_head *)&ops->list);
92165 }
92166 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
92167
92168 diff --git a/net/core/scm.c b/net/core/scm.c
92169 index b4da80b..98d6bdb 100644
92170 --- a/net/core/scm.c
92171 +++ b/net/core/scm.c
92172 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
92173 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92174 {
92175 struct cmsghdr __user *cm
92176 - = (__force struct cmsghdr __user *)msg->msg_control;
92177 + = (struct cmsghdr __force_user *)msg->msg_control;
92178 struct cmsghdr cmhdr;
92179 int cmlen = CMSG_LEN(len);
92180 int err;
92181 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92182 err = -EFAULT;
92183 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
92184 goto out;
92185 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
92186 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
92187 goto out;
92188 cmlen = CMSG_SPACE(len);
92189 if (msg->msg_controllen < cmlen)
92190 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
92191 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92192 {
92193 struct cmsghdr __user *cm
92194 - = (__force struct cmsghdr __user*)msg->msg_control;
92195 + = (struct cmsghdr __force_user *)msg->msg_control;
92196
92197 int fdmax = 0;
92198 int fdnum = scm->fp->count;
92199 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92200 if (fdnum < fdmax)
92201 fdmax = fdnum;
92202
92203 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
92204 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
92205 i++, cmfptr++)
92206 {
92207 struct socket *sock;
92208 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
92209 index 2c3d0f5..f5a326f 100644
92210 --- a/net/core/skbuff.c
92211 +++ b/net/core/skbuff.c
92212 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
92213 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
92214 sizeof(struct sk_buff),
92215 0,
92216 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92217 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92218 + SLAB_NO_SANITIZE,
92219 NULL);
92220 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
92221 (2*sizeof(struct sk_buff)) +
92222 sizeof(atomic_t),
92223 0,
92224 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92225 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92226 + SLAB_NO_SANITIZE,
92227 NULL);
92228 }
92229
92230 diff --git a/net/core/sock.c b/net/core/sock.c
92231 index 8729d91..4a20427 100644
92232 --- a/net/core/sock.c
92233 +++ b/net/core/sock.c
92234 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92235 struct sk_buff_head *list = &sk->sk_receive_queue;
92236
92237 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
92238 - atomic_inc(&sk->sk_drops);
92239 + atomic_inc_unchecked(&sk->sk_drops);
92240 trace_sock_rcvqueue_full(sk, skb);
92241 return -ENOMEM;
92242 }
92243 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92244 return err;
92245
92246 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
92247 - atomic_inc(&sk->sk_drops);
92248 + atomic_inc_unchecked(&sk->sk_drops);
92249 return -ENOBUFS;
92250 }
92251
92252 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92253 skb_dst_force(skb);
92254
92255 spin_lock_irqsave(&list->lock, flags);
92256 - skb->dropcount = atomic_read(&sk->sk_drops);
92257 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
92258 __skb_queue_tail(list, skb);
92259 spin_unlock_irqrestore(&list->lock, flags);
92260
92261 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92262 skb->dev = NULL;
92263
92264 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
92265 - atomic_inc(&sk->sk_drops);
92266 + atomic_inc_unchecked(&sk->sk_drops);
92267 goto discard_and_relse;
92268 }
92269 if (nested)
92270 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92271 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
92272 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
92273 bh_unlock_sock(sk);
92274 - atomic_inc(&sk->sk_drops);
92275 + atomic_inc_unchecked(&sk->sk_drops);
92276 goto discard_and_relse;
92277 }
92278
92279 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92280 struct timeval tm;
92281 } v;
92282
92283 - int lv = sizeof(int);
92284 - int len;
92285 + unsigned int lv = sizeof(int);
92286 + unsigned int len;
92287
92288 if (get_user(len, optlen))
92289 return -EFAULT;
92290 - if (len < 0)
92291 + if (len > INT_MAX)
92292 return -EINVAL;
92293
92294 memset(&v, 0, sizeof(v));
92295 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92296
92297 case SO_PEERNAME:
92298 {
92299 - char address[128];
92300 + char address[_K_SS_MAXSIZE];
92301
92302 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
92303 return -ENOTCONN;
92304 - if (lv < len)
92305 + if (lv < len || sizeof address < len)
92306 return -EINVAL;
92307 if (copy_to_user(optval, address, len))
92308 return -EFAULT;
92309 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92310
92311 if (len > lv)
92312 len = lv;
92313 - if (copy_to_user(optval, &v, len))
92314 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
92315 return -EFAULT;
92316 lenout:
92317 if (put_user(len, optlen))
92318 @@ -2304,7 +2304,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
92319 */
92320 smp_wmb();
92321 atomic_set(&sk->sk_refcnt, 1);
92322 - atomic_set(&sk->sk_drops, 0);
92323 + atomic_set_unchecked(&sk->sk_drops, 0);
92324 }
92325 EXPORT_SYMBOL(sock_init_data);
92326
92327 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
92328 index a0e9cf6..ef7f9ed 100644
92329 --- a/net/core/sock_diag.c
92330 +++ b/net/core/sock_diag.c
92331 @@ -9,26 +9,33 @@
92332 #include <linux/inet_diag.h>
92333 #include <linux/sock_diag.h>
92334
92335 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
92336 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
92337 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
92338 static DEFINE_MUTEX(sock_diag_table_mutex);
92339
92340 int sock_diag_check_cookie(void *sk, __u32 *cookie)
92341 {
92342 +#ifndef CONFIG_GRKERNSEC_HIDESYM
92343 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
92344 cookie[1] != INET_DIAG_NOCOOKIE) &&
92345 ((u32)(unsigned long)sk != cookie[0] ||
92346 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
92347 return -ESTALE;
92348 else
92349 +#endif
92350 return 0;
92351 }
92352 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
92353
92354 void sock_diag_save_cookie(void *sk, __u32 *cookie)
92355 {
92356 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92357 + cookie[0] = 0;
92358 + cookie[1] = 0;
92359 +#else
92360 cookie[0] = (u32)(unsigned long)sk;
92361 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
92362 +#endif
92363 }
92364 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
92365
92366 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
92367 mutex_lock(&sock_diag_table_mutex);
92368 if (sock_diag_handlers[hndl->family])
92369 err = -EBUSY;
92370 - else
92371 + else {
92372 + pax_open_kernel();
92373 sock_diag_handlers[hndl->family] = hndl;
92374 + pax_close_kernel();
92375 + }
92376 mutex_unlock(&sock_diag_table_mutex);
92377
92378 return err;
92379 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
92380
92381 mutex_lock(&sock_diag_table_mutex);
92382 BUG_ON(sock_diag_handlers[family] != hnld);
92383 + pax_open_kernel();
92384 sock_diag_handlers[family] = NULL;
92385 + pax_close_kernel();
92386 mutex_unlock(&sock_diag_table_mutex);
92387 }
92388 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92389 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92390 index 31107ab..ae03d5a 100644
92391 --- a/net/core/sysctl_net_core.c
92392 +++ b/net/core/sysctl_net_core.c
92393 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92394 {
92395 unsigned int orig_size, size;
92396 int ret, i;
92397 - struct ctl_table tmp = {
92398 + ctl_table_no_const tmp = {
92399 .data = &size,
92400 .maxlen = sizeof(size),
92401 .mode = table->mode
92402 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
92403
92404 static __net_init int sysctl_core_net_init(struct net *net)
92405 {
92406 - struct ctl_table *tbl;
92407 + ctl_table_no_const *tbl = NULL;
92408
92409 net->core.sysctl_somaxconn = SOMAXCONN;
92410
92411 - tbl = netns_core_table;
92412 if (!net_eq(net, &init_net)) {
92413 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
92414 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
92415 if (tbl == NULL)
92416 goto err_dup;
92417
92418 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
92419 if (net->user_ns != &init_user_ns) {
92420 tbl[0].procname = NULL;
92421 }
92422 - }
92423 -
92424 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92425 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92426 + } else
92427 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
92428 if (net->core.sysctl_hdr == NULL)
92429 goto err_reg;
92430
92431 return 0;
92432
92433 err_reg:
92434 - if (tbl != netns_core_table)
92435 - kfree(tbl);
92436 + kfree(tbl);
92437 err_dup:
92438 return -ENOMEM;
92439 }
92440 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
92441 kfree(tbl);
92442 }
92443
92444 -static __net_initdata struct pernet_operations sysctl_core_ops = {
92445 +static __net_initconst struct pernet_operations sysctl_core_ops = {
92446 .init = sysctl_core_net_init,
92447 .exit = sysctl_core_net_exit,
92448 };
92449 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
92450 index dd4d506..fb2fb87 100644
92451 --- a/net/decnet/af_decnet.c
92452 +++ b/net/decnet/af_decnet.c
92453 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
92454 .sysctl_rmem = sysctl_decnet_rmem,
92455 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
92456 .obj_size = sizeof(struct dn_sock),
92457 + .slab_flags = SLAB_USERCOPY,
92458 };
92459
92460 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
92461 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
92462 index 5325b54..a0d4d69 100644
92463 --- a/net/decnet/sysctl_net_decnet.c
92464 +++ b/net/decnet/sysctl_net_decnet.c
92465 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
92466
92467 if (len > *lenp) len = *lenp;
92468
92469 - if (copy_to_user(buffer, addr, len))
92470 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
92471 return -EFAULT;
92472
92473 *lenp = len;
92474 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
92475
92476 if (len > *lenp) len = *lenp;
92477
92478 - if (copy_to_user(buffer, devname, len))
92479 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
92480 return -EFAULT;
92481
92482 *lenp = len;
92483 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
92484 index 3b9d5f2..d7015c6 100644
92485 --- a/net/ieee802154/6lowpan.c
92486 +++ b/net/ieee802154/6lowpan.c
92487 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
92488 hc06_ptr += 3;
92489 } else {
92490 /* compress nothing */
92491 - memcpy(hc06_ptr, &hdr, 4);
92492 + memcpy(hc06_ptr, hdr, 4);
92493 /* replace the top byte with new ECN | DSCP format */
92494 *hc06_ptr = tmp;
92495 hc06_ptr += 4;
92496 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
92497 index dd6b523..dfe558f 100644
92498 --- a/net/ipv4/af_inet.c
92499 +++ b/net/ipv4/af_inet.c
92500 @@ -1687,13 +1687,9 @@ static int __init inet_init(void)
92501
92502 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
92503
92504 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
92505 - if (!sysctl_local_reserved_ports)
92506 - goto out;
92507 -
92508 rc = proto_register(&tcp_prot, 1);
92509 if (rc)
92510 - goto out_free_reserved_ports;
92511 + goto out;
92512
92513 rc = proto_register(&udp_prot, 1);
92514 if (rc)
92515 @@ -1802,8 +1798,6 @@ out_unregister_udp_proto:
92516 proto_unregister(&udp_prot);
92517 out_unregister_tcp_proto:
92518 proto_unregister(&tcp_prot);
92519 -out_free_reserved_ports:
92520 - kfree(sysctl_local_reserved_ports);
92521 goto out;
92522 }
92523
92524 diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
92525 index b28e863..19e3637 100644
92526 --- a/net/ipv4/datagram.c
92527 +++ b/net/ipv4/datagram.c
92528 @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
92529 if (IS_ERR(rt)) {
92530 err = PTR_ERR(rt);
92531 if (err == -ENETUNREACH)
92532 - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92533 + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92534 goto out;
92535 }
92536
92537 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
92538 index 34ca6d5..b6421e8 100644
92539 --- a/net/ipv4/devinet.c
92540 +++ b/net/ipv4/devinet.c
92541 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
92542 idx = 0;
92543 head = &net->dev_index_head[h];
92544 rcu_read_lock();
92545 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92546 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92547 net->dev_base_seq;
92548 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92549 if (idx < s_idx)
92550 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
92551 idx = 0;
92552 head = &net->dev_index_head[h];
92553 rcu_read_lock();
92554 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92555 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92556 net->dev_base_seq;
92557 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92558 if (idx < s_idx)
92559 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
92560 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
92561 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
92562
92563 -static struct devinet_sysctl_table {
92564 +static const struct devinet_sysctl_table {
92565 struct ctl_table_header *sysctl_header;
92566 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92567 } devinet_sysctl = {
92568 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92569 int err;
92570 struct ipv4_devconf *all, *dflt;
92571 #ifdef CONFIG_SYSCTL
92572 - struct ctl_table *tbl = ctl_forward_entry;
92573 + ctl_table_no_const *tbl = NULL;
92574 struct ctl_table_header *forw_hdr;
92575 #endif
92576
92577 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92578 goto err_alloc_dflt;
92579
92580 #ifdef CONFIG_SYSCTL
92581 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92582 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92583 if (tbl == NULL)
92584 goto err_alloc_ctl;
92585
92586 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92587 goto err_reg_dflt;
92588
92589 err = -ENOMEM;
92590 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92591 + if (!net_eq(net, &init_net))
92592 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92593 + else
92594 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92595 if (forw_hdr == NULL)
92596 goto err_reg_ctl;
92597 net->ipv4.forw_hdr = forw_hdr;
92598 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92599 err_reg_dflt:
92600 __devinet_sysctl_unregister(all);
92601 err_reg_all:
92602 - if (tbl != ctl_forward_entry)
92603 - kfree(tbl);
92604 + kfree(tbl);
92605 err_alloc_ctl:
92606 #endif
92607 if (dflt != &ipv4_devconf_dflt)
92608 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92609 index b3f627a..b0f3e99 100644
92610 --- a/net/ipv4/fib_frontend.c
92611 +++ b/net/ipv4/fib_frontend.c
92612 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92613 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92614 fib_sync_up(dev);
92615 #endif
92616 - atomic_inc(&net->ipv4.dev_addr_genid);
92617 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92618 rt_cache_flush(dev_net(dev));
92619 break;
92620 case NETDEV_DOWN:
92621 fib_del_ifaddr(ifa, NULL);
92622 - atomic_inc(&net->ipv4.dev_addr_genid);
92623 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92624 if (ifa->ifa_dev->ifa_list == NULL) {
92625 /* Last address was deleted from this interface.
92626 * Disable IP.
92627 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92628 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92629 fib_sync_up(dev);
92630 #endif
92631 - atomic_inc(&net->ipv4.dev_addr_genid);
92632 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92633 rt_cache_flush(net);
92634 break;
92635 case NETDEV_DOWN:
92636 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92637 index d5dbca5..6251d5f 100644
92638 --- a/net/ipv4/fib_semantics.c
92639 +++ b/net/ipv4/fib_semantics.c
92640 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92641 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92642 nh->nh_gw,
92643 nh->nh_parent->fib_scope);
92644 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92645 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92646
92647 return nh->nh_saddr;
92648 }
92649 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92650 index 6acb541..9ea617d 100644
92651 --- a/net/ipv4/inet_connection_sock.c
92652 +++ b/net/ipv4/inet_connection_sock.c
92653 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92654 .range = { 32768, 61000 },
92655 };
92656
92657 -unsigned long *sysctl_local_reserved_ports;
92658 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92659 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92660
92661 void inet_get_local_port_range(int *low, int *high)
92662 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92663 index 96da9c7..b956690 100644
92664 --- a/net/ipv4/inet_hashtables.c
92665 +++ b/net/ipv4/inet_hashtables.c
92666 @@ -18,12 +18,15 @@
92667 #include <linux/sched.h>
92668 #include <linux/slab.h>
92669 #include <linux/wait.h>
92670 +#include <linux/security.h>
92671
92672 #include <net/inet_connection_sock.h>
92673 #include <net/inet_hashtables.h>
92674 #include <net/secure_seq.h>
92675 #include <net/ip.h>
92676
92677 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92678 +
92679 /*
92680 * Allocate and initialize a new local port bind bucket.
92681 * The bindhash mutex for snum's hash chain must be held here.
92682 @@ -554,6 +557,8 @@ ok:
92683 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92684 spin_unlock(&head->lock);
92685
92686 + gr_update_task_in_ip_table(current, inet_sk(sk));
92687 +
92688 if (tw) {
92689 inet_twsk_deschedule(tw, death_row);
92690 while (twrefcnt) {
92691 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92692 index 33d5537..da337a4 100644
92693 --- a/net/ipv4/inetpeer.c
92694 +++ b/net/ipv4/inetpeer.c
92695 @@ -503,8 +503,8 @@ relookup:
92696 if (p) {
92697 p->daddr = *daddr;
92698 atomic_set(&p->refcnt, 1);
92699 - atomic_set(&p->rid, 0);
92700 - atomic_set(&p->ip_id_count,
92701 + atomic_set_unchecked(&p->rid, 0);
92702 + atomic_set_unchecked(&p->ip_id_count,
92703 (daddr->family == AF_INET) ?
92704 secure_ip_id(daddr->addr.a4) :
92705 secure_ipv6_id(daddr->addr.a6));
92706 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92707 index b66910a..cfe416e 100644
92708 --- a/net/ipv4/ip_fragment.c
92709 +++ b/net/ipv4/ip_fragment.c
92710 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92711 return 0;
92712
92713 start = qp->rid;
92714 - end = atomic_inc_return(&peer->rid);
92715 + end = atomic_inc_return_unchecked(&peer->rid);
92716 qp->rid = end;
92717
92718 rc = qp->q.fragments && (end - start) > max;
92719 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92720
92721 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92722 {
92723 - struct ctl_table *table;
92724 + ctl_table_no_const *table = NULL;
92725 struct ctl_table_header *hdr;
92726
92727 - table = ip4_frags_ns_ctl_table;
92728 if (!net_eq(net, &init_net)) {
92729 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92730 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92731 if (table == NULL)
92732 goto err_alloc;
92733
92734 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92735 /* Don't export sysctls to unprivileged users */
92736 if (net->user_ns != &init_user_ns)
92737 table[0].procname = NULL;
92738 - }
92739 + hdr = register_net_sysctl(net, "net/ipv4", table);
92740 + } else
92741 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92742
92743 - hdr = register_net_sysctl(net, "net/ipv4", table);
92744 if (hdr == NULL)
92745 goto err_reg;
92746
92747 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92748 return 0;
92749
92750 err_reg:
92751 - if (!net_eq(net, &init_net))
92752 - kfree(table);
92753 + kfree(table);
92754 err_alloc:
92755 return -ENOMEM;
92756 }
92757 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92758 index 8d6939e..19d0a95 100644
92759 --- a/net/ipv4/ip_gre.c
92760 +++ b/net/ipv4/ip_gre.c
92761 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92762 module_param(log_ecn_error, bool, 0644);
92763 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92764
92765 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92766 +static struct rtnl_link_ops ipgre_link_ops;
92767 static int ipgre_tunnel_init(struct net_device *dev);
92768
92769 static int ipgre_net_id __read_mostly;
92770 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92771 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92772 };
92773
92774 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92775 +static struct rtnl_link_ops ipgre_link_ops = {
92776 .kind = "gre",
92777 .maxtype = IFLA_GRE_MAX,
92778 .policy = ipgre_policy,
92779 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92780 .fill_info = ipgre_fill_info,
92781 };
92782
92783 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92784 +static struct rtnl_link_ops ipgre_tap_ops = {
92785 .kind = "gretap",
92786 .maxtype = IFLA_GRE_MAX,
92787 .policy = ipgre_policy,
92788 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92789 index d9c4f11..02b82dbc 100644
92790 --- a/net/ipv4/ip_sockglue.c
92791 +++ b/net/ipv4/ip_sockglue.c
92792 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92793 len = min_t(unsigned int, len, opt->optlen);
92794 if (put_user(len, optlen))
92795 return -EFAULT;
92796 - if (copy_to_user(optval, opt->__data, len))
92797 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92798 + copy_to_user(optval, opt->__data, len))
92799 return -EFAULT;
92800 return 0;
92801 }
92802 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92803 if (sk->sk_type != SOCK_STREAM)
92804 return -ENOPROTOOPT;
92805
92806 - msg.msg_control = optval;
92807 + msg.msg_control = (void __force_kernel *)optval;
92808 msg.msg_controllen = len;
92809 msg.msg_flags = flags;
92810
92811 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92812 index 0656041..d6ecb60 100644
92813 --- a/net/ipv4/ip_vti.c
92814 +++ b/net/ipv4/ip_vti.c
92815 @@ -47,7 +47,7 @@
92816 #define HASH_SIZE 16
92817 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92818
92819 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92820 +static struct rtnl_link_ops vti_link_ops;
92821
92822 static int vti_net_id __read_mostly;
92823 struct vti_net {
92824 @@ -848,7 +848,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92825 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92826 };
92827
92828 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92829 +static struct rtnl_link_ops vti_link_ops = {
92830 .kind = "vti",
92831 .maxtype = IFLA_VTI_MAX,
92832 .policy = vti_policy,
92833 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92834 index efa1138..20dbba0 100644
92835 --- a/net/ipv4/ipconfig.c
92836 +++ b/net/ipv4/ipconfig.c
92837 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92838
92839 mm_segment_t oldfs = get_fs();
92840 set_fs(get_ds());
92841 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92842 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92843 set_fs(oldfs);
92844 return res;
92845 }
92846 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92847
92848 mm_segment_t oldfs = get_fs();
92849 set_fs(get_ds());
92850 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92851 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92852 set_fs(oldfs);
92853 return res;
92854 }
92855 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92856
92857 mm_segment_t oldfs = get_fs();
92858 set_fs(get_ds());
92859 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92860 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92861 set_fs(oldfs);
92862 return res;
92863 }
92864 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92865 index b3ac3c3..ec6bd95 100644
92866 --- a/net/ipv4/ipip.c
92867 +++ b/net/ipv4/ipip.c
92868 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92869 static int ipip_net_id __read_mostly;
92870
92871 static int ipip_tunnel_init(struct net_device *dev);
92872 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92873 +static struct rtnl_link_ops ipip_link_ops;
92874
92875 static int ipip_err(struct sk_buff *skb, u32 info)
92876 {
92877 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92878 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92879 };
92880
92881 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92882 +static struct rtnl_link_ops ipip_link_ops = {
92883 .kind = "ipip",
92884 .maxtype = IFLA_IPTUN_MAX,
92885 .policy = ipip_policy,
92886 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92887 index 85a4f21..1beb1f5 100644
92888 --- a/net/ipv4/netfilter/arp_tables.c
92889 +++ b/net/ipv4/netfilter/arp_tables.c
92890 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92891 #endif
92892
92893 static int get_info(struct net *net, void __user *user,
92894 - const int *len, int compat)
92895 + int len, int compat)
92896 {
92897 char name[XT_TABLE_MAXNAMELEN];
92898 struct xt_table *t;
92899 int ret;
92900
92901 - if (*len != sizeof(struct arpt_getinfo)) {
92902 - duprintf("length %u != %Zu\n", *len,
92903 + if (len != sizeof(struct arpt_getinfo)) {
92904 + duprintf("length %u != %Zu\n", len,
92905 sizeof(struct arpt_getinfo));
92906 return -EINVAL;
92907 }
92908 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92909 info.size = private->size;
92910 strcpy(info.name, name);
92911
92912 - if (copy_to_user(user, &info, *len) != 0)
92913 + if (copy_to_user(user, &info, len) != 0)
92914 ret = -EFAULT;
92915 else
92916 ret = 0;
92917 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92918
92919 switch (cmd) {
92920 case ARPT_SO_GET_INFO:
92921 - ret = get_info(sock_net(sk), user, len, 1);
92922 + ret = get_info(sock_net(sk), user, *len, 1);
92923 break;
92924 case ARPT_SO_GET_ENTRIES:
92925 ret = compat_get_entries(sock_net(sk), user, len);
92926 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92927
92928 switch (cmd) {
92929 case ARPT_SO_GET_INFO:
92930 - ret = get_info(sock_net(sk), user, len, 0);
92931 + ret = get_info(sock_net(sk), user, *len, 0);
92932 break;
92933
92934 case ARPT_SO_GET_ENTRIES:
92935 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92936 index d23118d..6ad7277 100644
92937 --- a/net/ipv4/netfilter/ip_tables.c
92938 +++ b/net/ipv4/netfilter/ip_tables.c
92939 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92940 #endif
92941
92942 static int get_info(struct net *net, void __user *user,
92943 - const int *len, int compat)
92944 + int len, int compat)
92945 {
92946 char name[XT_TABLE_MAXNAMELEN];
92947 struct xt_table *t;
92948 int ret;
92949
92950 - if (*len != sizeof(struct ipt_getinfo)) {
92951 - duprintf("length %u != %zu\n", *len,
92952 + if (len != sizeof(struct ipt_getinfo)) {
92953 + duprintf("length %u != %zu\n", len,
92954 sizeof(struct ipt_getinfo));
92955 return -EINVAL;
92956 }
92957 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92958 info.size = private->size;
92959 strcpy(info.name, name);
92960
92961 - if (copy_to_user(user, &info, *len) != 0)
92962 + if (copy_to_user(user, &info, len) != 0)
92963 ret = -EFAULT;
92964 else
92965 ret = 0;
92966 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92967
92968 switch (cmd) {
92969 case IPT_SO_GET_INFO:
92970 - ret = get_info(sock_net(sk), user, len, 1);
92971 + ret = get_info(sock_net(sk), user, *len, 1);
92972 break;
92973 case IPT_SO_GET_ENTRIES:
92974 ret = compat_get_entries(sock_net(sk), user, len);
92975 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92976
92977 switch (cmd) {
92978 case IPT_SO_GET_INFO:
92979 - ret = get_info(sock_net(sk), user, len, 0);
92980 + ret = get_info(sock_net(sk), user, *len, 0);
92981 break;
92982
92983 case IPT_SO_GET_ENTRIES:
92984 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
92985 index cbc2215..9cb993c 100644
92986 --- a/net/ipv4/netfilter/ipt_ULOG.c
92987 +++ b/net/ipv4/netfilter/ipt_ULOG.c
92988 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
92989 ub->qlen++;
92990
92991 pm = nlmsg_data(nlh);
92992 + memset(pm, 0, sizeof(*pm));
92993
92994 /* We might not have a timestamp, get one */
92995 if (skb->tstamp.tv64 == 0)
92996 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
92997 }
92998 else if (loginfo->prefix[0] != '\0')
92999 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
93000 - else
93001 - *(pm->prefix) = '\0';
93002
93003 if (in && in->hard_header_len > 0 &&
93004 skb->mac_header != skb->network_header &&
93005 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
93006
93007 if (in)
93008 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
93009 - else
93010 - pm->indev_name[0] = '\0';
93011
93012 if (out)
93013 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
93014 - else
93015 - pm->outdev_name[0] = '\0';
93016
93017 /* copy_len <= skb->len, so can't fail. */
93018 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
93019 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
93020 index 746427c..a73be71 100644
93021 --- a/net/ipv4/ping.c
93022 +++ b/net/ipv4/ping.c
93023 @@ -55,7 +55,7 @@
93024
93025
93026 struct ping_table ping_table;
93027 -struct pingv6_ops pingv6_ops;
93028 +struct pingv6_ops *pingv6_ops;
93029 EXPORT_SYMBOL_GPL(pingv6_ops);
93030
93031 static u16 ping_port_rover;
93032 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
93033 return -ENODEV;
93034 }
93035 }
93036 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
93037 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
93038 scoped);
93039 rcu_read_unlock();
93040
93041 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93042 }
93043 #if IS_ENABLED(CONFIG_IPV6)
93044 } else if (skb->protocol == htons(ETH_P_IPV6)) {
93045 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
93046 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
93047 #endif
93048 }
93049
93050 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93051 info, (u8 *)icmph);
93052 #if IS_ENABLED(CONFIG_IPV6)
93053 } else if (family == AF_INET6) {
93054 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
93055 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
93056 info, (u8 *)icmph);
93057 #endif
93058 }
93059 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93060 return ip_recv_error(sk, msg, len);
93061 #if IS_ENABLED(CONFIG_IPV6)
93062 } else if (family == AF_INET6) {
93063 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
93064 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
93065 #endif
93066 }
93067 }
93068 @@ -874,11 +874,14 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93069
93070 /* Copy the address and add cmsg data. */
93071 if (family == AF_INET) {
93072 - sin = (struct sockaddr_in *) msg->msg_name;
93073 - sin->sin_family = AF_INET;
93074 - sin->sin_port = 0 /* skb->h.uh->source */;
93075 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93076 - memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93077 + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
93078 +
93079 + if (sin) {
93080 + sin->sin_family = AF_INET;
93081 + sin->sin_port = 0 /* skb->h.uh->source */;
93082 + sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93083 + memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93084 + }
93085
93086 if (isk->cmsg_flags)
93087 ip_cmsg_recv(msg, skb);
93088 @@ -887,20 +890,23 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93089 } else if (family == AF_INET6) {
93090 struct ipv6_pinfo *np = inet6_sk(sk);
93091 struct ipv6hdr *ip6 = ipv6_hdr(skb);
93092 - sin6 = (struct sockaddr_in6 *) msg->msg_name;
93093 - sin6->sin6_family = AF_INET6;
93094 - sin6->sin6_port = 0;
93095 - sin6->sin6_addr = ip6->saddr;
93096 + struct sockaddr_in6 *sin6 =
93097 + (struct sockaddr_in6 *)msg->msg_name;
93098
93099 - sin6->sin6_flowinfo = 0;
93100 - if (np->sndflow)
93101 - sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93102 -
93103 - sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
93104 - IP6CB(skb)->iif);
93105 + if (sin6) {
93106 + sin6->sin6_family = AF_INET6;
93107 + sin6->sin6_port = 0;
93108 + sin6->sin6_addr = ip6->saddr;
93109 + sin6->sin6_flowinfo = 0;
93110 + if (np->sndflow)
93111 + sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93112 + sin6->sin6_scope_id =
93113 + ipv6_iface_scope_id(&sin6->sin6_addr,
93114 + IP6CB(skb)->iif);
93115 + }
93116
93117 if (inet6_sk(sk)->rxopt.all)
93118 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
93119 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
93120 #endif
93121 } else {
93122 BUG();
93123 @@ -1090,7 +1096,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
93124 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93125 0, sock_i_ino(sp),
93126 atomic_read(&sp->sk_refcnt), sp,
93127 - atomic_read(&sp->sk_drops), len);
93128 + atomic_read_unchecked(&sp->sk_drops), len);
93129 }
93130
93131 static int ping_v4_seq_show(struct seq_file *seq, void *v)
93132 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
93133 index 6fb2337..9cd6b20 100644
93134 --- a/net/ipv4/raw.c
93135 +++ b/net/ipv4/raw.c
93136 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
93137 int raw_rcv(struct sock *sk, struct sk_buff *skb)
93138 {
93139 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
93140 - atomic_inc(&sk->sk_drops);
93141 + atomic_inc_unchecked(&sk->sk_drops);
93142 kfree_skb(skb);
93143 return NET_RX_DROP;
93144 }
93145 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
93146
93147 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
93148 {
93149 + struct icmp_filter filter;
93150 +
93151 if (optlen > sizeof(struct icmp_filter))
93152 optlen = sizeof(struct icmp_filter);
93153 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
93154 + if (copy_from_user(&filter, optval, optlen))
93155 return -EFAULT;
93156 + raw_sk(sk)->filter = filter;
93157 return 0;
93158 }
93159
93160 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
93161 {
93162 int len, ret = -EFAULT;
93163 + struct icmp_filter filter;
93164
93165 if (get_user(len, optlen))
93166 goto out;
93167 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
93168 if (len > sizeof(struct icmp_filter))
93169 len = sizeof(struct icmp_filter);
93170 ret = -EFAULT;
93171 - if (put_user(len, optlen) ||
93172 - copy_to_user(optval, &raw_sk(sk)->filter, len))
93173 + filter = raw_sk(sk)->filter;
93174 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
93175 goto out;
93176 ret = 0;
93177 out: return ret;
93178 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
93179 0, 0L, 0,
93180 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
93181 0, sock_i_ino(sp),
93182 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
93183 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
93184 }
93185
93186 static int raw_seq_show(struct seq_file *seq, void *v)
93187 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
93188 index 2de16d9..da558c7 100644
93189 --- a/net/ipv4/route.c
93190 +++ b/net/ipv4/route.c
93191 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
93192 .maxlen = sizeof(int),
93193 .mode = 0200,
93194 .proc_handler = ipv4_sysctl_rtcache_flush,
93195 + .extra1 = &init_net,
93196 },
93197 { },
93198 };
93199
93200 static __net_init int sysctl_route_net_init(struct net *net)
93201 {
93202 - struct ctl_table *tbl;
93203 + ctl_table_no_const *tbl = NULL;
93204
93205 - tbl = ipv4_route_flush_table;
93206 if (!net_eq(net, &init_net)) {
93207 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93208 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93209 if (tbl == NULL)
93210 goto err_dup;
93211
93212 /* Don't export sysctls to unprivileged users */
93213 if (net->user_ns != &init_user_ns)
93214 tbl[0].procname = NULL;
93215 - }
93216 - tbl[0].extra1 = net;
93217 + tbl[0].extra1 = net;
93218 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93219 + } else
93220 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
93221
93222 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93223 if (net->ipv4.route_hdr == NULL)
93224 goto err_reg;
93225 return 0;
93226
93227 err_reg:
93228 - if (tbl != ipv4_route_flush_table)
93229 - kfree(tbl);
93230 + kfree(tbl);
93231 err_dup:
93232 return -ENOMEM;
93233 }
93234 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
93235
93236 static __net_init int rt_genid_init(struct net *net)
93237 {
93238 - atomic_set(&net->rt_genid, 0);
93239 - atomic_set(&net->fnhe_genid, 0);
93240 + atomic_set_unchecked(&net->rt_genid, 0);
93241 + atomic_set_unchecked(&net->fnhe_genid, 0);
93242 get_random_bytes(&net->ipv4.dev_addr_genid,
93243 sizeof(net->ipv4.dev_addr_genid));
93244 return 0;
93245 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
93246 index 6900b8b..7832c6b 100644
93247 --- a/net/ipv4/sysctl_net_ipv4.c
93248 +++ b/net/ipv4/sysctl_net_ipv4.c
93249 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
93250 {
93251 int ret;
93252 int range[2];
93253 - struct ctl_table tmp = {
93254 + ctl_table_no_const tmp = {
93255 .data = &range,
93256 .maxlen = sizeof(range),
93257 .mode = table->mode,
93258 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
93259 int ret;
93260 gid_t urange[2];
93261 kgid_t low, high;
93262 - struct ctl_table tmp = {
93263 + ctl_table_no_const tmp = {
93264 .data = &urange,
93265 .maxlen = sizeof(urange),
93266 .mode = table->mode,
93267 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
93268 void __user *buffer, size_t *lenp, loff_t *ppos)
93269 {
93270 char val[TCP_CA_NAME_MAX];
93271 - struct ctl_table tbl = {
93272 + ctl_table_no_const tbl = {
93273 .data = val,
93274 .maxlen = TCP_CA_NAME_MAX,
93275 };
93276 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
93277 void __user *buffer, size_t *lenp,
93278 loff_t *ppos)
93279 {
93280 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
93281 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
93282 int ret;
93283
93284 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93285 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
93286 void __user *buffer, size_t *lenp,
93287 loff_t *ppos)
93288 {
93289 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
93290 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
93291 int ret;
93292
93293 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93294 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
93295 struct mem_cgroup *memcg;
93296 #endif
93297
93298 - struct ctl_table tmp = {
93299 + ctl_table_no_const tmp = {
93300 .data = &vec,
93301 .maxlen = sizeof(vec),
93302 .mode = ctl->mode,
93303 };
93304
93305 if (!write) {
93306 - ctl->data = &net->ipv4.sysctl_tcp_mem;
93307 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
93308 + ctl_table_no_const tcp_mem = *ctl;
93309 +
93310 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
93311 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
93312 }
93313
93314 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
93315 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
93316 void __user *buffer, size_t *lenp,
93317 loff_t *ppos)
93318 {
93319 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93320 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93321 struct tcp_fastopen_context *ctxt;
93322 int ret;
93323 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
93324 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
93325 },
93326 {
93327 .procname = "ip_local_reserved_ports",
93328 - .data = NULL, /* initialized in sysctl_ipv4_init */
93329 + .data = sysctl_local_reserved_ports,
93330 .maxlen = 65536,
93331 .mode = 0644,
93332 .proc_handler = proc_do_large_bitmap,
93333 @@ -857,11 +859,10 @@ static struct ctl_table ipv4_net_table[] = {
93334
93335 static __net_init int ipv4_sysctl_init_net(struct net *net)
93336 {
93337 - struct ctl_table *table;
93338 + ctl_table_no_const *table = NULL;
93339
93340 - table = ipv4_net_table;
93341 if (!net_eq(net, &init_net)) {
93342 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
93343 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
93344 if (table == NULL)
93345 goto err_alloc;
93346
93347 @@ -896,15 +897,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
93348
93349 tcp_init_mem(net);
93350
93351 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93352 + if (!net_eq(net, &init_net))
93353 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93354 + else
93355 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
93356 if (net->ipv4.ipv4_hdr == NULL)
93357 goto err_reg;
93358
93359 return 0;
93360
93361 err_reg:
93362 - if (!net_eq(net, &init_net))
93363 - kfree(table);
93364 + kfree(table);
93365 err_alloc:
93366 return -ENOMEM;
93367 }
93368 @@ -926,16 +929,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
93369 static __init int sysctl_ipv4_init(void)
93370 {
93371 struct ctl_table_header *hdr;
93372 - struct ctl_table *i;
93373 -
93374 - for (i = ipv4_table; i->procname; i++) {
93375 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
93376 - i->data = sysctl_local_reserved_ports;
93377 - break;
93378 - }
93379 - }
93380 - if (!i->procname)
93381 - return -EINVAL;
93382
93383 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
93384 if (hdr == NULL)
93385 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
93386 index 723951a..61cf1cc 100644
93387 --- a/net/ipv4/tcp_input.c
93388 +++ b/net/ipv4/tcp_input.c
93389 @@ -4412,7 +4412,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
93390 * simplifies code)
93391 */
93392 static void
93393 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93394 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93395 struct sk_buff *head, struct sk_buff *tail,
93396 u32 start, u32 end)
93397 {
93398 @@ -5498,6 +5498,7 @@ discard:
93399 tcp_paws_reject(&tp->rx_opt, 0))
93400 goto discard_and_undo;
93401
93402 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
93403 if (th->syn) {
93404 /* We see SYN without ACK. It is attempt of
93405 * simultaneous connect with crossed SYNs.
93406 @@ -5548,6 +5549,7 @@ discard:
93407 goto discard;
93408 #endif
93409 }
93410 +#endif
93411 /* "fifth, if neither of the SYN or RST bits is set then
93412 * drop the segment and return."
93413 */
93414 @@ -5593,7 +5595,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
93415 goto discard;
93416
93417 if (th->syn) {
93418 - if (th->fin)
93419 + if (th->fin || th->urg || th->psh)
93420 goto discard;
93421 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
93422 return 1;
93423 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
93424 index b299da5..097db06 100644
93425 --- a/net/ipv4/tcp_ipv4.c
93426 +++ b/net/ipv4/tcp_ipv4.c
93427 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
93428 EXPORT_SYMBOL(sysctl_tcp_low_latency);
93429
93430
93431 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93432 +extern int grsec_enable_blackhole;
93433 +#endif
93434 +
93435 #ifdef CONFIG_TCP_MD5SIG
93436 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
93437 __be32 daddr, __be32 saddr, const struct tcphdr *th);
93438 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
93439 return 0;
93440
93441 reset:
93442 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93443 + if (!grsec_enable_blackhole)
93444 +#endif
93445 tcp_v4_send_reset(rsk, skb);
93446 discard:
93447 kfree_skb(skb);
93448 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
93449 TCP_SKB_CB(skb)->sacked = 0;
93450
93451 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93452 - if (!sk)
93453 + if (!sk) {
93454 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93455 + ret = 1;
93456 +#endif
93457 goto no_tcp_socket;
93458 -
93459 + }
93460 process:
93461 - if (sk->sk_state == TCP_TIME_WAIT)
93462 + if (sk->sk_state == TCP_TIME_WAIT) {
93463 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93464 + ret = 2;
93465 +#endif
93466 goto do_time_wait;
93467 + }
93468
93469 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
93470 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93471 @@ -2034,6 +2048,10 @@ csum_error:
93472 bad_packet:
93473 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93474 } else {
93475 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93476 + if (!grsec_enable_blackhole || (ret == 1 &&
93477 + (skb->dev->flags & IFF_LOOPBACK)))
93478 +#endif
93479 tcp_v4_send_reset(NULL, skb);
93480 }
93481
93482 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
93483 index ab1c086..2a8d76b 100644
93484 --- a/net/ipv4/tcp_minisocks.c
93485 +++ b/net/ipv4/tcp_minisocks.c
93486 @@ -27,6 +27,10 @@
93487 #include <net/inet_common.h>
93488 #include <net/xfrm.h>
93489
93490 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93491 +extern int grsec_enable_blackhole;
93492 +#endif
93493 +
93494 int sysctl_tcp_syncookies __read_mostly = 1;
93495 EXPORT_SYMBOL(sysctl_tcp_syncookies);
93496
93497 @@ -715,7 +719,10 @@ embryonic_reset:
93498 * avoid becoming vulnerable to outside attack aiming at
93499 * resetting legit local connections.
93500 */
93501 - req->rsk_ops->send_reset(sk, skb);
93502 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93503 + if (!grsec_enable_blackhole)
93504 +#endif
93505 + req->rsk_ops->send_reset(sk, skb);
93506 } else if (fastopen) { /* received a valid RST pkt */
93507 reqsk_fastopen_remove(sk, req, true);
93508 tcp_reset(sk);
93509 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
93510 index d4943f6..e7a74a5 100644
93511 --- a/net/ipv4/tcp_probe.c
93512 +++ b/net/ipv4/tcp_probe.c
93513 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
93514 if (cnt + width >= len)
93515 break;
93516
93517 - if (copy_to_user(buf + cnt, tbuf, width))
93518 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
93519 return -EFAULT;
93520 cnt += width;
93521 }
93522 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
93523 index 4b85e6f..22f9ac9 100644
93524 --- a/net/ipv4/tcp_timer.c
93525 +++ b/net/ipv4/tcp_timer.c
93526 @@ -22,6 +22,10 @@
93527 #include <linux/gfp.h>
93528 #include <net/tcp.h>
93529
93530 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93531 +extern int grsec_lastack_retries;
93532 +#endif
93533 +
93534 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
93535 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
93536 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
93537 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
93538 }
93539 }
93540
93541 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93542 + if ((sk->sk_state == TCP_LAST_ACK) &&
93543 + (grsec_lastack_retries > 0) &&
93544 + (grsec_lastack_retries < retry_until))
93545 + retry_until = grsec_lastack_retries;
93546 +#endif
93547 +
93548 if (retransmits_timed_out(sk, retry_until,
93549 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
93550 /* Has it gone just too far? */
93551 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
93552 index 766e6ba..aff2f8d 100644
93553 --- a/net/ipv4/udp.c
93554 +++ b/net/ipv4/udp.c
93555 @@ -87,6 +87,7 @@
93556 #include <linux/types.h>
93557 #include <linux/fcntl.h>
93558 #include <linux/module.h>
93559 +#include <linux/security.h>
93560 #include <linux/socket.h>
93561 #include <linux/sockios.h>
93562 #include <linux/igmp.h>
93563 @@ -112,6 +113,10 @@
93564 #include <net/busy_poll.h>
93565 #include "udp_impl.h"
93566
93567 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93568 +extern int grsec_enable_blackhole;
93569 +#endif
93570 +
93571 struct udp_table udp_table __read_mostly;
93572 EXPORT_SYMBOL(udp_table);
93573
93574 @@ -595,6 +600,9 @@ found:
93575 return s;
93576 }
93577
93578 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
93579 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
93580 +
93581 /*
93582 * This routine is called by the ICMP module when it gets some
93583 * sort of error condition. If err < 0 then the socket should
93584 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93585 dport = usin->sin_port;
93586 if (dport == 0)
93587 return -EINVAL;
93588 +
93589 + err = gr_search_udp_sendmsg(sk, usin);
93590 + if (err)
93591 + return err;
93592 } else {
93593 if (sk->sk_state != TCP_ESTABLISHED)
93594 return -EDESTADDRREQ;
93595 +
93596 + err = gr_search_udp_sendmsg(sk, NULL);
93597 + if (err)
93598 + return err;
93599 +
93600 daddr = inet->inet_daddr;
93601 dport = inet->inet_dport;
93602 /* Open fast path for connected socket.
93603 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
93604 IS_UDPLITE(sk));
93605 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93606 IS_UDPLITE(sk));
93607 - atomic_inc(&sk->sk_drops);
93608 + atomic_inc_unchecked(&sk->sk_drops);
93609 __skb_unlink(skb, rcvq);
93610 __skb_queue_tail(&list_kill, skb);
93611 }
93612 @@ -1223,6 +1240,10 @@ try_again:
93613 if (!skb)
93614 goto out;
93615
93616 + err = gr_search_udp_recvmsg(sk, skb);
93617 + if (err)
93618 + goto out_free;
93619 +
93620 ulen = skb->len - sizeof(struct udphdr);
93621 copied = len;
93622 if (copied > ulen)
93623 @@ -1256,7 +1277,7 @@ try_again:
93624 if (unlikely(err)) {
93625 trace_kfree_skb(skb, udp_recvmsg);
93626 if (!peeked) {
93627 - atomic_inc(&sk->sk_drops);
93628 + atomic_inc_unchecked(&sk->sk_drops);
93629 UDP_INC_STATS_USER(sock_net(sk),
93630 UDP_MIB_INERRORS, is_udplite);
93631 }
93632 @@ -1543,7 +1564,7 @@ csum_error:
93633 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93634 drop:
93635 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93636 - atomic_inc(&sk->sk_drops);
93637 + atomic_inc_unchecked(&sk->sk_drops);
93638 kfree_skb(skb);
93639 return -1;
93640 }
93641 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93642 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93643
93644 if (!skb1) {
93645 - atomic_inc(&sk->sk_drops);
93646 + atomic_inc_unchecked(&sk->sk_drops);
93647 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93648 IS_UDPLITE(sk));
93649 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93650 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93651 goto csum_error;
93652
93653 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93654 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93655 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93656 +#endif
93657 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93658
93659 /*
93660 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93661 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93662 0, sock_i_ino(sp),
93663 atomic_read(&sp->sk_refcnt), sp,
93664 - atomic_read(&sp->sk_drops), len);
93665 + atomic_read_unchecked(&sp->sk_drops), len);
93666 }
93667
93668 int udp4_seq_show(struct seq_file *seq, void *v)
93669 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93670 index 9a459be..c7bc04c 100644
93671 --- a/net/ipv4/xfrm4_policy.c
93672 +++ b/net/ipv4/xfrm4_policy.c
93673 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93674 fl4->flowi4_tos = iph->tos;
93675 }
93676
93677 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93678 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93679 {
93680 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93681
93682 - xfrm4_policy_afinfo.garbage_collect(net);
93683 + xfrm_garbage_collect_deferred(net);
93684 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93685 }
93686
93687 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93688
93689 static int __net_init xfrm4_net_init(struct net *net)
93690 {
93691 - struct ctl_table *table;
93692 + ctl_table_no_const *table = NULL;
93693 struct ctl_table_header *hdr;
93694
93695 - table = xfrm4_policy_table;
93696 if (!net_eq(net, &init_net)) {
93697 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93698 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93699 if (!table)
93700 goto err_alloc;
93701
93702 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93703 - }
93704 -
93705 - hdr = register_net_sysctl(net, "net/ipv4", table);
93706 + hdr = register_net_sysctl(net, "net/ipv4", table);
93707 + } else
93708 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93709 if (!hdr)
93710 goto err_reg;
93711
93712 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93713 return 0;
93714
93715 err_reg:
93716 - if (!net_eq(net, &init_net))
93717 - kfree(table);
93718 + kfree(table);
93719 err_alloc:
93720 return -ENOMEM;
93721 }
93722 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93723 index 0f99f7b..9375cf5 100644
93724 --- a/net/ipv6/addrconf.c
93725 +++ b/net/ipv6/addrconf.c
93726 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93727 idx = 0;
93728 head = &net->dev_index_head[h];
93729 rcu_read_lock();
93730 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93731 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93732 net->dev_base_seq;
93733 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93734 if (idx < s_idx)
93735 @@ -2408,7 +2408,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93736 p.iph.ihl = 5;
93737 p.iph.protocol = IPPROTO_IPV6;
93738 p.iph.ttl = 64;
93739 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93740 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93741
93742 if (ops->ndo_do_ioctl) {
93743 mm_segment_t oldfs = get_fs();
93744 @@ -4057,7 +4057,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93745 s_ip_idx = ip_idx = cb->args[2];
93746
93747 rcu_read_lock();
93748 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93749 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93750 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93751 idx = 0;
93752 head = &net->dev_index_head[h];
93753 @@ -4678,7 +4678,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93754 dst_free(&ifp->rt->dst);
93755 break;
93756 }
93757 - atomic_inc(&net->ipv6.dev_addr_genid);
93758 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93759 }
93760
93761 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93762 @@ -4698,7 +4698,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93763 int *valp = ctl->data;
93764 int val = *valp;
93765 loff_t pos = *ppos;
93766 - struct ctl_table lctl;
93767 + ctl_table_no_const lctl;
93768 int ret;
93769
93770 /*
93771 @@ -4783,7 +4783,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93772 int *valp = ctl->data;
93773 int val = *valp;
93774 loff_t pos = *ppos;
93775 - struct ctl_table lctl;
93776 + ctl_table_no_const lctl;
93777 int ret;
93778
93779 /*
93780 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93781 index 197e6f4..16d8396 100644
93782 --- a/net/ipv6/datagram.c
93783 +++ b/net/ipv6/datagram.c
93784 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93785 0,
93786 sock_i_ino(sp),
93787 atomic_read(&sp->sk_refcnt), sp,
93788 - atomic_read(&sp->sk_drops));
93789 + atomic_read_unchecked(&sp->sk_drops));
93790 }
93791 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93792 index 7cfc8d2..c5394b6 100644
93793 --- a/net/ipv6/icmp.c
93794 +++ b/net/ipv6/icmp.c
93795 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93796
93797 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93798 {
93799 - struct ctl_table *table;
93800 + ctl_table_no_const *table;
93801
93802 table = kmemdup(ipv6_icmp_table_template,
93803 sizeof(ipv6_icmp_table_template),
93804 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93805 index 8bc717b..76fbb5d 100644
93806 --- a/net/ipv6/ip6_gre.c
93807 +++ b/net/ipv6/ip6_gre.c
93808 @@ -74,7 +74,7 @@ struct ip6gre_net {
93809 struct net_device *fb_tunnel_dev;
93810 };
93811
93812 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93813 +static struct rtnl_link_ops ip6gre_link_ops;
93814 static int ip6gre_tunnel_init(struct net_device *dev);
93815 static void ip6gre_tunnel_setup(struct net_device *dev);
93816 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93817 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93818 }
93819
93820
93821 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93822 +static struct inet6_protocol ip6gre_protocol = {
93823 .handler = ip6gre_rcv,
93824 .err_handler = ip6gre_err,
93825 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93826 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93827 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93828 };
93829
93830 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93831 +static struct rtnl_link_ops ip6gre_link_ops = {
93832 .kind = "ip6gre",
93833 .maxtype = IFLA_GRE_MAX,
93834 .policy = ip6gre_policy,
93835 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93836 .fill_info = ip6gre_fill_info,
93837 };
93838
93839 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93840 +static struct rtnl_link_ops ip6gre_tap_ops = {
93841 .kind = "ip6gretap",
93842 .maxtype = IFLA_GRE_MAX,
93843 .policy = ip6gre_policy,
93844 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93845 index cf5d490..30946f0 100644
93846 --- a/net/ipv6/ip6_tunnel.c
93847 +++ b/net/ipv6/ip6_tunnel.c
93848 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93849
93850 static int ip6_tnl_dev_init(struct net_device *dev);
93851 static void ip6_tnl_dev_setup(struct net_device *dev);
93852 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93853 +static struct rtnl_link_ops ip6_link_ops;
93854
93855 static int ip6_tnl_net_id __read_mostly;
93856 struct ip6_tnl_net {
93857 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93858 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93859 };
93860
93861 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93862 +static struct rtnl_link_ops ip6_link_ops = {
93863 .kind = "ip6tnl",
93864 .maxtype = IFLA_IPTUN_MAX,
93865 .policy = ip6_tnl_policy,
93866 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93867 index d1e2e8e..51c19ae 100644
93868 --- a/net/ipv6/ipv6_sockglue.c
93869 +++ b/net/ipv6/ipv6_sockglue.c
93870 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93871 if (sk->sk_type != SOCK_STREAM)
93872 return -ENOPROTOOPT;
93873
93874 - msg.msg_control = optval;
93875 + msg.msg_control = (void __force_kernel *)optval;
93876 msg.msg_controllen = len;
93877 msg.msg_flags = flags;
93878
93879 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93880 index 44400c2..8e11f52 100644
93881 --- a/net/ipv6/netfilter/ip6_tables.c
93882 +++ b/net/ipv6/netfilter/ip6_tables.c
93883 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93884 #endif
93885
93886 static int get_info(struct net *net, void __user *user,
93887 - const int *len, int compat)
93888 + int len, int compat)
93889 {
93890 char name[XT_TABLE_MAXNAMELEN];
93891 struct xt_table *t;
93892 int ret;
93893
93894 - if (*len != sizeof(struct ip6t_getinfo)) {
93895 - duprintf("length %u != %zu\n", *len,
93896 + if (len != sizeof(struct ip6t_getinfo)) {
93897 + duprintf("length %u != %zu\n", len,
93898 sizeof(struct ip6t_getinfo));
93899 return -EINVAL;
93900 }
93901 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93902 info.size = private->size;
93903 strcpy(info.name, name);
93904
93905 - if (copy_to_user(user, &info, *len) != 0)
93906 + if (copy_to_user(user, &info, len) != 0)
93907 ret = -EFAULT;
93908 else
93909 ret = 0;
93910 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93911
93912 switch (cmd) {
93913 case IP6T_SO_GET_INFO:
93914 - ret = get_info(sock_net(sk), user, len, 1);
93915 + ret = get_info(sock_net(sk), user, *len, 1);
93916 break;
93917 case IP6T_SO_GET_ENTRIES:
93918 ret = compat_get_entries(sock_net(sk), user, len);
93919 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93920
93921 switch (cmd) {
93922 case IP6T_SO_GET_INFO:
93923 - ret = get_info(sock_net(sk), user, len, 0);
93924 + ret = get_info(sock_net(sk), user, *len, 0);
93925 break;
93926
93927 case IP6T_SO_GET_ENTRIES:
93928 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93929 index dffdc1a..ccc6678 100644
93930 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93931 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93932 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93933
93934 static int nf_ct_frag6_sysctl_register(struct net *net)
93935 {
93936 - struct ctl_table *table;
93937 + ctl_table_no_const *table = NULL;
93938 struct ctl_table_header *hdr;
93939
93940 - table = nf_ct_frag6_sysctl_table;
93941 if (!net_eq(net, &init_net)) {
93942 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93943 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93944 GFP_KERNEL);
93945 if (table == NULL)
93946 goto err_alloc;
93947 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93948 table[0].data = &net->nf_frag.frags.timeout;
93949 table[1].data = &net->nf_frag.frags.low_thresh;
93950 table[2].data = &net->nf_frag.frags.high_thresh;
93951 - }
93952 -
93953 - hdr = register_net_sysctl(net, "net/netfilter", table);
93954 + hdr = register_net_sysctl(net, "net/netfilter", table);
93955 + } else
93956 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93957 if (hdr == NULL)
93958 goto err_reg;
93959
93960 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93961 return 0;
93962
93963 err_reg:
93964 - if (!net_eq(net, &init_net))
93965 - kfree(table);
93966 + kfree(table);
93967 err_alloc:
93968 return -ENOMEM;
93969 }
93970 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93971 index ab92a36..bb4a528 100644
93972 --- a/net/ipv6/output_core.c
93973 +++ b/net/ipv6/output_core.c
93974 @@ -8,8 +8,8 @@
93975
93976 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93977 {
93978 - static atomic_t ipv6_fragmentation_id;
93979 - int old, new;
93980 + static atomic_unchecked_t ipv6_fragmentation_id;
93981 + int id;
93982
93983 #if IS_ENABLED(CONFIG_IPV6)
93984 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93985 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93986 }
93987 }
93988 #endif
93989 - do {
93990 - old = atomic_read(&ipv6_fragmentation_id);
93991 - new = old + 1;
93992 - if (!new)
93993 - new = 1;
93994 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93995 - fhdr->identification = htonl(new);
93996 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93997 + if (!id)
93998 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93999 + fhdr->identification = htonl(id);
94000 }
94001 EXPORT_SYMBOL(ipv6_select_ident);
94002
94003 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
94004 index 18f19df..b46ada1 100644
94005 --- a/net/ipv6/ping.c
94006 +++ b/net/ipv6/ping.c
94007 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
94008 };
94009 #endif
94010
94011 +static struct pingv6_ops real_pingv6_ops = {
94012 + .ipv6_recv_error = ipv6_recv_error,
94013 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
94014 + .icmpv6_err_convert = icmpv6_err_convert,
94015 + .ipv6_icmp_error = ipv6_icmp_error,
94016 + .ipv6_chk_addr = ipv6_chk_addr,
94017 +};
94018 +
94019 +static struct pingv6_ops dummy_pingv6_ops = {
94020 + .ipv6_recv_error = dummy_ipv6_recv_error,
94021 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
94022 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
94023 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
94024 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
94025 +};
94026 +
94027 int __init pingv6_init(void)
94028 {
94029 #ifdef CONFIG_PROC_FS
94030 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
94031 if (ret)
94032 return ret;
94033 #endif
94034 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
94035 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
94036 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
94037 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
94038 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
94039 + pingv6_ops = &real_pingv6_ops;
94040 return inet6_register_protosw(&pingv6_protosw);
94041 }
94042
94043 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
94044 */
94045 void pingv6_exit(void)
94046 {
94047 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
94048 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
94049 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
94050 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
94051 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
94052 + pingv6_ops = &dummy_pingv6_ops;
94053 #ifdef CONFIG_PROC_FS
94054 unregister_pernet_subsys(&ping_v6_net_ops);
94055 #endif
94056 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
94057 index cdaed47..515edde9 100644
94058 --- a/net/ipv6/raw.c
94059 +++ b/net/ipv6/raw.c
94060 @@ -108,7 +108,7 @@ found:
94061 */
94062 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
94063 {
94064 - struct icmp6hdr *_hdr;
94065 + struct icmp6hdr _hdr;
94066 const struct icmp6hdr *hdr;
94067
94068 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
94069 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
94070 {
94071 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
94072 skb_checksum_complete(skb)) {
94073 - atomic_inc(&sk->sk_drops);
94074 + atomic_inc_unchecked(&sk->sk_drops);
94075 kfree_skb(skb);
94076 return NET_RX_DROP;
94077 }
94078 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94079 struct raw6_sock *rp = raw6_sk(sk);
94080
94081 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
94082 - atomic_inc(&sk->sk_drops);
94083 + atomic_inc_unchecked(&sk->sk_drops);
94084 kfree_skb(skb);
94085 return NET_RX_DROP;
94086 }
94087 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94088
94089 if (inet->hdrincl) {
94090 if (skb_checksum_complete(skb)) {
94091 - atomic_inc(&sk->sk_drops);
94092 + atomic_inc_unchecked(&sk->sk_drops);
94093 kfree_skb(skb);
94094 return NET_RX_DROP;
94095 }
94096 @@ -602,7 +602,7 @@ out:
94097 return err;
94098 }
94099
94100 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
94101 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
94102 struct flowi6 *fl6, struct dst_entry **dstp,
94103 unsigned int flags)
94104 {
94105 @@ -915,12 +915,15 @@ do_confirm:
94106 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
94107 char __user *optval, int optlen)
94108 {
94109 + struct icmp6_filter filter;
94110 +
94111 switch (optname) {
94112 case ICMPV6_FILTER:
94113 if (optlen > sizeof(struct icmp6_filter))
94114 optlen = sizeof(struct icmp6_filter);
94115 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
94116 + if (copy_from_user(&filter, optval, optlen))
94117 return -EFAULT;
94118 + raw6_sk(sk)->filter = filter;
94119 return 0;
94120 default:
94121 return -ENOPROTOOPT;
94122 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94123 char __user *optval, int __user *optlen)
94124 {
94125 int len;
94126 + struct icmp6_filter filter;
94127
94128 switch (optname) {
94129 case ICMPV6_FILTER:
94130 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94131 len = sizeof(struct icmp6_filter);
94132 if (put_user(len, optlen))
94133 return -EFAULT;
94134 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
94135 + filter = raw6_sk(sk)->filter;
94136 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
94137 return -EFAULT;
94138 return 0;
94139 default:
94140 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
94141 index 1aeb473..bea761c 100644
94142 --- a/net/ipv6/reassembly.c
94143 +++ b/net/ipv6/reassembly.c
94144 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
94145
94146 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94147 {
94148 - struct ctl_table *table;
94149 + ctl_table_no_const *table = NULL;
94150 struct ctl_table_header *hdr;
94151
94152 - table = ip6_frags_ns_ctl_table;
94153 if (!net_eq(net, &init_net)) {
94154 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94155 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94156 if (table == NULL)
94157 goto err_alloc;
94158
94159 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94160 /* Don't export sysctls to unprivileged users */
94161 if (net->user_ns != &init_user_ns)
94162 table[0].procname = NULL;
94163 - }
94164 + hdr = register_net_sysctl(net, "net/ipv6", table);
94165 + } else
94166 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
94167
94168 - hdr = register_net_sysctl(net, "net/ipv6", table);
94169 if (hdr == NULL)
94170 goto err_reg;
94171
94172 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(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/ipv6/route.c b/net/ipv6/route.c
94183 index c9bd97b..a15506e 100644
94184 --- a/net/ipv6/route.c
94185 +++ b/net/ipv6/route.c
94186 @@ -2957,7 +2957,7 @@ struct ctl_table ipv6_route_table_template[] = {
94187
94188 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
94189 {
94190 - struct ctl_table *table;
94191 + ctl_table_no_const *table;
94192
94193 table = kmemdup(ipv6_route_table_template,
94194 sizeof(ipv6_route_table_template),
94195 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
94196 index a51ad07..a90bc19 100644
94197 --- a/net/ipv6/sit.c
94198 +++ b/net/ipv6/sit.c
94199 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
94200 static void ipip6_dev_free(struct net_device *dev);
94201 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
94202 __be32 *v4dst);
94203 -static struct rtnl_link_ops sit_link_ops __read_mostly;
94204 +static struct rtnl_link_ops sit_link_ops;
94205
94206 static int sit_net_id __read_mostly;
94207 struct sit_net {
94208 @@ -1601,7 +1601,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
94209 #endif
94210 };
94211
94212 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
94213 +static struct rtnl_link_ops sit_link_ops = {
94214 .kind = "sit",
94215 .maxtype = IFLA_IPTUN_MAX,
94216 .policy = ipip6_policy,
94217 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
94218 index 107b2f1..72741a9 100644
94219 --- a/net/ipv6/sysctl_net_ipv6.c
94220 +++ b/net/ipv6/sysctl_net_ipv6.c
94221 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
94222
94223 static int __net_init ipv6_sysctl_net_init(struct net *net)
94224 {
94225 - struct ctl_table *ipv6_table;
94226 + ctl_table_no_const *ipv6_table;
94227 struct ctl_table *ipv6_route_table;
94228 struct ctl_table *ipv6_icmp_table;
94229 int err;
94230 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
94231 index 6e1649d..75ddb4c 100644
94232 --- a/net/ipv6/tcp_ipv6.c
94233 +++ b/net/ipv6/tcp_ipv6.c
94234 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
94235 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
94236 }
94237
94238 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94239 +extern int grsec_enable_blackhole;
94240 +#endif
94241 +
94242 static void tcp_v6_hash(struct sock *sk)
94243 {
94244 if (sk->sk_state != TCP_CLOSE) {
94245 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
94246 return 0;
94247
94248 reset:
94249 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94250 + if (!grsec_enable_blackhole)
94251 +#endif
94252 tcp_v6_send_reset(sk, skb);
94253 discard:
94254 if (opt_skb)
94255 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
94256 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
94257 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
94258 if (np->rxopt.bits.rxtclass)
94259 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
94260 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
94261 if (ipv6_opt_accepted(sk, opt_skb)) {
94262 skb_set_owner_r(opt_skb, sk);
94263 opt_skb = xchg(&np->pktoptions, opt_skb);
94264 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
94265 TCP_SKB_CB(skb)->sacked = 0;
94266
94267 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94268 - if (!sk)
94269 + if (!sk) {
94270 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94271 + ret = 1;
94272 +#endif
94273 goto no_tcp_socket;
94274 + }
94275
94276 process:
94277 - if (sk->sk_state == TCP_TIME_WAIT)
94278 + if (sk->sk_state == TCP_TIME_WAIT) {
94279 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94280 + ret = 2;
94281 +#endif
94282 goto do_time_wait;
94283 + }
94284
94285 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
94286 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94287 @@ -1538,6 +1553,10 @@ csum_error:
94288 bad_packet:
94289 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94290 } else {
94291 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94292 + if (!grsec_enable_blackhole || (ret == 1 &&
94293 + (skb->dev->flags & IFF_LOOPBACK)))
94294 +#endif
94295 tcp_v6_send_reset(NULL, skb);
94296 }
94297
94298 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
94299 index f405815..45a68a6 100644
94300 --- a/net/ipv6/udp.c
94301 +++ b/net/ipv6/udp.c
94302 @@ -53,6 +53,10 @@
94303 #include <trace/events/skb.h>
94304 #include "udp_impl.h"
94305
94306 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94307 +extern int grsec_enable_blackhole;
94308 +#endif
94309 +
94310 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
94311 {
94312 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
94313 @@ -420,7 +424,7 @@ try_again:
94314 if (unlikely(err)) {
94315 trace_kfree_skb(skb, udpv6_recvmsg);
94316 if (!peeked) {
94317 - atomic_inc(&sk->sk_drops);
94318 + atomic_inc_unchecked(&sk->sk_drops);
94319 if (is_udp4)
94320 UDP_INC_STATS_USER(sock_net(sk),
94321 UDP_MIB_INERRORS,
94322 @@ -666,7 +670,7 @@ csum_error:
94323 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94324 drop:
94325 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94326 - atomic_inc(&sk->sk_drops);
94327 + atomic_inc_unchecked(&sk->sk_drops);
94328 kfree_skb(skb);
94329 return -1;
94330 }
94331 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94332 if (likely(skb1 == NULL))
94333 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94334 if (!skb1) {
94335 - atomic_inc(&sk->sk_drops);
94336 + atomic_inc_unchecked(&sk->sk_drops);
94337 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94338 IS_UDPLITE(sk));
94339 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94340 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94341 goto csum_error;
94342
94343 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94344 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94345 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94346 +#endif
94347 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
94348
94349 kfree_skb(skb);
94350 diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
94351 index 5d1b8d7..657914b 100644
94352 --- a/net/ipv6/udp_offload.c
94353 +++ b/net/ipv6/udp_offload.c
94354 @@ -86,7 +86,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
94355
94356 /* Check if there is enough headroom to insert fragment header. */
94357 tnl_hlen = skb_tnl_header_len(skb);
94358 - if (skb_headroom(skb) < (tnl_hlen + frag_hdr_sz)) {
94359 + if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
94360 if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
94361 goto out;
94362 }
94363 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
94364 index 23ed03d..6532e67 100644
94365 --- a/net/ipv6/xfrm6_policy.c
94366 +++ b/net/ipv6/xfrm6_policy.c
94367 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
94368 }
94369 }
94370
94371 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
94372 +static int xfrm6_garbage_collect(struct dst_ops *ops)
94373 {
94374 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94375
94376 - xfrm6_policy_afinfo.garbage_collect(net);
94377 + xfrm_garbage_collect_deferred(net);
94378 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94379 }
94380
94381 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94382
94383 static int __net_init xfrm6_net_init(struct net *net)
94384 {
94385 - struct ctl_table *table;
94386 + ctl_table_no_const *table = NULL;
94387 struct ctl_table_header *hdr;
94388
94389 - table = xfrm6_policy_table;
94390 if (!net_eq(net, &init_net)) {
94391 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94392 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94393 if (!table)
94394 goto err_alloc;
94395
94396 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94397 - }
94398 + hdr = register_net_sysctl(net, "net/ipv6", table);
94399 + } else
94400 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94401
94402 - hdr = register_net_sysctl(net, "net/ipv6", table);
94403 if (!hdr)
94404 goto err_reg;
94405
94406 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
94407 return 0;
94408
94409 err_reg:
94410 - if (!net_eq(net, &init_net))
94411 - kfree(table);
94412 + kfree(table);
94413 err_alloc:
94414 return -ENOMEM;
94415 }
94416 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
94417 index 41ac7938..75e3bb1 100644
94418 --- a/net/irda/ircomm/ircomm_tty.c
94419 +++ b/net/irda/ircomm/ircomm_tty.c
94420 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94421 add_wait_queue(&port->open_wait, &wait);
94422
94423 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
94424 - __FILE__, __LINE__, tty->driver->name, port->count);
94425 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94426
94427 spin_lock_irqsave(&port->lock, flags);
94428 if (!tty_hung_up_p(filp))
94429 - port->count--;
94430 + atomic_dec(&port->count);
94431 port->blocked_open++;
94432 spin_unlock_irqrestore(&port->lock, flags);
94433
94434 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94435 }
94436
94437 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
94438 - __FILE__, __LINE__, tty->driver->name, port->count);
94439 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94440
94441 schedule();
94442 }
94443 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94444
94445 spin_lock_irqsave(&port->lock, flags);
94446 if (!tty_hung_up_p(filp))
94447 - port->count++;
94448 + atomic_inc(&port->count);
94449 port->blocked_open--;
94450 spin_unlock_irqrestore(&port->lock, flags);
94451
94452 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
94453 - __FILE__, __LINE__, tty->driver->name, port->count);
94454 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94455
94456 if (!retval)
94457 port->flags |= ASYNC_NORMAL_ACTIVE;
94458 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
94459
94460 /* ++ is not atomic, so this should be protected - Jean II */
94461 spin_lock_irqsave(&self->port.lock, flags);
94462 - self->port.count++;
94463 + atomic_inc(&self->port.count);
94464 spin_unlock_irqrestore(&self->port.lock, flags);
94465 tty_port_tty_set(&self->port, tty);
94466
94467 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
94468 - self->line, self->port.count);
94469 + self->line, atomic_read(&self->port.count));
94470
94471 /* Not really used by us, but lets do it anyway */
94472 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
94473 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
94474 tty_kref_put(port->tty);
94475 }
94476 port->tty = NULL;
94477 - port->count = 0;
94478 + atomic_set(&port->count, 0);
94479 spin_unlock_irqrestore(&port->lock, flags);
94480
94481 wake_up_interruptible(&port->open_wait);
94482 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
94483 seq_putc(m, '\n');
94484
94485 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
94486 - seq_printf(m, "Open count: %d\n", self->port.count);
94487 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
94488 seq_printf(m, "Max data size: %d\n", self->max_data_size);
94489 seq_printf(m, "Max header size: %d\n", self->max_header_size);
94490
94491 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
94492 index 168aff5..9d43132 100644
94493 --- a/net/iucv/af_iucv.c
94494 +++ b/net/iucv/af_iucv.c
94495 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
94496
94497 write_lock_bh(&iucv_sk_list.lock);
94498
94499 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
94500 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94501 while (__iucv_get_sock_by_name(name)) {
94502 sprintf(name, "%08x",
94503 - atomic_inc_return(&iucv_sk_list.autobind_name));
94504 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94505 }
94506
94507 write_unlock_bh(&iucv_sk_list.lock);
94508 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
94509 index cd5b8ec..f205e6b 100644
94510 --- a/net/iucv/iucv.c
94511 +++ b/net/iucv/iucv.c
94512 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
94513 return NOTIFY_OK;
94514 }
94515
94516 -static struct notifier_block __refdata iucv_cpu_notifier = {
94517 +static struct notifier_block iucv_cpu_notifier = {
94518 .notifier_call = iucv_cpu_notify,
94519 };
94520
94521 diff --git a/net/key/af_key.c b/net/key/af_key.c
94522 index ab8bd2c..3a3eb81 100644
94523 --- a/net/key/af_key.c
94524 +++ b/net/key/af_key.c
94525 @@ -1098,7 +1098,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
94526
94527 x->id.proto = proto;
94528 x->id.spi = sa->sadb_sa_spi;
94529 - x->props.replay_window = sa->sadb_sa_replay;
94530 + x->props.replay_window = min_t(unsigned int, sa->sadb_sa_replay,
94531 + (sizeof(x->replay.bitmap) * 8));
94532 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN)
94533 x->props.flags |= XFRM_STATE_NOECN;
94534 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
94535 @@ -3048,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
94536 static u32 get_acqseq(void)
94537 {
94538 u32 res;
94539 - static atomic_t acqseq;
94540 + static atomic_unchecked_t acqseq;
94541
94542 do {
94543 - res = atomic_inc_return(&acqseq);
94544 + res = atomic_inc_return_unchecked(&acqseq);
94545 } while (!res);
94546 return res;
94547 }
94548 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
94549 index b076e83..793e6ff 100644
94550 --- a/net/l2tp/l2tp_core.c
94551 +++ b/net/l2tp/l2tp_core.c
94552 @@ -501,6 +501,7 @@ out:
94553 static inline int l2tp_verify_udp_checksum(struct sock *sk,
94554 struct sk_buff *skb)
94555 {
94556 + struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
94557 struct udphdr *uh = udp_hdr(skb);
94558 u16 ulen = ntohs(uh->len);
94559 __wsum psum;
94560 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
94561 index a4b2154..b2fef6f 100644
94562 --- a/net/mac80211/cfg.c
94563 +++ b/net/mac80211/cfg.c
94564 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
94565 ret = ieee80211_vif_use_channel(sdata, chandef,
94566 IEEE80211_CHANCTX_EXCLUSIVE);
94567 }
94568 - } else if (local->open_count == local->monitors) {
94569 + } else if (local_read(&local->open_count) == local->monitors) {
94570 local->_oper_chandef = *chandef;
94571 ieee80211_hw_config(local, 0);
94572 }
94573 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
94574 else
94575 local->probe_req_reg--;
94576
94577 - if (!local->open_count)
94578 + if (!local_read(&local->open_count))
94579 break;
94580
94581 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
94582 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
94583 if (chanctx_conf) {
94584 *chandef = chanctx_conf->def;
94585 ret = 0;
94586 - } else if (local->open_count > 0 &&
94587 - local->open_count == local->monitors &&
94588 + } else if (local_read(&local->open_count) > 0 &&
94589 + local_read(&local->open_count) == local->monitors &&
94590 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
94591 if (local->use_chanctx)
94592 *chandef = local->monitor_chandef;
94593 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
94594 index 8c0f8e6..438e580 100644
94595 --- a/net/mac80211/ieee80211_i.h
94596 +++ b/net/mac80211/ieee80211_i.h
94597 @@ -28,6 +28,7 @@
94598 #include <net/ieee80211_radiotap.h>
94599 #include <net/cfg80211.h>
94600 #include <net/mac80211.h>
94601 +#include <asm/local.h>
94602 #include "key.h"
94603 #include "sta_info.h"
94604 #include "debug.h"
94605 @@ -910,7 +911,7 @@ struct ieee80211_local {
94606 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
94607 spinlock_t queue_stop_reason_lock;
94608
94609 - int open_count;
94610 + local_t open_count;
94611 int monitors, cooked_mntrs;
94612 /* number of interfaces with corresponding FIF_ flags */
94613 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94614 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94615 index cc11759..11d5541 100644
94616 --- a/net/mac80211/iface.c
94617 +++ b/net/mac80211/iface.c
94618 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94619 break;
94620 }
94621
94622 - if (local->open_count == 0) {
94623 + if (local_read(&local->open_count) == 0) {
94624 res = drv_start(local);
94625 if (res)
94626 goto err_del_bss;
94627 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94628 res = drv_add_interface(local, sdata);
94629 if (res)
94630 goto err_stop;
94631 - } else if (local->monitors == 0 && local->open_count == 0) {
94632 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94633 res = ieee80211_add_virtual_monitor(local);
94634 if (res)
94635 goto err_stop;
94636 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94637 atomic_inc(&local->iff_promiscs);
94638
94639 if (coming_up)
94640 - local->open_count++;
94641 + local_inc(&local->open_count);
94642
94643 if (hw_reconf_flags)
94644 ieee80211_hw_config(local, hw_reconf_flags);
94645 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94646 err_del_interface:
94647 drv_remove_interface(local, sdata);
94648 err_stop:
94649 - if (!local->open_count)
94650 + if (!local_read(&local->open_count))
94651 drv_stop(local);
94652 err_del_bss:
94653 sdata->bss = NULL;
94654 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94655 }
94656
94657 if (going_down)
94658 - local->open_count--;
94659 + local_dec(&local->open_count);
94660
94661 switch (sdata->vif.type) {
94662 case NL80211_IFTYPE_AP_VLAN:
94663 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94664 }
94665 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94666
94667 - if (local->open_count == 0)
94668 + if (local_read(&local->open_count) == 0)
94669 ieee80211_clear_tx_pending(local);
94670
94671 /*
94672 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94673
94674 ieee80211_recalc_ps(local, -1);
94675
94676 - if (local->open_count == 0) {
94677 + if (local_read(&local->open_count) == 0) {
94678 ieee80211_stop_device(local);
94679
94680 /* no reconfiguring after stop! */
94681 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94682 ieee80211_configure_filter(local);
94683 ieee80211_hw_config(local, hw_reconf_flags);
94684
94685 - if (local->monitors == local->open_count)
94686 + if (local->monitors == local_read(&local->open_count))
94687 ieee80211_add_virtual_monitor(local);
94688 }
94689
94690 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94691 index 091088a..daf43c7 100644
94692 --- a/net/mac80211/main.c
94693 +++ b/net/mac80211/main.c
94694 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94695 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94696 IEEE80211_CONF_CHANGE_POWER);
94697
94698 - if (changed && local->open_count) {
94699 + if (changed && local_read(&local->open_count)) {
94700 ret = drv_config(local, changed);
94701 /*
94702 * Goal:
94703 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94704 index 3401262..d5cd68d 100644
94705 --- a/net/mac80211/pm.c
94706 +++ b/net/mac80211/pm.c
94707 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94708 struct ieee80211_sub_if_data *sdata;
94709 struct sta_info *sta;
94710
94711 - if (!local->open_count)
94712 + if (!local_read(&local->open_count))
94713 goto suspend;
94714
94715 ieee80211_scan_cancel(local);
94716 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94717 cancel_work_sync(&local->dynamic_ps_enable_work);
94718 del_timer_sync(&local->dynamic_ps_timer);
94719
94720 - local->wowlan = wowlan && local->open_count;
94721 + local->wowlan = wowlan && local_read(&local->open_count);
94722 if (local->wowlan) {
94723 int err = drv_suspend(local, wowlan);
94724 if (err < 0) {
94725 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94726 WARN_ON(!list_empty(&local->chanctx_list));
94727
94728 /* stop hardware - this must stop RX */
94729 - if (local->open_count)
94730 + if (local_read(&local->open_count))
94731 ieee80211_stop_device(local);
94732
94733 suspend:
94734 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94735 index 30d58d2..449ac8e 100644
94736 --- a/net/mac80211/rate.c
94737 +++ b/net/mac80211/rate.c
94738 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94739
94740 ASSERT_RTNL();
94741
94742 - if (local->open_count)
94743 + if (local_read(&local->open_count))
94744 return -EBUSY;
94745
94746 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94747 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94748 index c97a065..ff61928 100644
94749 --- a/net/mac80211/rc80211_pid_debugfs.c
94750 +++ b/net/mac80211/rc80211_pid_debugfs.c
94751 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94752
94753 spin_unlock_irqrestore(&events->lock, status);
94754
94755 - if (copy_to_user(buf, pb, p))
94756 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94757 return -EFAULT;
94758
94759 return p;
94760 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94761 index 31e78ae..f2a7381 100644
94762 --- a/net/mac80211/util.c
94763 +++ b/net/mac80211/util.c
94764 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94765 }
94766 #endif
94767 /* everything else happens only if HW was up & running */
94768 - if (!local->open_count)
94769 + if (!local_read(&local->open_count))
94770 goto wake_up;
94771
94772 /*
94773 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94774 local->in_reconfig = false;
94775 barrier();
94776
94777 - if (local->monitors == local->open_count && local->monitors > 0)
94778 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94779 ieee80211_add_virtual_monitor(local);
94780
94781 /*
94782 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94783 index 56d22ca..87c778f 100644
94784 --- a/net/netfilter/Kconfig
94785 +++ b/net/netfilter/Kconfig
94786 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94787
94788 To compile it as a module, choose M here. If unsure, say N.
94789
94790 +config NETFILTER_XT_MATCH_GRADM
94791 + tristate '"gradm" match support'
94792 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94793 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94794 + ---help---
94795 + The gradm match allows to match on grsecurity RBAC being enabled.
94796 + It is useful when iptables rules are applied early on bootup to
94797 + prevent connections to the machine (except from a trusted host)
94798 + while the RBAC system is disabled.
94799 +
94800 config NETFILTER_XT_MATCH_HASHLIMIT
94801 tristate '"hashlimit" match support'
94802 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94803 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94804 index a1abf87..dbcb7ee 100644
94805 --- a/net/netfilter/Makefile
94806 +++ b/net/netfilter/Makefile
94807 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94808 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94809 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94810 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94811 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94812 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94813 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94814 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94815 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94816 index f771390..145b765 100644
94817 --- a/net/netfilter/ipset/ip_set_core.c
94818 +++ b/net/netfilter/ipset/ip_set_core.c
94819 @@ -1820,7 +1820,7 @@ done:
94820 return ret;
94821 }
94822
94823 -static struct nf_sockopt_ops so_set __read_mostly = {
94824 +static struct nf_sockopt_ops so_set = {
94825 .pf = PF_INET,
94826 .get_optmin = SO_IP_SET,
94827 .get_optmax = SO_IP_SET + 1,
94828 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94829 index 4c8e5c0..5a79b4d 100644
94830 --- a/net/netfilter/ipvs/ip_vs_conn.c
94831 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94832 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94833 /* Increase the refcnt counter of the dest */
94834 ip_vs_dest_hold(dest);
94835
94836 - conn_flags = atomic_read(&dest->conn_flags);
94837 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94838 if (cp->protocol != IPPROTO_UDP)
94839 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94840 flags = cp->flags;
94841 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94842
94843 cp->control = NULL;
94844 atomic_set(&cp->n_control, 0);
94845 - atomic_set(&cp->in_pkts, 0);
94846 + atomic_set_unchecked(&cp->in_pkts, 0);
94847
94848 cp->packet_xmit = NULL;
94849 cp->app = NULL;
94850 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94851
94852 /* Don't drop the entry if its number of incoming packets is not
94853 located in [0, 8] */
94854 - i = atomic_read(&cp->in_pkts);
94855 + i = atomic_read_unchecked(&cp->in_pkts);
94856 if (i > 8 || i < 0) return 0;
94857
94858 if (!todrop_rate[i]) return 0;
94859 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94860 index 4f69e83..da2d8bf 100644
94861 --- a/net/netfilter/ipvs/ip_vs_core.c
94862 +++ b/net/netfilter/ipvs/ip_vs_core.c
94863 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94864 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94865 /* do not touch skb anymore */
94866
94867 - atomic_inc(&cp->in_pkts);
94868 + atomic_inc_unchecked(&cp->in_pkts);
94869 ip_vs_conn_put(cp);
94870 return ret;
94871 }
94872 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94873 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94874 pkts = sysctl_sync_threshold(ipvs);
94875 else
94876 - pkts = atomic_add_return(1, &cp->in_pkts);
94877 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94878
94879 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94880 ip_vs_sync_conn(net, cp, pkts);
94881 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94882 index c8148e4..eff604f 100644
94883 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94884 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94885 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94886 */
94887 ip_vs_rs_hash(ipvs, dest);
94888 }
94889 - atomic_set(&dest->conn_flags, conn_flags);
94890 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94891
94892 /* bind the service */
94893 if (!dest->svc) {
94894 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94895 * align with netns init in ip_vs_control_net_init()
94896 */
94897
94898 -static struct ctl_table vs_vars[] = {
94899 +static ctl_table_no_const vs_vars[] __read_only = {
94900 {
94901 .procname = "amemthresh",
94902 .maxlen = sizeof(int),
94903 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94904 " %-7s %-6d %-10d %-10d\n",
94905 &dest->addr.in6,
94906 ntohs(dest->port),
94907 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94908 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94909 atomic_read(&dest->weight),
94910 atomic_read(&dest->activeconns),
94911 atomic_read(&dest->inactconns));
94912 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94913 "%-7s %-6d %-10d %-10d\n",
94914 ntohl(dest->addr.ip),
94915 ntohs(dest->port),
94916 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94917 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94918 atomic_read(&dest->weight),
94919 atomic_read(&dest->activeconns),
94920 atomic_read(&dest->inactconns));
94921 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94922
94923 entry.addr = dest->addr.ip;
94924 entry.port = dest->port;
94925 - entry.conn_flags = atomic_read(&dest->conn_flags);
94926 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94927 entry.weight = atomic_read(&dest->weight);
94928 entry.u_threshold = dest->u_threshold;
94929 entry.l_threshold = dest->l_threshold;
94930 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94931 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94932 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94933 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94934 - (atomic_read(&dest->conn_flags) &
94935 + (atomic_read_unchecked(&dest->conn_flags) &
94936 IP_VS_CONN_F_FWD_MASK)) ||
94937 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94938 atomic_read(&dest->weight)) ||
94939 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94940 {
94941 int idx;
94942 struct netns_ipvs *ipvs = net_ipvs(net);
94943 - struct ctl_table *tbl;
94944 + ctl_table_no_const *tbl;
94945
94946 atomic_set(&ipvs->dropentry, 0);
94947 spin_lock_init(&ipvs->dropentry_lock);
94948 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94949 index 1383b0e..a486da1 100644
94950 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94951 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94952 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94953 * IPVS LBLC sysctl table
94954 */
94955 #ifdef CONFIG_SYSCTL
94956 -static struct ctl_table vs_vars_table[] = {
94957 +static ctl_table_no_const vs_vars_table[] __read_only = {
94958 {
94959 .procname = "lblc_expiration",
94960 .data = NULL,
94961 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94962 index 3cd85b2..dfab2b8 100644
94963 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94964 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94965 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94966 * IPVS LBLCR sysctl table
94967 */
94968
94969 -static struct ctl_table vs_vars_table[] = {
94970 +static ctl_table_no_const vs_vars_table[] __read_only = {
94971 {
94972 .procname = "lblcr_expiration",
94973 .data = NULL,
94974 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94975 index f448471..995f131 100644
94976 --- a/net/netfilter/ipvs/ip_vs_sync.c
94977 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94978 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94979 cp = cp->control;
94980 if (cp) {
94981 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94982 - pkts = atomic_add_return(1, &cp->in_pkts);
94983 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94984 else
94985 pkts = sysctl_sync_threshold(ipvs);
94986 ip_vs_sync_conn(net, cp->control, pkts);
94987 @@ -771,7 +771,7 @@ control:
94988 if (!cp)
94989 return;
94990 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94991 - pkts = atomic_add_return(1, &cp->in_pkts);
94992 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94993 else
94994 pkts = sysctl_sync_threshold(ipvs);
94995 goto sloop;
94996 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94997
94998 if (opt)
94999 memcpy(&cp->in_seq, opt, sizeof(*opt));
95000 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95001 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95002 cp->state = state;
95003 cp->old_state = cp->state;
95004 /*
95005 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
95006 index c47444e..b0961c6 100644
95007 --- a/net/netfilter/ipvs/ip_vs_xmit.c
95008 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
95009 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
95010 else
95011 rc = NF_ACCEPT;
95012 /* do not touch skb anymore */
95013 - atomic_inc(&cp->in_pkts);
95014 + atomic_inc_unchecked(&cp->in_pkts);
95015 goto out;
95016 }
95017
95018 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
95019 else
95020 rc = NF_ACCEPT;
95021 /* do not touch skb anymore */
95022 - atomic_inc(&cp->in_pkts);
95023 + atomic_inc_unchecked(&cp->in_pkts);
95024 goto out;
95025 }
95026
95027 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
95028 index 2d3030a..7ba1c0a 100644
95029 --- a/net/netfilter/nf_conntrack_acct.c
95030 +++ b/net/netfilter/nf_conntrack_acct.c
95031 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
95032 #ifdef CONFIG_SYSCTL
95033 static int nf_conntrack_acct_init_sysctl(struct net *net)
95034 {
95035 - struct ctl_table *table;
95036 + ctl_table_no_const *table;
95037
95038 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
95039 GFP_KERNEL);
95040 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
95041 index 0283bae..5febcb0 100644
95042 --- a/net/netfilter/nf_conntrack_core.c
95043 +++ b/net/netfilter/nf_conntrack_core.c
95044 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
95045 #define DYING_NULLS_VAL ((1<<30)+1)
95046 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
95047
95048 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95049 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
95050 +#endif
95051 +
95052 int nf_conntrack_init_net(struct net *net)
95053 {
95054 int ret;
95055 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
95056 goto err_stat;
95057 }
95058
95059 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95060 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
95061 +#else
95062 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
95063 +#endif
95064 if (!net->ct.slabname) {
95065 ret = -ENOMEM;
95066 goto err_slabname;
95067 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
95068 index 1df1761..ce8b88a 100644
95069 --- a/net/netfilter/nf_conntrack_ecache.c
95070 +++ b/net/netfilter/nf_conntrack_ecache.c
95071 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
95072 #ifdef CONFIG_SYSCTL
95073 static int nf_conntrack_event_init_sysctl(struct net *net)
95074 {
95075 - struct ctl_table *table;
95076 + ctl_table_no_const *table;
95077
95078 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
95079 GFP_KERNEL);
95080 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
95081 index 974a2a4..52cc6ff 100644
95082 --- a/net/netfilter/nf_conntrack_helper.c
95083 +++ b/net/netfilter/nf_conntrack_helper.c
95084 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
95085
95086 static int nf_conntrack_helper_init_sysctl(struct net *net)
95087 {
95088 - struct ctl_table *table;
95089 + ctl_table_no_const *table;
95090
95091 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
95092 GFP_KERNEL);
95093 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
95094 index 0ab9636..cea3c6a 100644
95095 --- a/net/netfilter/nf_conntrack_proto.c
95096 +++ b/net/netfilter/nf_conntrack_proto.c
95097 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
95098
95099 static void
95100 nf_ct_unregister_sysctl(struct ctl_table_header **header,
95101 - struct ctl_table **table,
95102 + ctl_table_no_const **table,
95103 unsigned int users)
95104 {
95105 if (users > 0)
95106 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
95107 index a99b6c3..cb372f9 100644
95108 --- a/net/netfilter/nf_conntrack_proto_dccp.c
95109 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
95110 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95111 const char *msg;
95112 u_int8_t state;
95113
95114 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95115 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95116 BUG_ON(dh == NULL);
95117
95118 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
95119 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95120 out_invalid:
95121 if (LOG_INVALID(net, IPPROTO_DCCP))
95122 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
95123 - NULL, msg);
95124 + NULL, "%s", msg);
95125 return false;
95126 }
95127
95128 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
95129 u_int8_t type, old_state, new_state;
95130 enum ct_dccp_roles role;
95131
95132 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95133 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95134 BUG_ON(dh == NULL);
95135 type = dh->dccph_type;
95136
95137 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95138 unsigned int cscov;
95139 const char *msg;
95140
95141 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95142 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95143 if (dh == NULL) {
95144 msg = "nf_ct_dccp: short packet ";
95145 goto out_invalid;
95146 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95147
95148 out_invalid:
95149 if (LOG_INVALID(net, IPPROTO_DCCP))
95150 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
95151 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
95152 return -NF_ACCEPT;
95153 }
95154
95155 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
95156 index f641751..d3c5b51 100644
95157 --- a/net/netfilter/nf_conntrack_standalone.c
95158 +++ b/net/netfilter/nf_conntrack_standalone.c
95159 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
95160
95161 static int nf_conntrack_standalone_init_sysctl(struct net *net)
95162 {
95163 - struct ctl_table *table;
95164 + ctl_table_no_const *table;
95165
95166 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
95167 GFP_KERNEL);
95168 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
95169 index 902fb0a..87f7fdb 100644
95170 --- a/net/netfilter/nf_conntrack_timestamp.c
95171 +++ b/net/netfilter/nf_conntrack_timestamp.c
95172 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
95173 #ifdef CONFIG_SYSCTL
95174 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
95175 {
95176 - struct ctl_table *table;
95177 + ctl_table_no_const *table;
95178
95179 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
95180 GFP_KERNEL);
95181 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
95182 index 85296d4..8becdec 100644
95183 --- a/net/netfilter/nf_log.c
95184 +++ b/net/netfilter/nf_log.c
95185 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
95186
95187 #ifdef CONFIG_SYSCTL
95188 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
95189 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
95190 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
95191
95192 static int nf_log_proc_dostring(struct ctl_table *table, int write,
95193 void __user *buffer, size_t *lenp, loff_t *ppos)
95194 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
95195 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
95196 mutex_unlock(&nf_log_mutex);
95197 } else {
95198 + ctl_table_no_const nf_log_table = *table;
95199 +
95200 mutex_lock(&nf_log_mutex);
95201 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
95202 lockdep_is_held(&nf_log_mutex));
95203 if (!logger)
95204 - table->data = "NONE";
95205 + nf_log_table.data = "NONE";
95206 else
95207 - table->data = logger->name;
95208 - r = proc_dostring(table, write, buffer, lenp, ppos);
95209 + nf_log_table.data = logger->name;
95210 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
95211 mutex_unlock(&nf_log_mutex);
95212 }
95213
95214 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
95215 index f042ae5..30ea486 100644
95216 --- a/net/netfilter/nf_sockopt.c
95217 +++ b/net/netfilter/nf_sockopt.c
95218 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
95219 }
95220 }
95221
95222 - list_add(&reg->list, &nf_sockopts);
95223 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
95224 out:
95225 mutex_unlock(&nf_sockopt_mutex);
95226 return ret;
95227 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
95228 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
95229 {
95230 mutex_lock(&nf_sockopt_mutex);
95231 - list_del(&reg->list);
95232 + pax_list_del((struct list_head *)&reg->list);
95233 mutex_unlock(&nf_sockopt_mutex);
95234 }
95235 EXPORT_SYMBOL(nf_unregister_sockopt);
95236 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
95237 index d92cc31..e46f350 100644
95238 --- a/net/netfilter/nfnetlink_log.c
95239 +++ b/net/netfilter/nfnetlink_log.c
95240 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
95241 struct nfnl_log_net {
95242 spinlock_t instances_lock;
95243 struct hlist_head instance_table[INSTANCE_BUCKETS];
95244 - atomic_t global_seq;
95245 + atomic_unchecked_t global_seq;
95246 };
95247
95248 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
95249 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
95250 /* global sequence number */
95251 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
95252 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
95253 - htonl(atomic_inc_return(&log->global_seq))))
95254 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
95255 goto nla_put_failure;
95256
95257 if (data_len) {
95258 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
95259 new file mode 100644
95260 index 0000000..c566332
95261 --- /dev/null
95262 +++ b/net/netfilter/xt_gradm.c
95263 @@ -0,0 +1,51 @@
95264 +/*
95265 + * gradm match for netfilter
95266 + * Copyright © Zbigniew Krzystolik, 2010
95267 + *
95268 + * This program is free software; you can redistribute it and/or modify
95269 + * it under the terms of the GNU General Public License; either version
95270 + * 2 or 3 as published by the Free Software Foundation.
95271 + */
95272 +#include <linux/module.h>
95273 +#include <linux/moduleparam.h>
95274 +#include <linux/skbuff.h>
95275 +#include <linux/netfilter/x_tables.h>
95276 +#include <linux/grsecurity.h>
95277 +#include <linux/netfilter/xt_gradm.h>
95278 +
95279 +static bool
95280 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
95281 +{
95282 + const struct xt_gradm_mtinfo *info = par->matchinfo;
95283 + bool retval = false;
95284 + if (gr_acl_is_enabled())
95285 + retval = true;
95286 + return retval ^ info->invflags;
95287 +}
95288 +
95289 +static struct xt_match gradm_mt_reg __read_mostly = {
95290 + .name = "gradm",
95291 + .revision = 0,
95292 + .family = NFPROTO_UNSPEC,
95293 + .match = gradm_mt,
95294 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
95295 + .me = THIS_MODULE,
95296 +};
95297 +
95298 +static int __init gradm_mt_init(void)
95299 +{
95300 + return xt_register_match(&gradm_mt_reg);
95301 +}
95302 +
95303 +static void __exit gradm_mt_exit(void)
95304 +{
95305 + xt_unregister_match(&gradm_mt_reg);
95306 +}
95307 +
95308 +module_init(gradm_mt_init);
95309 +module_exit(gradm_mt_exit);
95310 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
95311 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
95312 +MODULE_LICENSE("GPL");
95313 +MODULE_ALIAS("ipt_gradm");
95314 +MODULE_ALIAS("ip6t_gradm");
95315 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
95316 index 4fe4fb4..87a89e5 100644
95317 --- a/net/netfilter/xt_statistic.c
95318 +++ b/net/netfilter/xt_statistic.c
95319 @@ -19,7 +19,7 @@
95320 #include <linux/module.h>
95321
95322 struct xt_statistic_priv {
95323 - atomic_t count;
95324 + atomic_unchecked_t count;
95325 } ____cacheline_aligned_in_smp;
95326
95327 MODULE_LICENSE("GPL");
95328 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
95329 break;
95330 case XT_STATISTIC_MODE_NTH:
95331 do {
95332 - oval = atomic_read(&info->master->count);
95333 + oval = atomic_read_unchecked(&info->master->count);
95334 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
95335 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
95336 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
95337 if (nval == 0)
95338 ret = !ret;
95339 break;
95340 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
95341 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
95342 if (info->master == NULL)
95343 return -ENOMEM;
95344 - atomic_set(&info->master->count, info->u.nth.count);
95345 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
95346
95347 return 0;
95348 }
95349 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
95350 index 0c61b59..941bddd 100644
95351 --- a/net/netlink/af_netlink.c
95352 +++ b/net/netlink/af_netlink.c
95353 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
95354 sk->sk_error_report(sk);
95355 }
95356 }
95357 - atomic_inc(&sk->sk_drops);
95358 + atomic_inc_unchecked(&sk->sk_drops);
95359 }
95360
95361 static void netlink_rcv_wake(struct sock *sk)
95362 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
95363 sk_wmem_alloc_get(s),
95364 nlk->cb,
95365 atomic_read(&s->sk_refcnt),
95366 - atomic_read(&s->sk_drops),
95367 + atomic_read_unchecked(&s->sk_drops),
95368 sock_i_ino(s)
95369 );
95370
95371 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
95372 index 0c741ce..f8c8ca7 100644
95373 --- a/net/netlink/genetlink.c
95374 +++ b/net/netlink/genetlink.c
95375 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95376 goto errout;
95377 }
95378
95379 + pax_open_kernel();
95380 if (ops->dumpit)
95381 - ops->flags |= GENL_CMD_CAP_DUMP;
95382 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95383 if (ops->doit)
95384 - ops->flags |= GENL_CMD_CAP_DO;
95385 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95386 if (ops->policy)
95387 - ops->flags |= GENL_CMD_CAP_HASPOL;
95388 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95389 + pax_close_kernel();
95390
95391 genl_lock_all();
95392 - list_add_tail(&ops->ops_list, &family->ops_list);
95393 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95394 genl_unlock_all();
95395
95396 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95397 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95398 err = 0;
95399 errout:
95400 return err;
95401 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95402 genl_lock_all();
95403 list_for_each_entry(rc, &family->ops_list, ops_list) {
95404 if (rc == ops) {
95405 - list_del(&ops->ops_list);
95406 + pax_list_del((struct list_head *)&ops->ops_list);
95407 genl_unlock_all();
95408 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95409 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95410 return 0;
95411 }
95412 }
95413 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95414 index 698814b..7cfde4e 100644
95415 --- a/net/netrom/af_netrom.c
95416 +++ b/net/netrom/af_netrom.c
95417 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95418 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95419 } else {
95420 sax->fsa_ax25.sax25_family = AF_NETROM;
95421 - sax->fsa_ax25.sax25_ndigis = 0;
95422 sax->fsa_ax25.sax25_call = nr->source_addr;
95423 *uaddr_len = sizeof(struct sockaddr_ax25);
95424 }
95425 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
95426 index 75c8bbf..ee9be59 100644
95427 --- a/net/packet/af_packet.c
95428 +++ b/net/packet/af_packet.c
95429 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95430
95431 spin_lock(&sk->sk_receive_queue.lock);
95432 po->stats.stats1.tp_packets++;
95433 - skb->dropcount = atomic_read(&sk->sk_drops);
95434 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
95435 __skb_queue_tail(&sk->sk_receive_queue, skb);
95436 spin_unlock(&sk->sk_receive_queue.lock);
95437 sk->sk_data_ready(sk, skb->len);
95438 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95439 drop_n_acct:
95440 spin_lock(&sk->sk_receive_queue.lock);
95441 po->stats.stats1.tp_drops++;
95442 - atomic_inc(&sk->sk_drops);
95443 + atomic_inc_unchecked(&sk->sk_drops);
95444 spin_unlock(&sk->sk_receive_queue.lock);
95445
95446 drop_n_restore:
95447 @@ -2640,6 +2640,7 @@ out:
95448
95449 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95450 {
95451 + struct sock_extended_err ee;
95452 struct sock_exterr_skb *serr;
95453 struct sk_buff *skb, *skb2;
95454 int copied, err;
95455 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95456 sock_recv_timestamp(msg, sk, skb);
95457
95458 serr = SKB_EXT_ERR(skb);
95459 + ee = serr->ee;
95460 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
95461 - sizeof(serr->ee), &serr->ee);
95462 + sizeof ee, &ee);
95463
95464 msg->msg_flags |= MSG_ERRQUEUE;
95465 err = copied;
95466 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95467 case PACKET_HDRLEN:
95468 if (len > sizeof(int))
95469 len = sizeof(int);
95470 - if (copy_from_user(&val, optval, len))
95471 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
95472 return -EFAULT;
95473 switch (val) {
95474 case TPACKET_V1:
95475 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95476 len = lv;
95477 if (put_user(len, optlen))
95478 return -EFAULT;
95479 - if (copy_to_user(optval, data, len))
95480 + if (len > sizeof(st) || copy_to_user(optval, data, len))
95481 return -EFAULT;
95482 return 0;
95483 }
95484 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
95485 index e774117..900b8b7 100644
95486 --- a/net/phonet/pep.c
95487 +++ b/net/phonet/pep.c
95488 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95489
95490 case PNS_PEP_CTRL_REQ:
95491 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
95492 - atomic_inc(&sk->sk_drops);
95493 + atomic_inc_unchecked(&sk->sk_drops);
95494 break;
95495 }
95496 __skb_pull(skb, 4);
95497 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95498 }
95499
95500 if (pn->rx_credits == 0) {
95501 - atomic_inc(&sk->sk_drops);
95502 + atomic_inc_unchecked(&sk->sk_drops);
95503 err = -ENOBUFS;
95504 break;
95505 }
95506 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
95507 }
95508
95509 if (pn->rx_credits == 0) {
95510 - atomic_inc(&sk->sk_drops);
95511 + atomic_inc_unchecked(&sk->sk_drops);
95512 err = NET_RX_DROP;
95513 break;
95514 }
95515 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
95516 index 1afd138..0b42453 100644
95517 --- a/net/phonet/socket.c
95518 +++ b/net/phonet/socket.c
95519 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
95520 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
95521 sock_i_ino(sk),
95522 atomic_read(&sk->sk_refcnt), sk,
95523 - atomic_read(&sk->sk_drops), &len);
95524 + atomic_read_unchecked(&sk->sk_drops), &len);
95525 }
95526 seq_printf(seq, "%*s\n", 127 - len, "");
95527 return 0;
95528 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
95529 index c02a8c4..3c5b600 100644
95530 --- a/net/phonet/sysctl.c
95531 +++ b/net/phonet/sysctl.c
95532 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
95533 {
95534 int ret;
95535 int range[2] = {local_port_range[0], local_port_range[1]};
95536 - struct ctl_table tmp = {
95537 + ctl_table_no_const tmp = {
95538 .data = &range,
95539 .maxlen = sizeof(range),
95540 .mode = table->mode,
95541 diff --git a/net/rds/cong.c b/net/rds/cong.c
95542 index e5b65ac..f3b6fb7 100644
95543 --- a/net/rds/cong.c
95544 +++ b/net/rds/cong.c
95545 @@ -78,7 +78,7 @@
95546 * finds that the saved generation number is smaller than the global generation
95547 * number, it wakes up the process.
95548 */
95549 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
95550 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
95551
95552 /*
95553 * Congestion monitoring
95554 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
95555 rdsdebug("waking map %p for %pI4\n",
95556 map, &map->m_addr);
95557 rds_stats_inc(s_cong_update_received);
95558 - atomic_inc(&rds_cong_generation);
95559 + atomic_inc_unchecked(&rds_cong_generation);
95560 if (waitqueue_active(&map->m_waitq))
95561 wake_up(&map->m_waitq);
95562 if (waitqueue_active(&rds_poll_waitq))
95563 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
95564
95565 int rds_cong_updated_since(unsigned long *recent)
95566 {
95567 - unsigned long gen = atomic_read(&rds_cong_generation);
95568 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
95569
95570 if (likely(*recent == gen))
95571 return 0;
95572 diff --git a/net/rds/ib.h b/net/rds/ib.h
95573 index 7280ab8..e04f4ea 100644
95574 --- a/net/rds/ib.h
95575 +++ b/net/rds/ib.h
95576 @@ -128,7 +128,7 @@ struct rds_ib_connection {
95577 /* sending acks */
95578 unsigned long i_ack_flags;
95579 #ifdef KERNEL_HAS_ATOMIC64
95580 - atomic64_t i_ack_next; /* next ACK to send */
95581 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95582 #else
95583 spinlock_t i_ack_lock; /* protect i_ack_next */
95584 u64 i_ack_next; /* next ACK to send */
95585 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
95586 index 31b74f5..dc1fbfa 100644
95587 --- a/net/rds/ib_cm.c
95588 +++ b/net/rds/ib_cm.c
95589 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
95590 /* Clear the ACK state */
95591 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95592 #ifdef KERNEL_HAS_ATOMIC64
95593 - atomic64_set(&ic->i_ack_next, 0);
95594 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95595 #else
95596 ic->i_ack_next = 0;
95597 #endif
95598 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95599 index 8eb9501..0c386ff 100644
95600 --- a/net/rds/ib_recv.c
95601 +++ b/net/rds/ib_recv.c
95602 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95603 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95604 int ack_required)
95605 {
95606 - atomic64_set(&ic->i_ack_next, seq);
95607 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95608 if (ack_required) {
95609 smp_mb__before_clear_bit();
95610 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95611 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95612 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95613 smp_mb__after_clear_bit();
95614
95615 - return atomic64_read(&ic->i_ack_next);
95616 + return atomic64_read_unchecked(&ic->i_ack_next);
95617 }
95618 #endif
95619
95620 diff --git a/net/rds/iw.h b/net/rds/iw.h
95621 index 04ce3b1..48119a6 100644
95622 --- a/net/rds/iw.h
95623 +++ b/net/rds/iw.h
95624 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95625 /* sending acks */
95626 unsigned long i_ack_flags;
95627 #ifdef KERNEL_HAS_ATOMIC64
95628 - atomic64_t i_ack_next; /* next ACK to send */
95629 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95630 #else
95631 spinlock_t i_ack_lock; /* protect i_ack_next */
95632 u64 i_ack_next; /* next ACK to send */
95633 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95634 index a91e1db..cf3053f 100644
95635 --- a/net/rds/iw_cm.c
95636 +++ b/net/rds/iw_cm.c
95637 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95638 /* Clear the ACK state */
95639 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95640 #ifdef KERNEL_HAS_ATOMIC64
95641 - atomic64_set(&ic->i_ack_next, 0);
95642 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95643 #else
95644 ic->i_ack_next = 0;
95645 #endif
95646 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95647 index 4503335..db566b4 100644
95648 --- a/net/rds/iw_recv.c
95649 +++ b/net/rds/iw_recv.c
95650 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95651 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95652 int ack_required)
95653 {
95654 - atomic64_set(&ic->i_ack_next, seq);
95655 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95656 if (ack_required) {
95657 smp_mb__before_clear_bit();
95658 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95659 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95660 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95661 smp_mb__after_clear_bit();
95662
95663 - return atomic64_read(&ic->i_ack_next);
95664 + return atomic64_read_unchecked(&ic->i_ack_next);
95665 }
95666 #endif
95667
95668 diff --git a/net/rds/rds.h b/net/rds/rds.h
95669 index ec1d731..90a3a8d 100644
95670 --- a/net/rds/rds.h
95671 +++ b/net/rds/rds.h
95672 @@ -449,7 +449,7 @@ struct rds_transport {
95673 void (*sync_mr)(void *trans_private, int direction);
95674 void (*free_mr)(void *trans_private, int invalidate);
95675 void (*flush_mrs)(void);
95676 -};
95677 +} __do_const;
95678
95679 struct rds_sock {
95680 struct sock rs_sk;
95681 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95682 index edac9ef..16bcb98 100644
95683 --- a/net/rds/tcp.c
95684 +++ b/net/rds/tcp.c
95685 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95686 int val = 1;
95687
95688 set_fs(KERNEL_DS);
95689 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95690 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95691 sizeof(val));
95692 set_fs(oldfs);
95693 }
95694 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95695 index 81cf5a4..b5826ff 100644
95696 --- a/net/rds/tcp_send.c
95697 +++ b/net/rds/tcp_send.c
95698 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95699
95700 oldfs = get_fs();
95701 set_fs(KERNEL_DS);
95702 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95703 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95704 sizeof(val));
95705 set_fs(oldfs);
95706 }
95707 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95708 index e61aa60..f07cc89 100644
95709 --- a/net/rxrpc/af_rxrpc.c
95710 +++ b/net/rxrpc/af_rxrpc.c
95711 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95712 __be32 rxrpc_epoch;
95713
95714 /* current debugging ID */
95715 -atomic_t rxrpc_debug_id;
95716 +atomic_unchecked_t rxrpc_debug_id;
95717
95718 /* count of skbs currently in use */
95719 atomic_t rxrpc_n_skbs;
95720 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95721 index e4d9cbc..b229649 100644
95722 --- a/net/rxrpc/ar-ack.c
95723 +++ b/net/rxrpc/ar-ack.c
95724 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95725
95726 _enter("{%d,%d,%d,%d},",
95727 call->acks_hard, call->acks_unacked,
95728 - atomic_read(&call->sequence),
95729 + atomic_read_unchecked(&call->sequence),
95730 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95731
95732 stop = 0;
95733 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95734
95735 /* each Tx packet has a new serial number */
95736 sp->hdr.serial =
95737 - htonl(atomic_inc_return(&call->conn->serial));
95738 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95739
95740 hdr = (struct rxrpc_header *) txb->head;
95741 hdr->serial = sp->hdr.serial;
95742 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95743 */
95744 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95745 {
95746 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95747 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95748 }
95749
95750 /*
95751 @@ -629,7 +629,7 @@ process_further:
95752
95753 latest = ntohl(sp->hdr.serial);
95754 hard = ntohl(ack.firstPacket);
95755 - tx = atomic_read(&call->sequence);
95756 + tx = atomic_read_unchecked(&call->sequence);
95757
95758 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95759 latest,
95760 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95761 goto maybe_reschedule;
95762
95763 send_ACK_with_skew:
95764 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95765 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95766 ntohl(ack.serial));
95767 send_ACK:
95768 mtu = call->conn->trans->peer->if_mtu;
95769 @@ -1173,7 +1173,7 @@ send_ACK:
95770 ackinfo.rxMTU = htonl(5692);
95771 ackinfo.jumbo_max = htonl(4);
95772
95773 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95774 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95775 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95776 ntohl(hdr.serial),
95777 ntohs(ack.maxSkew),
95778 @@ -1191,7 +1191,7 @@ send_ACK:
95779 send_message:
95780 _debug("send message");
95781
95782 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95783 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95784 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95785 send_message_2:
95786
95787 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95788 index a3bbb36..3341fb9 100644
95789 --- a/net/rxrpc/ar-call.c
95790 +++ b/net/rxrpc/ar-call.c
95791 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95792 spin_lock_init(&call->lock);
95793 rwlock_init(&call->state_lock);
95794 atomic_set(&call->usage, 1);
95795 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95796 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95797 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95798
95799 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95800 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95801 index 4106ca9..a338d7a 100644
95802 --- a/net/rxrpc/ar-connection.c
95803 +++ b/net/rxrpc/ar-connection.c
95804 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95805 rwlock_init(&conn->lock);
95806 spin_lock_init(&conn->state_lock);
95807 atomic_set(&conn->usage, 1);
95808 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95809 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95810 conn->avail_calls = RXRPC_MAXCALLS;
95811 conn->size_align = 4;
95812 conn->header_size = sizeof(struct rxrpc_header);
95813 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95814 index e7ed43a..6afa140 100644
95815 --- a/net/rxrpc/ar-connevent.c
95816 +++ b/net/rxrpc/ar-connevent.c
95817 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95818
95819 len = iov[0].iov_len + iov[1].iov_len;
95820
95821 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95822 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95823 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95824
95825 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95826 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95827 index 529572f..c758ca7 100644
95828 --- a/net/rxrpc/ar-input.c
95829 +++ b/net/rxrpc/ar-input.c
95830 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95831 /* track the latest serial number on this connection for ACK packet
95832 * information */
95833 serial = ntohl(sp->hdr.serial);
95834 - hi_serial = atomic_read(&call->conn->hi_serial);
95835 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95836 while (serial > hi_serial)
95837 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95838 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95839 serial);
95840
95841 /* request ACK generation for any ACK or DATA packet that requests
95842 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95843 index a693aca..81e7293 100644
95844 --- a/net/rxrpc/ar-internal.h
95845 +++ b/net/rxrpc/ar-internal.h
95846 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95847 int error; /* error code for local abort */
95848 int debug_id; /* debug ID for printks */
95849 unsigned int call_counter; /* call ID counter */
95850 - atomic_t serial; /* packet serial number counter */
95851 - atomic_t hi_serial; /* highest serial number received */
95852 + atomic_unchecked_t serial; /* packet serial number counter */
95853 + atomic_unchecked_t hi_serial; /* highest serial number received */
95854 u8 avail_calls; /* number of calls available */
95855 u8 size_align; /* data size alignment (for security) */
95856 u8 header_size; /* rxrpc + security header size */
95857 @@ -346,7 +346,7 @@ struct rxrpc_call {
95858 spinlock_t lock;
95859 rwlock_t state_lock; /* lock for state transition */
95860 atomic_t usage;
95861 - atomic_t sequence; /* Tx data packet sequence counter */
95862 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95863 u32 abort_code; /* local/remote abort code */
95864 enum { /* current state of call */
95865 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95866 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95867 */
95868 extern atomic_t rxrpc_n_skbs;
95869 extern __be32 rxrpc_epoch;
95870 -extern atomic_t rxrpc_debug_id;
95871 +extern atomic_unchecked_t rxrpc_debug_id;
95872 extern struct workqueue_struct *rxrpc_workqueue;
95873
95874 /*
95875 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95876 index 87f7135..74d3703 100644
95877 --- a/net/rxrpc/ar-local.c
95878 +++ b/net/rxrpc/ar-local.c
95879 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95880 spin_lock_init(&local->lock);
95881 rwlock_init(&local->services_lock);
95882 atomic_set(&local->usage, 1);
95883 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95884 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95885 memcpy(&local->srx, srx, sizeof(*srx));
95886 }
95887
95888 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95889 index e1ac183..b43e10e 100644
95890 --- a/net/rxrpc/ar-output.c
95891 +++ b/net/rxrpc/ar-output.c
95892 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95893 sp->hdr.cid = call->cid;
95894 sp->hdr.callNumber = call->call_id;
95895 sp->hdr.seq =
95896 - htonl(atomic_inc_return(&call->sequence));
95897 + htonl(atomic_inc_return_unchecked(&call->sequence));
95898 sp->hdr.serial =
95899 - htonl(atomic_inc_return(&conn->serial));
95900 + htonl(atomic_inc_return_unchecked(&conn->serial));
95901 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95902 sp->hdr.userStatus = 0;
95903 sp->hdr.securityIndex = conn->security_ix;
95904 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95905 index bebaa43..2644591 100644
95906 --- a/net/rxrpc/ar-peer.c
95907 +++ b/net/rxrpc/ar-peer.c
95908 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95909 INIT_LIST_HEAD(&peer->error_targets);
95910 spin_lock_init(&peer->lock);
95911 atomic_set(&peer->usage, 1);
95912 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95913 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95914 memcpy(&peer->srx, srx, sizeof(*srx));
95915
95916 rxrpc_assess_MTU_size(peer);
95917 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95918 index 38047f7..9f48511 100644
95919 --- a/net/rxrpc/ar-proc.c
95920 +++ b/net/rxrpc/ar-proc.c
95921 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95922 atomic_read(&conn->usage),
95923 rxrpc_conn_states[conn->state],
95924 key_serial(conn->key),
95925 - atomic_read(&conn->serial),
95926 - atomic_read(&conn->hi_serial));
95927 + atomic_read_unchecked(&conn->serial),
95928 + atomic_read_unchecked(&conn->hi_serial));
95929
95930 return 0;
95931 }
95932 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95933 index 92df566..87ec1bf 100644
95934 --- a/net/rxrpc/ar-transport.c
95935 +++ b/net/rxrpc/ar-transport.c
95936 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95937 spin_lock_init(&trans->client_lock);
95938 rwlock_init(&trans->conn_lock);
95939 atomic_set(&trans->usage, 1);
95940 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95941 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95942
95943 if (peer->srx.transport.family == AF_INET) {
95944 switch (peer->srx.transport_type) {
95945 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95946 index f226709..0e735a8 100644
95947 --- a/net/rxrpc/rxkad.c
95948 +++ b/net/rxrpc/rxkad.c
95949 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95950
95951 len = iov[0].iov_len + iov[1].iov_len;
95952
95953 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95954 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95955 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95956
95957 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95958 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95959
95960 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95961
95962 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95963 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95964 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95965
95966 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95967 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95968 index 547a461e..ea606e3 100644
95969 --- a/net/sctp/ipv6.c
95970 +++ b/net/sctp/ipv6.c
95971 @@ -968,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95972 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95973 };
95974
95975 -static struct sctp_af sctp_af_inet6 = {
95976 +static struct sctp_af sctp_af_inet6 __read_only = {
95977 .sa_family = AF_INET6,
95978 .sctp_xmit = sctp_v6_xmit,
95979 .setsockopt = ipv6_setsockopt,
95980 @@ -1000,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95981 #endif
95982 };
95983
95984 -static struct sctp_pf sctp_pf_inet6 = {
95985 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95986 .event_msgname = sctp_inet6_event_msgname,
95987 .skb_msgname = sctp_inet6_skb_msgname,
95988 .af_supported = sctp_inet6_af_supported,
95989 @@ -1025,7 +1025,7 @@ void sctp_v6_pf_init(void)
95990
95991 void sctp_v6_pf_exit(void)
95992 {
95993 - list_del(&sctp_af_inet6.list);
95994 + pax_list_del(&sctp_af_inet6.list);
95995 }
95996
95997 /* Initialize IPv6 support and register with socket layer. */
95998 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95999 index 62526c4..36a13c5 100644
96000 --- a/net/sctp/proc.c
96001 +++ b/net/sctp/proc.c
96002 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
96003 seq_printf(seq,
96004 "%8pK %8pK %-3d %-3d %-2d %-4d "
96005 "%4d %8d %8d %7d %5lu %-5d %5d ",
96006 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
96007 + assoc, sk,
96008 + sctp_sk(sk)->type, sk->sk_state,
96009 assoc->state, hash,
96010 assoc->assoc_id,
96011 assoc->sndbuf_used,
96012 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
96013 index 4a17494d..f7e3fa0 100644
96014 --- a/net/sctp/protocol.c
96015 +++ b/net/sctp/protocol.c
96016 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
96017 return 0;
96018 }
96019
96020 + pax_open_kernel();
96021 INIT_LIST_HEAD(&af->list);
96022 - list_add_tail(&af->list, &sctp_address_families);
96023 + pax_close_kernel();
96024 + pax_list_add_tail(&af->list, &sctp_address_families);
96025 return 1;
96026 }
96027
96028 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
96029
96030 static struct sctp_af sctp_af_inet;
96031
96032 -static struct sctp_pf sctp_pf_inet = {
96033 +static struct sctp_pf sctp_pf_inet __read_only = {
96034 .event_msgname = sctp_inet_event_msgname,
96035 .skb_msgname = sctp_inet_skb_msgname,
96036 .af_supported = sctp_inet_af_supported,
96037 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
96038 };
96039
96040 /* IPv4 address related functions. */
96041 -static struct sctp_af sctp_af_inet = {
96042 +static struct sctp_af sctp_af_inet __read_only = {
96043 .sa_family = AF_INET,
96044 .sctp_xmit = sctp_v4_xmit,
96045 .setsockopt = ip_setsockopt,
96046 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
96047
96048 static void sctp_v4_pf_exit(void)
96049 {
96050 - list_del(&sctp_af_inet.list);
96051 + pax_list_del(&sctp_af_inet.list);
96052 }
96053
96054 static int sctp_v4_protosw_init(void)
96055 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
96056 index 8b5b4b7..2636327 100644
96057 --- a/net/sctp/sm_sideeffect.c
96058 +++ b/net/sctp/sm_sideeffect.c
96059 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
96060 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
96061 }
96062
96063 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96064 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96065 NULL,
96066 sctp_generate_t1_cookie_event,
96067 sctp_generate_t1_init_event,
96068 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
96069 index cf6c6b0..b978b65 100644
96070 --- a/net/sctp/socket.c
96071 +++ b/net/sctp/socket.c
96072 @@ -2159,11 +2159,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
96073 {
96074 struct sctp_association *asoc;
96075 struct sctp_ulpevent *event;
96076 + struct sctp_event_subscribe subscribe;
96077
96078 if (optlen > sizeof(struct sctp_event_subscribe))
96079 return -EINVAL;
96080 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
96081 + if (copy_from_user(&subscribe, optval, optlen))
96082 return -EFAULT;
96083 + sctp_sk(sk)->subscribe = subscribe;
96084
96085 /*
96086 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
96087 @@ -4219,13 +4221,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
96088 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96089 int __user *optlen)
96090 {
96091 + struct sctp_event_subscribe subscribe;
96092 +
96093 if (len <= 0)
96094 return -EINVAL;
96095 if (len > sizeof(struct sctp_event_subscribe))
96096 len = sizeof(struct sctp_event_subscribe);
96097 if (put_user(len, optlen))
96098 return -EFAULT;
96099 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
96100 + subscribe = sctp_sk(sk)->subscribe;
96101 + if (copy_to_user(optval, &subscribe, len))
96102 return -EFAULT;
96103 return 0;
96104 }
96105 @@ -4243,6 +4248,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96106 */
96107 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
96108 {
96109 + __u32 autoclose;
96110 +
96111 /* Applicable to UDP-style socket only */
96112 if (sctp_style(sk, TCP))
96113 return -EOPNOTSUPP;
96114 @@ -4251,7 +4258,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
96115 len = sizeof(int);
96116 if (put_user(len, optlen))
96117 return -EFAULT;
96118 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
96119 + autoclose = sctp_sk(sk)->autoclose;
96120 + if (copy_to_user(optval, &autoclose, sizeof(int)))
96121 return -EFAULT;
96122 return 0;
96123 }
96124 @@ -4623,12 +4631,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
96125 */
96126 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
96127 {
96128 + struct sctp_initmsg initmsg;
96129 +
96130 if (len < sizeof(struct sctp_initmsg))
96131 return -EINVAL;
96132 len = sizeof(struct sctp_initmsg);
96133 if (put_user(len, optlen))
96134 return -EFAULT;
96135 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
96136 + initmsg = sctp_sk(sk)->initmsg;
96137 + if (copy_to_user(optval, &initmsg, len))
96138 return -EFAULT;
96139 return 0;
96140 }
96141 @@ -4669,6 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
96142 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
96143 if (space_left < addrlen)
96144 return -ENOMEM;
96145 + if (addrlen > sizeof(temp) || addrlen < 0)
96146 + return -EFAULT;
96147 if (copy_to_user(to, &temp, addrlen))
96148 return -EFAULT;
96149 to += addrlen;
96150 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
96151 index 9a5c4c9..46e4b29 100644
96152 --- a/net/sctp/sysctl.c
96153 +++ b/net/sctp/sysctl.c
96154 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96155 {
96156 struct net *net = current->nsproxy->net_ns;
96157 char tmp[8];
96158 - struct ctl_table tbl;
96159 + ctl_table_no_const tbl;
96160 int ret;
96161 int changed = 0;
96162 char *none = "none";
96163 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96164
96165 int sctp_sysctl_net_register(struct net *net)
96166 {
96167 - struct ctl_table *table;
96168 + ctl_table_no_const *table;
96169 int i;
96170
96171 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
96172 diff --git a/net/socket.c b/net/socket.c
96173 index 4b94643..f703b02 100644
96174 --- a/net/socket.c
96175 +++ b/net/socket.c
96176 @@ -88,6 +88,7 @@
96177 #include <linux/magic.h>
96178 #include <linux/slab.h>
96179 #include <linux/xattr.h>
96180 +#include <linux/in.h>
96181
96182 #include <asm/uaccess.h>
96183 #include <asm/unistd.h>
96184 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
96185 unsigned int sysctl_net_busy_poll __read_mostly;
96186 #endif
96187
96188 +#include <linux/grsock.h>
96189 +
96190 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
96191 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
96192 unsigned long nr_segs, loff_t pos);
96193 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
96194 */
96195
96196 static DEFINE_SPINLOCK(net_family_lock);
96197 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96198 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96199
96200 /*
96201 * Statistics counters of the socket lists
96202 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
96203 &sockfs_dentry_operations, SOCKFS_MAGIC);
96204 }
96205
96206 -static struct vfsmount *sock_mnt __read_mostly;
96207 +struct vfsmount *sock_mnt __read_mostly;
96208
96209 static struct file_system_type sock_fs_type = {
96210 .name = "sockfs",
96211 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96212 return -EAFNOSUPPORT;
96213 if (type < 0 || type >= SOCK_MAX)
96214 return -EINVAL;
96215 + if (protocol < 0)
96216 + return -EINVAL;
96217
96218 /* Compatibility.
96219
96220 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96221 if (err)
96222 return err;
96223
96224 + if(!kern && !gr_search_socket(family, type, protocol)) {
96225 + if (rcu_access_pointer(net_families[family]) == NULL)
96226 + return -EAFNOSUPPORT;
96227 + else
96228 + return -EACCES;
96229 + }
96230 +
96231 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
96232 + if (rcu_access_pointer(net_families[family]) == NULL)
96233 + return -EAFNOSUPPORT;
96234 + else
96235 + return -EACCES;
96236 + }
96237 +
96238 /*
96239 * Allocate the socket and allow the family to set things up. if
96240 * the protocol is 0, the family is instructed to select an appropriate
96241 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96242 if (sock) {
96243 err = move_addr_to_kernel(umyaddr, addrlen, &address);
96244 if (err >= 0) {
96245 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
96246 + err = -EACCES;
96247 + goto error;
96248 + }
96249 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
96250 + if (err)
96251 + goto error;
96252 +
96253 err = security_socket_bind(sock,
96254 (struct sockaddr *)&address,
96255 addrlen);
96256 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96257 (struct sockaddr *)
96258 &address, addrlen);
96259 }
96260 +error:
96261 fput_light(sock->file, fput_needed);
96262 }
96263 return err;
96264 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
96265 if ((unsigned int)backlog > somaxconn)
96266 backlog = somaxconn;
96267
96268 + if (gr_handle_sock_server_other(sock->sk)) {
96269 + err = -EPERM;
96270 + goto error;
96271 + }
96272 +
96273 + err = gr_search_listen(sock);
96274 + if (err)
96275 + goto error;
96276 +
96277 err = security_socket_listen(sock, backlog);
96278 if (!err)
96279 err = sock->ops->listen(sock, backlog);
96280
96281 +error:
96282 fput_light(sock->file, fput_needed);
96283 }
96284 return err;
96285 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96286 newsock->type = sock->type;
96287 newsock->ops = sock->ops;
96288
96289 + if (gr_handle_sock_server_other(sock->sk)) {
96290 + err = -EPERM;
96291 + sock_release(newsock);
96292 + goto out_put;
96293 + }
96294 +
96295 + err = gr_search_accept(sock);
96296 + if (err) {
96297 + sock_release(newsock);
96298 + goto out_put;
96299 + }
96300 +
96301 /*
96302 * We don't need try_module_get here, as the listening socket (sock)
96303 * has the protocol module (sock->ops->owner) held.
96304 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96305 fd_install(newfd, newfile);
96306 err = newfd;
96307
96308 + gr_attach_curr_ip(newsock->sk);
96309 +
96310 out_put:
96311 fput_light(sock->file, fput_needed);
96312 out:
96313 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96314 int, addrlen)
96315 {
96316 struct socket *sock;
96317 + struct sockaddr *sck;
96318 struct sockaddr_storage address;
96319 int err, fput_needed;
96320
96321 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96322 if (err < 0)
96323 goto out_put;
96324
96325 + sck = (struct sockaddr *)&address;
96326 +
96327 + if (gr_handle_sock_client(sck)) {
96328 + err = -EACCES;
96329 + goto out_put;
96330 + }
96331 +
96332 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
96333 + if (err)
96334 + goto out_put;
96335 +
96336 err =
96337 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
96338 if (err)
96339 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
96340 * the protocol.
96341 */
96342
96343 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
96344 +
96345 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
96346 unsigned int, flags, struct sockaddr __user *, addr,
96347 int, addr_len)
96348 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
96349 struct socket *sock;
96350 struct iovec iov;
96351 struct msghdr msg;
96352 - struct sockaddr_storage address;
96353 + struct sockaddr_storage address = { };
96354 int err, err2;
96355 int fput_needed;
96356
96357 @@ -2053,7 +2119,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96358 * checking falls down on this.
96359 */
96360 if (copy_from_user(ctl_buf,
96361 - (void __user __force *)msg_sys->msg_control,
96362 + (void __force_user *)msg_sys->msg_control,
96363 ctl_len))
96364 goto out_freectl;
96365 msg_sys->msg_control = ctl_buf;
96366 @@ -2204,7 +2270,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96367 int err, total_len, len;
96368
96369 /* kernel mode address */
96370 - struct sockaddr_storage addr;
96371 + struct sockaddr_storage addr = { };
96372
96373 /* user mode address pointers */
96374 struct sockaddr __user *uaddr;
96375 @@ -2235,7 +2301,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96376 * kernel msghdr to use the kernel address space)
96377 */
96378
96379 - uaddr = (__force void __user *)msg_sys->msg_name;
96380 + uaddr = (void __force_user *)msg_sys->msg_name;
96381 uaddr_len = COMPAT_NAMELEN(msg);
96382 if (MSG_CMSG_COMPAT & flags) {
96383 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96384 @@ -2990,7 +3056,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96385 old_fs = get_fs();
96386 set_fs(KERNEL_DS);
96387 err = dev_ioctl(net, cmd,
96388 - (struct ifreq __user __force *) &kifr);
96389 + (struct ifreq __force_user *) &kifr);
96390 set_fs(old_fs);
96391
96392 return err;
96393 @@ -3099,7 +3165,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96394
96395 old_fs = get_fs();
96396 set_fs(KERNEL_DS);
96397 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96398 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96399 set_fs(old_fs);
96400
96401 if (cmd == SIOCGIFMAP && !err) {
96402 @@ -3204,7 +3270,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96403 ret |= __get_user(rtdev, &(ur4->rt_dev));
96404 if (rtdev) {
96405 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96406 - r4.rt_dev = (char __user __force *)devname;
96407 + r4.rt_dev = (char __force_user *)devname;
96408 devname[15] = 0;
96409 } else
96410 r4.rt_dev = NULL;
96411 @@ -3430,8 +3496,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96412 int __user *uoptlen;
96413 int err;
96414
96415 - uoptval = (char __user __force *) optval;
96416 - uoptlen = (int __user __force *) optlen;
96417 + uoptval = (char __force_user *) optval;
96418 + uoptlen = (int __force_user *) optlen;
96419
96420 set_fs(KERNEL_DS);
96421 if (level == SOL_SOCKET)
96422 @@ -3451,7 +3517,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96423 char __user *uoptval;
96424 int err;
96425
96426 - uoptval = (char __user __force *) optval;
96427 + uoptval = (char __force_user *) optval;
96428
96429 set_fs(KERNEL_DS);
96430 if (level == SOL_SOCKET)
96431 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96432 index 09fb638..2e6a5c5 100644
96433 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96434 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96435 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96436 uint64_t *handle)
96437 {
96438 struct rsc rsci, *rscp = NULL;
96439 - static atomic64_t ctxhctr;
96440 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96441 long long ctxh;
96442 struct gss_api_mech *gm = NULL;
96443 time_t expiry;
96444 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96445 status = -ENOMEM;
96446 /* the handle needs to be just a unique id,
96447 * use a static counter */
96448 - ctxh = atomic64_inc_return(&ctxhctr);
96449 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96450
96451 /* make a copy for the caller */
96452 *handle = ctxh;
96453 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96454 index ecbc4e3..098e564 100644
96455 --- a/net/sunrpc/clnt.c
96456 +++ b/net/sunrpc/clnt.c
96457 @@ -645,14 +645,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);
96458 /*
96459 * Free an RPC client
96460 */
96461 -static void
96462 +static struct rpc_clnt *
96463 rpc_free_client(struct rpc_clnt *clnt)
96464 {
96465 + struct rpc_clnt *parent = NULL;
96466 +
96467 dprintk_rcu("RPC: destroying %s client for %s\n",
96468 clnt->cl_protname,
96469 rcu_dereference(clnt->cl_xprt)->servername);
96470 if (clnt->cl_parent != clnt)
96471 - rpc_release_client(clnt->cl_parent);
96472 + parent = clnt->cl_parent;
96473 rpc_clnt_remove_pipedir(clnt);
96474 rpc_unregister_client(clnt);
96475 rpc_free_iostats(clnt->cl_metrics);
96476 @@ -661,18 +663,17 @@ rpc_free_client(struct rpc_clnt *clnt)
96477 xprt_put(rcu_dereference_raw(clnt->cl_xprt));
96478 rpciod_down();
96479 kfree(clnt);
96480 + return parent;
96481 }
96482
96483 /*
96484 * Free an RPC client
96485 */
96486 -static void
96487 +static struct rpc_clnt *
96488 rpc_free_auth(struct rpc_clnt *clnt)
96489 {
96490 - if (clnt->cl_auth == NULL) {
96491 - rpc_free_client(clnt);
96492 - return;
96493 - }
96494 + if (clnt->cl_auth == NULL)
96495 + return rpc_free_client(clnt);
96496
96497 /*
96498 * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
96499 @@ -683,7 +684,8 @@ rpc_free_auth(struct rpc_clnt *clnt)
96500 rpcauth_release(clnt->cl_auth);
96501 clnt->cl_auth = NULL;
96502 if (atomic_dec_and_test(&clnt->cl_count))
96503 - rpc_free_client(clnt);
96504 + return rpc_free_client(clnt);
96505 + return NULL;
96506 }
96507
96508 /*
96509 @@ -694,10 +696,13 @@ rpc_release_client(struct rpc_clnt *clnt)
96510 {
96511 dprintk("RPC: rpc_release_client(%p)\n", clnt);
96512
96513 - if (list_empty(&clnt->cl_tasks))
96514 - wake_up(&destroy_wait);
96515 - if (atomic_dec_and_test(&clnt->cl_count))
96516 - rpc_free_auth(clnt);
96517 + do {
96518 + if (list_empty(&clnt->cl_tasks))
96519 + wake_up(&destroy_wait);
96520 + if (!atomic_dec_and_test(&clnt->cl_count))
96521 + break;
96522 + clnt = rpc_free_auth(clnt);
96523 + } while (clnt != NULL);
96524 }
96525 EXPORT_SYMBOL_GPL(rpc_release_client);
96526
96527 @@ -1304,7 +1309,9 @@ call_start(struct rpc_task *task)
96528 (RPC_IS_ASYNC(task) ? "async" : "sync"));
96529
96530 /* Increment call count */
96531 - task->tk_msg.rpc_proc->p_count++;
96532 + pax_open_kernel();
96533 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
96534 + pax_close_kernel();
96535 clnt->cl_stats->rpccnt++;
96536 task->tk_action = call_reserve;
96537 }
96538 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
96539 index 93a7a4e..3b98b9f 100644
96540 --- a/net/sunrpc/sched.c
96541 +++ b/net/sunrpc/sched.c
96542 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
96543 #ifdef RPC_DEBUG
96544 static void rpc_task_set_debuginfo(struct rpc_task *task)
96545 {
96546 - static atomic_t rpc_pid;
96547 + static atomic_unchecked_t rpc_pid;
96548
96549 - task->tk_pid = atomic_inc_return(&rpc_pid);
96550 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
96551 }
96552 #else
96553 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
96554 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
96555 index b974571..678ed90 100644
96556 --- a/net/sunrpc/svc.c
96557 +++ b/net/sunrpc/svc.c
96558 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
96559 svc_putnl(resv, RPC_SUCCESS);
96560
96561 /* Bump per-procedure stats counter */
96562 - procp->pc_count++;
96563 + pax_open_kernel();
96564 + (*(unsigned int *)&procp->pc_count)++;
96565 + pax_close_kernel();
96566
96567 /* Initialize storage for argp and resp */
96568 memset(rqstp->rq_argp, 0, procp->pc_argsize);
96569 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
96570 index c1b6270..05089c1 100644
96571 --- a/net/sunrpc/xprtrdma/svc_rdma.c
96572 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
96573 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
96574 static unsigned int min_max_inline = 4096;
96575 static unsigned int max_max_inline = 65536;
96576
96577 -atomic_t rdma_stat_recv;
96578 -atomic_t rdma_stat_read;
96579 -atomic_t rdma_stat_write;
96580 -atomic_t rdma_stat_sq_starve;
96581 -atomic_t rdma_stat_rq_starve;
96582 -atomic_t rdma_stat_rq_poll;
96583 -atomic_t rdma_stat_rq_prod;
96584 -atomic_t rdma_stat_sq_poll;
96585 -atomic_t rdma_stat_sq_prod;
96586 +atomic_unchecked_t rdma_stat_recv;
96587 +atomic_unchecked_t rdma_stat_read;
96588 +atomic_unchecked_t rdma_stat_write;
96589 +atomic_unchecked_t rdma_stat_sq_starve;
96590 +atomic_unchecked_t rdma_stat_rq_starve;
96591 +atomic_unchecked_t rdma_stat_rq_poll;
96592 +atomic_unchecked_t rdma_stat_rq_prod;
96593 +atomic_unchecked_t rdma_stat_sq_poll;
96594 +atomic_unchecked_t rdma_stat_sq_prod;
96595
96596 /* Temporary NFS request map and context caches */
96597 struct kmem_cache *svc_rdma_map_cachep;
96598 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96599 len -= *ppos;
96600 if (len > *lenp)
96601 len = *lenp;
96602 - if (len && copy_to_user(buffer, str_buf, len))
96603 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96604 return -EFAULT;
96605 *lenp = len;
96606 *ppos += len;
96607 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96608 {
96609 .procname = "rdma_stat_read",
96610 .data = &rdma_stat_read,
96611 - .maxlen = sizeof(atomic_t),
96612 + .maxlen = sizeof(atomic_unchecked_t),
96613 .mode = 0644,
96614 .proc_handler = read_reset_stat,
96615 },
96616 {
96617 .procname = "rdma_stat_recv",
96618 .data = &rdma_stat_recv,
96619 - .maxlen = sizeof(atomic_t),
96620 + .maxlen = sizeof(atomic_unchecked_t),
96621 .mode = 0644,
96622 .proc_handler = read_reset_stat,
96623 },
96624 {
96625 .procname = "rdma_stat_write",
96626 .data = &rdma_stat_write,
96627 - .maxlen = sizeof(atomic_t),
96628 + .maxlen = sizeof(atomic_unchecked_t),
96629 .mode = 0644,
96630 .proc_handler = read_reset_stat,
96631 },
96632 {
96633 .procname = "rdma_stat_sq_starve",
96634 .data = &rdma_stat_sq_starve,
96635 - .maxlen = sizeof(atomic_t),
96636 + .maxlen = sizeof(atomic_unchecked_t),
96637 .mode = 0644,
96638 .proc_handler = read_reset_stat,
96639 },
96640 {
96641 .procname = "rdma_stat_rq_starve",
96642 .data = &rdma_stat_rq_starve,
96643 - .maxlen = sizeof(atomic_t),
96644 + .maxlen = sizeof(atomic_unchecked_t),
96645 .mode = 0644,
96646 .proc_handler = read_reset_stat,
96647 },
96648 {
96649 .procname = "rdma_stat_rq_poll",
96650 .data = &rdma_stat_rq_poll,
96651 - .maxlen = sizeof(atomic_t),
96652 + .maxlen = sizeof(atomic_unchecked_t),
96653 .mode = 0644,
96654 .proc_handler = read_reset_stat,
96655 },
96656 {
96657 .procname = "rdma_stat_rq_prod",
96658 .data = &rdma_stat_rq_prod,
96659 - .maxlen = sizeof(atomic_t),
96660 + .maxlen = sizeof(atomic_unchecked_t),
96661 .mode = 0644,
96662 .proc_handler = read_reset_stat,
96663 },
96664 {
96665 .procname = "rdma_stat_sq_poll",
96666 .data = &rdma_stat_sq_poll,
96667 - .maxlen = sizeof(atomic_t),
96668 + .maxlen = sizeof(atomic_unchecked_t),
96669 .mode = 0644,
96670 .proc_handler = read_reset_stat,
96671 },
96672 {
96673 .procname = "rdma_stat_sq_prod",
96674 .data = &rdma_stat_sq_prod,
96675 - .maxlen = sizeof(atomic_t),
96676 + .maxlen = sizeof(atomic_unchecked_t),
96677 .mode = 0644,
96678 .proc_handler = read_reset_stat,
96679 },
96680 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96681 index 0ce7552..d074459 100644
96682 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96683 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96684 @@ -501,7 +501,7 @@ next_sge:
96685 svc_rdma_put_context(ctxt, 0);
96686 goto out;
96687 }
96688 - atomic_inc(&rdma_stat_read);
96689 + atomic_inc_unchecked(&rdma_stat_read);
96690
96691 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96692 chl_map->ch[ch_no].count -= read_wr.num_sge;
96693 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96694 dto_q);
96695 list_del_init(&ctxt->dto_q);
96696 } else {
96697 - atomic_inc(&rdma_stat_rq_starve);
96698 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96699 clear_bit(XPT_DATA, &xprt->xpt_flags);
96700 ctxt = NULL;
96701 }
96702 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96703 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96704 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96705 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96706 - atomic_inc(&rdma_stat_recv);
96707 + atomic_inc_unchecked(&rdma_stat_recv);
96708
96709 /* Build up the XDR from the receive buffers. */
96710 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96711 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96712 index c1d124d..acfc59e 100644
96713 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96714 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96715 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96716 write_wr.wr.rdma.remote_addr = to;
96717
96718 /* Post It */
96719 - atomic_inc(&rdma_stat_write);
96720 + atomic_inc_unchecked(&rdma_stat_write);
96721 if (svc_rdma_send(xprt, &write_wr))
96722 goto err;
96723 return 0;
96724 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96725 index 62e4f9b..dd3f2d7 100644
96726 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96727 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96728 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96729 return;
96730
96731 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96732 - atomic_inc(&rdma_stat_rq_poll);
96733 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96734
96735 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96736 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96737 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96738 }
96739
96740 if (ctxt)
96741 - atomic_inc(&rdma_stat_rq_prod);
96742 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96743
96744 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96745 /*
96746 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96747 return;
96748
96749 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96750 - atomic_inc(&rdma_stat_sq_poll);
96751 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96752 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96753 if (wc.status != IB_WC_SUCCESS)
96754 /* Close the transport */
96755 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96756 }
96757
96758 if (ctxt)
96759 - atomic_inc(&rdma_stat_sq_prod);
96760 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96761 }
96762
96763 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96764 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96765 spin_lock_bh(&xprt->sc_lock);
96766 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96767 spin_unlock_bh(&xprt->sc_lock);
96768 - atomic_inc(&rdma_stat_sq_starve);
96769 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96770
96771 /* See if we can opportunistically reap SQ WR to make room */
96772 sq_cq_reap(xprt);
96773 diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
96774 index ddf0602..e865e08 100644
96775 --- a/net/sunrpc/xprtsock.c
96776 +++ b/net/sunrpc/xprtsock.c
96777 @@ -391,8 +391,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
96778 return kernel_sendmsg(sock, &msg, NULL, 0, 0);
96779 }
96780
96781 -static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
96782 +static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
96783 {
96784 + ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
96785 + int offset, size_t size, int flags);
96786 struct page **ppage;
96787 unsigned int remainder;
96788 int err, sent = 0;
96789 @@ -401,6 +403,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96790 base += xdr->page_base;
96791 ppage = xdr->pages + (base >> PAGE_SHIFT);
96792 base &= ~PAGE_MASK;
96793 + do_sendpage = sock->ops->sendpage;
96794 + if (!zerocopy)
96795 + do_sendpage = sock_no_sendpage;
96796 for(;;) {
96797 unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
96798 int flags = XS_SENDMSG_FLAGS;
96799 @@ -408,7 +413,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96800 remainder -= len;
96801 if (remainder != 0 || more)
96802 flags |= MSG_MORE;
96803 - err = sock->ops->sendpage(sock, *ppage, base, len, flags);
96804 + err = do_sendpage(sock, *ppage, base, len, flags);
96805 if (remainder == 0 || err != len)
96806 break;
96807 sent += err;
96808 @@ -429,9 +434,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96809 * @addrlen: UDP only -- length of destination address
96810 * @xdr: buffer containing this request
96811 * @base: starting position in the buffer
96812 + * @zerocopy: true if it is safe to use sendpage()
96813 *
96814 */
96815 -static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
96816 +static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
96817 {
96818 unsigned int remainder = xdr->len - base;
96819 int err, sent = 0;
96820 @@ -459,7 +465,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
96821 if (base < xdr->page_len) {
96822 unsigned int len = xdr->page_len - base;
96823 remainder -= len;
96824 - err = xs_send_pagedata(sock, xdr, base, remainder != 0);
96825 + err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
96826 if (remainder == 0 || err != len)
96827 goto out;
96828 sent += err;
96829 @@ -562,7 +568,7 @@ static int xs_local_send_request(struct rpc_task *task)
96830 req->rq_svec->iov_base, req->rq_svec->iov_len);
96831
96832 status = xs_sendpages(transport->sock, NULL, 0,
96833 - xdr, req->rq_bytes_sent);
96834 + xdr, req->rq_bytes_sent, true);
96835 dprintk("RPC: %s(%u) = %d\n",
96836 __func__, xdr->len - req->rq_bytes_sent, status);
96837 if (likely(status >= 0)) {
96838 @@ -618,7 +624,7 @@ static int xs_udp_send_request(struct rpc_task *task)
96839 status = xs_sendpages(transport->sock,
96840 xs_addr(xprt),
96841 xprt->addrlen, xdr,
96842 - req->rq_bytes_sent);
96843 + req->rq_bytes_sent, true);
96844
96845 dprintk("RPC: xs_udp_send_request(%u) = %d\n",
96846 xdr->len - req->rq_bytes_sent, status);
96847 @@ -689,6 +695,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
96848 struct rpc_xprt *xprt = req->rq_xprt;
96849 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
96850 struct xdr_buf *xdr = &req->rq_snd_buf;
96851 + bool zerocopy = true;
96852 int status;
96853
96854 xs_encode_stream_record_marker(&req->rq_snd_buf);
96855 @@ -696,13 +703,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
96856 xs_pktdump("packet data:",
96857 req->rq_svec->iov_base,
96858 req->rq_svec->iov_len);
96859 + /* Don't use zero copy if this is a resend. If the RPC call
96860 + * completes while the socket holds a reference to the pages,
96861 + * then we may end up resending corrupted data.
96862 + */
96863 + if (task->tk_flags & RPC_TASK_SENT)
96864 + zerocopy = false;
96865
96866 /* Continue transmitting the packet/record. We must be careful
96867 * to cope with writespace callbacks arriving _after_ we have
96868 * called sendmsg(). */
96869 while (1) {
96870 status = xs_sendpages(transport->sock,
96871 - NULL, 0, xdr, req->rq_bytes_sent);
96872 + NULL, 0, xdr, req->rq_bytes_sent,
96873 + zerocopy);
96874
96875 dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
96876 xdr->len - req->rq_bytes_sent, status);
96877 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96878 index e7000be..e3b0ba7 100644
96879 --- a/net/sysctl_net.c
96880 +++ b/net/sysctl_net.c
96881 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96882 kgid_t root_gid = make_kgid(net->user_ns, 0);
96883
96884 /* Allow network administrator to have same access as root. */
96885 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96886 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96887 uid_eq(root_uid, current_euid())) {
96888 int mode = (table->mode >> 6) & 7;
96889 return (mode << 6) | (mode << 3) | mode;
96890 diff --git a/net/tipc/link.c b/net/tipc/link.c
96891 index 0cc3d90..cc42021 100644
96892 --- a/net/tipc/link.c
96893 +++ b/net/tipc/link.c
96894 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96895 struct tipc_msg fragm_hdr;
96896 struct sk_buff *buf, *buf_chain, *prev;
96897 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96898 - const unchar *sect_crs;
96899 + const unchar __user *sect_crs;
96900 int curr_sect;
96901 u32 fragm_no;
96902 int res = 0;
96903 @@ -1207,7 +1207,7 @@ again:
96904
96905 if (!sect_rest) {
96906 sect_rest = msg_sect[++curr_sect].iov_len;
96907 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96908 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96909 }
96910
96911 if (sect_rest < fragm_rest)
96912 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96913 index ced60e2..54eab6c 100644
96914 --- a/net/tipc/msg.c
96915 +++ b/net/tipc/msg.c
96916 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96917 skb_copy_to_linear_data(*buf, hdr, hsz);
96918 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96919 skb_copy_to_linear_data_offset(*buf, pos,
96920 - msg_sect[cnt].iov_base,
96921 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96922 msg_sect[cnt].iov_len);
96923 pos += msg_sect[cnt].iov_len;
96924 }
96925 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96926 index d38bb45..4fd6ac6 100644
96927 --- a/net/tipc/subscr.c
96928 +++ b/net/tipc/subscr.c
96929 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96930 struct kvec msg_sect;
96931 int ret;
96932
96933 - msg_sect.iov_base = (void *)&sub->evt;
96934 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96935 msg_sect.iov_len = sizeof(struct tipc_event);
96936
96937 sub->evt.event = htohl(event, sub->swap);
96938 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96939 index e64bbcf..9c3ba79 100644
96940 --- a/net/unix/af_unix.c
96941 +++ b/net/unix/af_unix.c
96942 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96943 err = -ECONNREFUSED;
96944 if (!S_ISSOCK(inode->i_mode))
96945 goto put_fail;
96946 +
96947 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96948 + err = -EACCES;
96949 + goto put_fail;
96950 + }
96951 +
96952 u = unix_find_socket_byinode(inode);
96953 if (!u)
96954 goto put_fail;
96955 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96956 if (u) {
96957 struct dentry *dentry;
96958 dentry = unix_sk(u)->path.dentry;
96959 +
96960 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96961 + err = -EPERM;
96962 + sock_put(u);
96963 + goto fail;
96964 + }
96965 +
96966 if (dentry)
96967 touch_atime(&unix_sk(u)->path);
96968 } else
96969 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96970 */
96971 err = security_path_mknod(&path, dentry, mode, 0);
96972 if (!err) {
96973 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96974 + err = -EACCES;
96975 + goto out;
96976 + }
96977 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96978 if (!err) {
96979 res->mnt = mntget(path.mnt);
96980 res->dentry = dget(dentry);
96981 + gr_handle_create(dentry, path.mnt);
96982 }
96983 }
96984 +out:
96985 done_path_create(&path, dentry);
96986 return err;
96987 }
96988 @@ -2335,9 +2354,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96989 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96990 "Inode Path\n");
96991 else {
96992 - struct sock *s = v;
96993 + struct sock *s = v, *peer;
96994 struct unix_sock *u = unix_sk(s);
96995 unix_state_lock(s);
96996 + peer = unix_peer(s);
96997 + unix_state_unlock(s);
96998 +
96999 + unix_state_double_lock(s, peer);
97000
97001 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
97002 s,
97003 @@ -2364,8 +2387,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97004 }
97005 for ( ; i < len; i++)
97006 seq_putc(seq, u->addr->name->sun_path[i]);
97007 - }
97008 - unix_state_unlock(s);
97009 + } else if (peer)
97010 + seq_printf(seq, " P%lu", sock_i_ino(peer));
97011 +
97012 + unix_state_double_unlock(s, peer);
97013 seq_putc(seq, '\n');
97014 }
97015
97016 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
97017 index b3d5150..ff3a837 100644
97018 --- a/net/unix/sysctl_net_unix.c
97019 +++ b/net/unix/sysctl_net_unix.c
97020 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
97021
97022 int __net_init unix_sysctl_register(struct net *net)
97023 {
97024 - struct ctl_table *table;
97025 + ctl_table_no_const *table;
97026
97027 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
97028 if (table == NULL)
97029 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
97030 index c8717c1..08539f5 100644
97031 --- a/net/wireless/wext-core.c
97032 +++ b/net/wireless/wext-core.c
97033 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97034 */
97035
97036 /* Support for very large requests */
97037 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
97038 - (user_length > descr->max_tokens)) {
97039 + if (user_length > descr->max_tokens) {
97040 /* Allow userspace to GET more than max so
97041 * we can support any size GET requests.
97042 * There is still a limit : -ENOMEM.
97043 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97044 }
97045 }
97046
97047 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
97048 - /*
97049 - * If this is a GET, but not NOMAX, it means that the extra
97050 - * data is not bounded by userspace, but by max_tokens. Thus
97051 - * set the length to max_tokens. This matches the extra data
97052 - * allocation.
97053 - * The driver should fill it with the number of tokens it
97054 - * provided, and it may check iwp->length rather than having
97055 - * knowledge of max_tokens. If the driver doesn't change the
97056 - * iwp->length, this ioctl just copies back max_token tokens
97057 - * filled with zeroes. Hopefully the driver isn't claiming
97058 - * them to be valid data.
97059 - */
97060 - iwp->length = descr->max_tokens;
97061 - }
97062 -
97063 err = handler(dev, info, (union iwreq_data *) iwp, extra);
97064
97065 iwp->length += essid_compat;
97066 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
97067 index f77c371..b0cb010 100644
97068 --- a/net/xfrm/xfrm_policy.c
97069 +++ b/net/xfrm/xfrm_policy.c
97070 @@ -332,9 +332,10 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
97071 {
97072 policy->walk.dead = 1;
97073
97074 - atomic_inc(&policy->genid);
97075 + atomic_inc_unchecked(&policy->genid);
97076
97077 - del_timer(&policy->polq.hold_timer);
97078 + if (del_timer(&policy->polq.hold_timer))
97079 + xfrm_pol_put(policy);
97080 xfrm_queue_purge(&policy->polq.hold_queue);
97081
97082 if (del_timer(&policy->timer))
97083 @@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
97084
97085 spin_lock_bh(&pq->hold_queue.lock);
97086 skb_queue_splice_init(&pq->hold_queue, &list);
97087 - del_timer(&pq->hold_timer);
97088 + if (del_timer(&pq->hold_timer))
97089 + xfrm_pol_put(old);
97090 spin_unlock_bh(&pq->hold_queue.lock);
97091
97092 if (skb_queue_empty(&list))
97093 @@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
97094 spin_lock_bh(&pq->hold_queue.lock);
97095 skb_queue_splice(&list, &pq->hold_queue);
97096 pq->timeout = XFRM_QUEUE_TMO_MIN;
97097 - mod_timer(&pq->hold_timer, jiffies);
97098 + if (!mod_timer(&pq->hold_timer, jiffies))
97099 + xfrm_pol_hold(new);
97100 spin_unlock_bh(&pq->hold_queue.lock);
97101 }
97102
97103 @@ -657,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
97104 hlist_add_head(&policy->bydst, chain);
97105 xfrm_pol_hold(policy);
97106 net->xfrm.policy_count[dir]++;
97107 - atomic_inc(&flow_cache_genid);
97108 + atomic_inc_unchecked(&flow_cache_genid);
97109 rt_genid_bump(net);
97110 if (delpol) {
97111 xfrm_policy_requeue(delpol, policy);
97112 @@ -1627,7 +1630,7 @@ free_dst:
97113 goto out;
97114 }
97115
97116 -static int inline
97117 +static inline int
97118 xfrm_dst_alloc_copy(void **target, const void *src, int size)
97119 {
97120 if (!*target) {
97121 @@ -1639,7 +1642,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
97122 return 0;
97123 }
97124
97125 -static int inline
97126 +static inline int
97127 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97128 {
97129 #ifdef CONFIG_XFRM_SUB_POLICY
97130 @@ -1651,7 +1654,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97131 #endif
97132 }
97133
97134 -static int inline
97135 +static inline int
97136 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
97137 {
97138 #ifdef CONFIG_XFRM_SUB_POLICY
97139 @@ -1745,7 +1748,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
97140
97141 xdst->num_pols = num_pols;
97142 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
97143 - xdst->policy_genid = atomic_read(&pols[0]->genid);
97144 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
97145
97146 return xdst;
97147 }
97148 @@ -1763,6 +1766,10 @@ static void xfrm_policy_queue_process(unsigned long arg)
97149
97150 spin_lock(&pq->hold_queue.lock);
97151 skb = skb_peek(&pq->hold_queue);
97152 + if (!skb) {
97153 + spin_unlock(&pq->hold_queue.lock);
97154 + goto out;
97155 + }
97156 dst = skb_dst(skb);
97157 sk = skb->sk;
97158 xfrm_decode_session(skb, &fl, dst->ops->family);
97159 @@ -1781,8 +1788,9 @@ static void xfrm_policy_queue_process(unsigned long arg)
97160 goto purge_queue;
97161
97162 pq->timeout = pq->timeout << 1;
97163 - mod_timer(&pq->hold_timer, jiffies + pq->timeout);
97164 - return;
97165 + if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout))
97166 + xfrm_pol_hold(pol);
97167 + goto out;
97168 }
97169
97170 dst_release(dst);
97171 @@ -1813,11 +1821,14 @@ static void xfrm_policy_queue_process(unsigned long arg)
97172 err = dst_output(skb);
97173 }
97174
97175 +out:
97176 + xfrm_pol_put(pol);
97177 return;
97178
97179 purge_queue:
97180 pq->timeout = 0;
97181 xfrm_queue_purge(&pq->hold_queue);
97182 + xfrm_pol_put(pol);
97183 }
97184
97185 static int xdst_queue_output(struct sk_buff *skb)
97186 @@ -1825,7 +1836,8 @@ static int xdst_queue_output(struct sk_buff *skb)
97187 unsigned long sched_next;
97188 struct dst_entry *dst = skb_dst(skb);
97189 struct xfrm_dst *xdst = (struct xfrm_dst *) dst;
97190 - struct xfrm_policy_queue *pq = &xdst->pols[0]->polq;
97191 + struct xfrm_policy *pol = xdst->pols[0];
97192 + struct xfrm_policy_queue *pq = &pol->polq;
97193
97194 if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) {
97195 kfree_skb(skb);
97196 @@ -1844,10 +1856,12 @@ static int xdst_queue_output(struct sk_buff *skb)
97197 if (del_timer(&pq->hold_timer)) {
97198 if (time_before(pq->hold_timer.expires, sched_next))
97199 sched_next = pq->hold_timer.expires;
97200 + xfrm_pol_put(pol);
97201 }
97202
97203 __skb_queue_tail(&pq->hold_queue, skb);
97204 - mod_timer(&pq->hold_timer, sched_next);
97205 + if (!mod_timer(&pq->hold_timer, sched_next))
97206 + xfrm_pol_hold(pol);
97207
97208 spin_unlock_bh(&pq->hold_queue.lock);
97209
97210 @@ -2557,11 +2571,12 @@ void xfrm_garbage_collect(struct net *net)
97211 }
97212 EXPORT_SYMBOL(xfrm_garbage_collect);
97213
97214 -static void xfrm_garbage_collect_deferred(struct net *net)
97215 +void xfrm_garbage_collect_deferred(struct net *net)
97216 {
97217 flow_cache_flush_deferred();
97218 __xfrm_garbage_collect(net);
97219 }
97220 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
97221
97222 static void xfrm_init_pmtu(struct dst_entry *dst)
97223 {
97224 @@ -2611,7 +2626,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
97225 if (xdst->xfrm_genid != dst->xfrm->genid)
97226 return 0;
97227 if (xdst->num_pols > 0 &&
97228 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
97229 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
97230 return 0;
97231
97232 mtu = dst_mtu(dst->child);
97233 @@ -2699,8 +2714,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
97234 dst_ops->link_failure = xfrm_link_failure;
97235 if (likely(dst_ops->neigh_lookup == NULL))
97236 dst_ops->neigh_lookup = xfrm_neigh_lookup;
97237 - if (likely(afinfo->garbage_collect == NULL))
97238 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
97239 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
97240 }
97241 spin_unlock(&xfrm_policy_afinfo_lock);
97242 @@ -2754,7 +2767,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
97243 dst_ops->check = NULL;
97244 dst_ops->negative_advice = NULL;
97245 dst_ops->link_failure = NULL;
97246 - afinfo->garbage_collect = NULL;
97247 }
97248 return err;
97249 }
97250 @@ -3137,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
97251 sizeof(pol->xfrm_vec[i].saddr));
97252 pol->xfrm_vec[i].encap_family = mp->new_family;
97253 /* flush bundles */
97254 - atomic_inc(&pol->genid);
97255 + atomic_inc_unchecked(&pol->genid);
97256 }
97257 }
97258
97259 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
97260 index 8dafe6d3..dab57da 100644
97261 --- a/net/xfrm/xfrm_replay.c
97262 +++ b/net/xfrm/xfrm_replay.c
97263 @@ -61,9 +61,9 @@ static void xfrm_replay_notify(struct xfrm_state *x, int event)
97264
97265 switch (event) {
97266 case XFRM_REPLAY_UPDATE:
97267 - if (x->replay_maxdiff &&
97268 - (x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
97269 - (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
97270 + if (!x->replay_maxdiff ||
97271 + ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
97272 + (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) {
97273 if (x->xflags & XFRM_TIME_DEFER)
97274 event = XFRM_REPLAY_TIMEOUT;
97275 else
97276 @@ -129,8 +129,7 @@ static int xfrm_replay_check(struct xfrm_state *x,
97277 return 0;
97278
97279 diff = x->replay.seq - seq;
97280 - if (diff >= min_t(unsigned int, x->props.replay_window,
97281 - sizeof(x->replay.bitmap) * 8)) {
97282 + if (diff >= x->props.replay_window) {
97283 x->stats.replay_window++;
97284 goto err;
97285 }
97286 @@ -302,9 +301,10 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
97287
97288 switch (event) {
97289 case XFRM_REPLAY_UPDATE:
97290 - if (x->replay_maxdiff &&
97291 - (replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
97292 - (replay_esn->oseq - preplay_esn->oseq < x->replay_maxdiff)) {
97293 + if (!x->replay_maxdiff ||
97294 + ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
97295 + (replay_esn->oseq - preplay_esn->oseq
97296 + < x->replay_maxdiff))) {
97297 if (x->xflags & XFRM_TIME_DEFER)
97298 event = XFRM_REPLAY_TIMEOUT;
97299 else
97300 @@ -353,28 +353,30 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event)
97301
97302 switch (event) {
97303 case XFRM_REPLAY_UPDATE:
97304 - if (!x->replay_maxdiff)
97305 - break;
97306 -
97307 - if (replay_esn->seq_hi == preplay_esn->seq_hi)
97308 - seq_diff = replay_esn->seq - preplay_esn->seq;
97309 - else
97310 - seq_diff = ~preplay_esn->seq + replay_esn->seq + 1;
97311 -
97312 - if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
97313 - oseq_diff = replay_esn->oseq - preplay_esn->oseq;
97314 - else
97315 - oseq_diff = ~preplay_esn->oseq + replay_esn->oseq + 1;
97316 -
97317 - if (seq_diff < x->replay_maxdiff &&
97318 - oseq_diff < x->replay_maxdiff) {
97319 + if (x->replay_maxdiff) {
97320 + if (replay_esn->seq_hi == preplay_esn->seq_hi)
97321 + seq_diff = replay_esn->seq - preplay_esn->seq;
97322 + else
97323 + seq_diff = ~preplay_esn->seq + replay_esn->seq
97324 + + 1;
97325
97326 - if (x->xflags & XFRM_TIME_DEFER)
97327 - event = XFRM_REPLAY_TIMEOUT;
97328 + if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
97329 + oseq_diff = replay_esn->oseq
97330 + - preplay_esn->oseq;
97331 else
97332 - return;
97333 + oseq_diff = ~preplay_esn->oseq
97334 + + replay_esn->oseq + 1;
97335 +
97336 + if (seq_diff >= x->replay_maxdiff ||
97337 + oseq_diff >= x->replay_maxdiff)
97338 + break;
97339 }
97340
97341 + if (x->xflags & XFRM_TIME_DEFER)
97342 + event = XFRM_REPLAY_TIMEOUT;
97343 + else
97344 + return;
97345 +
97346 break;
97347
97348 case XFRM_REPLAY_TIMEOUT:
97349 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
97350 index 54c0acd..56814bd 100644
97351 --- a/net/xfrm/xfrm_state.c
97352 +++ b/net/xfrm/xfrm_state.c
97353 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
97354
97355 if (unlikely(afinfo == NULL))
97356 return -EAFNOSUPPORT;
97357 - typemap = afinfo->type_map;
97358 + typemap = (const struct xfrm_type **)afinfo->type_map;
97359 spin_lock_bh(&xfrm_type_lock);
97360
97361 - if (likely(typemap[type->proto] == NULL))
97362 + if (likely(typemap[type->proto] == NULL)) {
97363 + pax_open_kernel();
97364 typemap[type->proto] = type;
97365 - else
97366 + pax_close_kernel();
97367 + } else
97368 err = -EEXIST;
97369 spin_unlock_bh(&xfrm_type_lock);
97370 xfrm_state_put_afinfo(afinfo);
97371 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
97372
97373 if (unlikely(afinfo == NULL))
97374 return -EAFNOSUPPORT;
97375 - typemap = afinfo->type_map;
97376 + typemap = (const struct xfrm_type **)afinfo->type_map;
97377 spin_lock_bh(&xfrm_type_lock);
97378
97379 if (unlikely(typemap[type->proto] != type))
97380 err = -ENOENT;
97381 - else
97382 + else {
97383 + pax_open_kernel();
97384 typemap[type->proto] = NULL;
97385 + pax_close_kernel();
97386 + }
97387 spin_unlock_bh(&xfrm_type_lock);
97388 xfrm_state_put_afinfo(afinfo);
97389 return err;
97390 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97391 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97392 {
97393 struct xfrm_state_afinfo *afinfo;
97394 - const struct xfrm_type **typemap;
97395 const struct xfrm_type *type;
97396 int modload_attempted = 0;
97397
97398 @@ -219,9 +223,8 @@ retry:
97399 afinfo = xfrm_state_get_afinfo(family);
97400 if (unlikely(afinfo == NULL))
97401 return NULL;
97402 - typemap = afinfo->type_map;
97403
97404 - type = typemap[proto];
97405 + type = afinfo->type_map[proto];
97406 if (unlikely(type && !try_module_get(type->owner)))
97407 type = NULL;
97408 if (!type && !modload_attempted) {
97409 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97410 return -EAFNOSUPPORT;
97411
97412 err = -EEXIST;
97413 - modemap = afinfo->mode_map;
97414 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97415 spin_lock_bh(&xfrm_mode_lock);
97416 if (modemap[mode->encap])
97417 goto out;
97418 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97419 if (!try_module_get(afinfo->owner))
97420 goto out;
97421
97422 - mode->afinfo = afinfo;
97423 + pax_open_kernel();
97424 + *(const void **)&mode->afinfo = afinfo;
97425 modemap[mode->encap] = mode;
97426 + pax_close_kernel();
97427 err = 0;
97428
97429 out:
97430 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97431 return -EAFNOSUPPORT;
97432
97433 err = -ENOENT;
97434 - modemap = afinfo->mode_map;
97435 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97436 spin_lock_bh(&xfrm_mode_lock);
97437 if (likely(modemap[mode->encap] == mode)) {
97438 + pax_open_kernel();
97439 modemap[mode->encap] = NULL;
97440 + pax_close_kernel();
97441 module_put(mode->afinfo->owner);
97442 err = 0;
97443 }
97444 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97445 u32 xfrm_get_acqseq(void)
97446 {
97447 u32 res;
97448 - static atomic_t acqseq;
97449 + static atomic_unchecked_t acqseq;
97450
97451 do {
97452 - res = atomic_inc_return(&acqseq);
97453 + res = atomic_inc_return_unchecked(&acqseq);
97454 } while (!res);
97455
97456 return res;
97457 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97458 index 05a6e3d..6716ec9 100644
97459 --- a/net/xfrm/xfrm_sysctl.c
97460 +++ b/net/xfrm/xfrm_sysctl.c
97461 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97462
97463 int __net_init xfrm_sysctl_init(struct net *net)
97464 {
97465 - struct ctl_table *table;
97466 + ctl_table_no_const *table;
97467
97468 __xfrm_sysctl_init(net);
97469
97470 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
97471 index 3f565e4..f964d4c 100644
97472 --- a/net/xfrm/xfrm_user.c
97473 +++ b/net/xfrm/xfrm_user.c
97474 @@ -446,7 +446,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
97475 memcpy(&x->sel, &p->sel, sizeof(x->sel));
97476 memcpy(&x->lft, &p->lft, sizeof(x->lft));
97477 x->props.mode = p->mode;
97478 - x->props.replay_window = p->replay_window;
97479 + x->props.replay_window = min_t(unsigned int, p->replay_window,
97480 + sizeof(x->replay.bitmap) * 8);
97481 x->props.reqid = p->reqid;
97482 x->props.family = p->family;
97483 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
97484 @@ -1856,7 +1857,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
97485 if (x->km.state != XFRM_STATE_VALID)
97486 goto out;
97487
97488 - err = xfrm_replay_verify_len(x->replay_esn, rp);
97489 + err = xfrm_replay_verify_len(x->replay_esn, re);
97490 if (err)
97491 goto out;
97492
97493 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97494 index d5d859c..781cbcb 100644
97495 --- a/scripts/Makefile.build
97496 +++ b/scripts/Makefile.build
97497 @@ -111,7 +111,7 @@ endif
97498 endif
97499
97500 # Do not include host rules unless needed
97501 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97502 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97503 include scripts/Makefile.host
97504 endif
97505
97506 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97507 index 686cb0d..9d653bf 100644
97508 --- a/scripts/Makefile.clean
97509 +++ b/scripts/Makefile.clean
97510 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97511 __clean-files := $(extra-y) $(always) \
97512 $(targets) $(clean-files) \
97513 $(host-progs) \
97514 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97515 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97516 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97517
97518 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97519
97520 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97521 index 1ac414f..38575f7 100644
97522 --- a/scripts/Makefile.host
97523 +++ b/scripts/Makefile.host
97524 @@ -31,6 +31,8 @@
97525 # Note: Shared libraries consisting of C++ files are not supported
97526
97527 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97528 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97529 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97530
97531 # C code
97532 # Executables compiled from a single .c file
97533 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97534 # Shared libaries (only .c supported)
97535 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97536 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97537 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97538 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97539 # Remove .so files from "xxx-objs"
97540 host-cobjs := $(filter-out %.so,$(host-cobjs))
97541 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97542
97543 -#Object (.o) files used by the shared libaries
97544 +# Object (.o) files used by the shared libaries
97545 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97546 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97547
97548 # output directory for programs/.o files
97549 # hostprogs-y := tools/build may have been specified. Retrieve directory
97550 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97551 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97552 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97553 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97554 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97555 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97556 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97557 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97558
97559 obj-dirs += $(host-objdirs)
97560 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97561 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97562 $(call if_changed_dep,host-cshobjs)
97563
97564 +# Compile .c file, create position independent .o file
97565 +# host-cxxshobjs -> .o
97566 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97567 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97568 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97569 + $(call if_changed_dep,host-cxxshobjs)
97570 +
97571 # Link a shared library, based on position independent .o files
97572 # *.o -> .so shared library (host-cshlib)
97573 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97574 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97575 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97576 $(call if_changed,host-cshlib)
97577
97578 +# Link a shared library, based on position independent .o files
97579 +# *.o -> .so shared library (host-cxxshlib)
97580 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97581 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97582 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97583 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97584 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97585 + $(call if_changed,host-cxxshlib)
97586 +
97587 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97588 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97589 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97590
97591 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97592 index 078fe1d..fbdb363 100644
97593 --- a/scripts/basic/fixdep.c
97594 +++ b/scripts/basic/fixdep.c
97595 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97596 /*
97597 * Lookup a value in the configuration string.
97598 */
97599 -static int is_defined_config(const char *name, int len, unsigned int hash)
97600 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97601 {
97602 struct item *aux;
97603
97604 @@ -211,10 +211,10 @@ static void clear_config(void)
97605 /*
97606 * Record the use of a CONFIG_* word.
97607 */
97608 -static void use_config(const char *m, int slen)
97609 +static void use_config(const char *m, unsigned int slen)
97610 {
97611 unsigned int hash = strhash(m, slen);
97612 - int c, i;
97613 + unsigned int c, i;
97614
97615 if (is_defined_config(m, slen, hash))
97616 return;
97617 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97618
97619 static void parse_config_file(const char *map, size_t len)
97620 {
97621 - const int *end = (const int *) (map + len);
97622 + const unsigned int *end = (const unsigned int *) (map + len);
97623 /* start at +1, so that p can never be < map */
97624 - const int *m = (const int *) map + 1;
97625 + const unsigned int *m = (const unsigned int *) map + 1;
97626 const char *p, *q;
97627
97628 for (; m < end; m++) {
97629 @@ -435,7 +435,7 @@ static void print_deps(void)
97630 static void traps(void)
97631 {
97632 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97633 - int *p = (int *)test;
97634 + unsigned int *p = (unsigned int *)test;
97635
97636 if (*p != INT_CONF) {
97637 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97638 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97639 new file mode 100644
97640 index 0000000..5e0222d
97641 --- /dev/null
97642 +++ b/scripts/gcc-plugin.sh
97643 @@ -0,0 +1,17 @@
97644 +#!/bin/bash
97645 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97646 +#include "gcc-plugin.h"
97647 +#include "tree.h"
97648 +#include "tm.h"
97649 +#include "rtl.h"
97650 +#ifdef ENABLE_BUILD_WITH_CXX
97651 +#warning $2
97652 +#else
97653 +#warning $1
97654 +#endif
97655 +EOF`
97656 +if [ $? -eq 0 ]
97657 +then
97658 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97659 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97660 +fi
97661 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97662 index 5de5660..d3deb89 100644
97663 --- a/scripts/headers_install.sh
97664 +++ b/scripts/headers_install.sh
97665 @@ -32,6 +32,7 @@ do
97666 FILE="$(basename "$i")"
97667 sed -r \
97668 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97669 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97670 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97671 -e 's@^#include <linux/compiler.h>@@' \
97672 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97673 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97674 index 32b10f5..0d8d2ee 100644
97675 --- a/scripts/link-vmlinux.sh
97676 +++ b/scripts/link-vmlinux.sh
97677 @@ -160,7 +160,7 @@ else
97678 fi;
97679
97680 # final build of init/
97681 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
97682 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
97683
97684 kallsymso=""
97685 kallsyms_vmlinux=""
97686 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
97687 index 2370863..212fbca 100644
97688 --- a/scripts/mod/file2alias.c
97689 +++ b/scripts/mod/file2alias.c
97690 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
97691 unsigned long size, unsigned long id_size,
97692 void *symval)
97693 {
97694 - int i;
97695 + unsigned int i;
97696
97697 if (size % id_size || size < id_size) {
97698 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
97699 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
97700 /* USB is special because the bcdDevice can be matched against a numeric range */
97701 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
97702 static void do_usb_entry(void *symval,
97703 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97704 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
97705 unsigned char range_lo, unsigned char range_hi,
97706 unsigned char max, struct module *mod)
97707 {
97708 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
97709 {
97710 unsigned int devlo, devhi;
97711 unsigned char chi, clo, max;
97712 - int ndigits;
97713 + unsigned int ndigits;
97714
97715 DEF_FIELD(symval, usb_device_id, match_flags);
97716 DEF_FIELD(symval, usb_device_id, idVendor);
97717 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
97718 for (i = 0; i < count; i++) {
97719 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
97720 char acpi_id[sizeof(*id)];
97721 - int j;
97722 + unsigned int j;
97723
97724 buf_printf(&mod->dev_table_buf,
97725 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
97726 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97727
97728 for (j = 0; j < PNP_MAX_DEVICES; j++) {
97729 const char *id = (char *)(*devs)[j].id;
97730 - int i2, j2;
97731 + unsigned int i2, j2;
97732 int dup = 0;
97733
97734 if (!id[0])
97735 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97736 /* add an individual alias for every device entry */
97737 if (!dup) {
97738 char acpi_id[PNP_ID_LEN];
97739 - int k;
97740 + unsigned int k;
97741
97742 buf_printf(&mod->dev_table_buf,
97743 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
97744 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
97745 static int do_dmi_entry(const char *filename, void *symval,
97746 char *alias)
97747 {
97748 - int i, j;
97749 + unsigned int i, j;
97750 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
97751 sprintf(alias, "dmi*");
97752
97753 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
97754 index 6216434..050cf89 100644
97755 --- a/scripts/mod/modpost.c
97756 +++ b/scripts/mod/modpost.c
97757 @@ -930,6 +930,7 @@ enum mismatch {
97758 ANY_INIT_TO_ANY_EXIT,
97759 ANY_EXIT_TO_ANY_INIT,
97760 EXPORT_TO_INIT_EXIT,
97761 + DATA_TO_TEXT
97762 };
97763
97764 struct sectioncheck {
97765 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
97766 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
97767 .mismatch = EXPORT_TO_INIT_EXIT,
97768 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
97769 +},
97770 +/* Do not reference code from writable data */
97771 +{
97772 + .fromsec = { DATA_SECTIONS, NULL },
97773 + .tosec = { TEXT_SECTIONS, NULL },
97774 + .mismatch = DATA_TO_TEXT
97775 }
97776 };
97777
97778 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
97779 continue;
97780 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
97781 continue;
97782 - if (sym->st_value == addr)
97783 - return sym;
97784 /* Find a symbol nearby - addr are maybe negative */
97785 d = sym->st_value - addr;
97786 + if (d == 0)
97787 + return sym;
97788 if (d < 0)
97789 d = addr - sym->st_value;
97790 if (d < distance) {
97791 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
97792 tosym, prl_to, prl_to, tosym);
97793 free(prl_to);
97794 break;
97795 + case DATA_TO_TEXT:
97796 +#if 0
97797 + fprintf(stderr,
97798 + "The %s %s:%s references\n"
97799 + "the %s %s:%s%s\n",
97800 + from, fromsec, fromsym, to, tosec, tosym, to_p);
97801 +#endif
97802 + break;
97803 }
97804 fprintf(stderr, "\n");
97805 }
97806 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97807 static void check_sec_ref(struct module *mod, const char *modname,
97808 struct elf_info *elf)
97809 {
97810 - int i;
97811 + unsigned int i;
97812 Elf_Shdr *sechdrs = elf->sechdrs;
97813
97814 /* Walk through all sections */
97815 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97816 va_end(ap);
97817 }
97818
97819 -void buf_write(struct buffer *buf, const char *s, int len)
97820 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97821 {
97822 if (buf->size - buf->pos < len) {
97823 buf->size += len + SZ;
97824 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
97825 if (fstat(fileno(file), &st) < 0)
97826 goto close_write;
97827
97828 - if (st.st_size != b->pos)
97829 + if (st.st_size != (off_t)b->pos)
97830 goto close_write;
97831
97832 tmp = NOFAIL(malloc(b->pos));
97833 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
97834 index 51207e4..f7d603d 100644
97835 --- a/scripts/mod/modpost.h
97836 +++ b/scripts/mod/modpost.h
97837 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
97838
97839 struct buffer {
97840 char *p;
97841 - int pos;
97842 - int size;
97843 + unsigned int pos;
97844 + unsigned int size;
97845 };
97846
97847 void __attribute__((format(printf, 2, 3)))
97848 buf_printf(struct buffer *buf, const char *fmt, ...);
97849
97850 void
97851 -buf_write(struct buffer *buf, const char *s, int len);
97852 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97853
97854 struct module {
97855 struct module *next;
97856 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97857 index 9dfcd6d..099068e 100644
97858 --- a/scripts/mod/sumversion.c
97859 +++ b/scripts/mod/sumversion.c
97860 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97861 goto out;
97862 }
97863
97864 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97865 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97866 warn("writing sum in %s failed: %s\n",
97867 filename, strerror(errno));
97868 goto out;
97869 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97870 index 0865b3e..7235dd4 100644
97871 --- a/scripts/module-common.lds
97872 +++ b/scripts/module-common.lds
97873 @@ -6,6 +6,10 @@
97874 SECTIONS {
97875 /DISCARD/ : { *(.discard) }
97876
97877 + .rodata : {
97878 + *(.rodata) *(.rodata.*)
97879 + *(.data..read_only)
97880 + }
97881 __ksymtab : { *(SORT(___ksymtab+*)) }
97882 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97883 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97884 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97885 index acb8650..b8c5f02 100644
97886 --- a/scripts/package/builddeb
97887 +++ b/scripts/package/builddeb
97888 @@ -246,6 +246,7 @@ fi
97889 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97890 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97891 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97892 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97893 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97894 mkdir -p "$destdir"
97895 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97896 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97897 index 68bb4ef..2f419e1 100644
97898 --- a/scripts/pnmtologo.c
97899 +++ b/scripts/pnmtologo.c
97900 @@ -244,14 +244,14 @@ static void write_header(void)
97901 fprintf(out, " * Linux logo %s\n", logoname);
97902 fputs(" */\n\n", out);
97903 fputs("#include <linux/linux_logo.h>\n\n", out);
97904 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97905 + fprintf(out, "static unsigned char %s_data[] = {\n",
97906 logoname);
97907 }
97908
97909 static void write_footer(void)
97910 {
97911 fputs("\n};\n\n", out);
97912 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97913 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97914 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97915 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97916 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97917 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97918 fputs("\n};\n\n", out);
97919
97920 /* write logo clut */
97921 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97922 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97923 logoname);
97924 write_hex_cnt = 0;
97925 for (i = 0; i < logo_clutsize; i++) {
97926 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97927 index f5eb43d..1814de8 100644
97928 --- a/scripts/sortextable.h
97929 +++ b/scripts/sortextable.h
97930 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97931 const char *secstrtab;
97932 const char *strtab;
97933 char *extab_image;
97934 - int extab_index = 0;
97935 - int i;
97936 - int idx;
97937 + unsigned int extab_index = 0;
97938 + unsigned int i;
97939 + unsigned int idx;
97940
97941 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97942 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97943 diff --git a/security/Kconfig b/security/Kconfig
97944 index e9c6ac7..031a726 100644
97945 --- a/security/Kconfig
97946 +++ b/security/Kconfig
97947 @@ -4,6 +4,960 @@
97948
97949 menu "Security options"
97950
97951 +menu "Grsecurity"
97952 +
97953 + config ARCH_TRACK_EXEC_LIMIT
97954 + bool
97955 +
97956 + config PAX_KERNEXEC_PLUGIN
97957 + bool
97958 +
97959 + config PAX_PER_CPU_PGD
97960 + bool
97961 +
97962 + config TASK_SIZE_MAX_SHIFT
97963 + int
97964 + depends on X86_64
97965 + default 47 if !PAX_PER_CPU_PGD
97966 + default 42 if PAX_PER_CPU_PGD
97967 +
97968 + config PAX_ENABLE_PAE
97969 + bool
97970 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97971 +
97972 + config PAX_USERCOPY_SLABS
97973 + bool
97974 +
97975 +config GRKERNSEC
97976 + bool "Grsecurity"
97977 + select CRYPTO
97978 + select CRYPTO_SHA256
97979 + select PROC_FS
97980 + select STOP_MACHINE
97981 + select TTY
97982 + select DEBUG_LIST
97983 + help
97984 + If you say Y here, you will be able to configure many features
97985 + that will enhance the security of your system. It is highly
97986 + recommended that you say Y here and read through the help
97987 + for each option so that you fully understand the features and
97988 + can evaluate their usefulness for your machine.
97989 +
97990 +choice
97991 + prompt "Configuration Method"
97992 + depends on GRKERNSEC
97993 + default GRKERNSEC_CONFIG_CUSTOM
97994 + help
97995 +
97996 +config GRKERNSEC_CONFIG_AUTO
97997 + bool "Automatic"
97998 + help
97999 + If you choose this configuration method, you'll be able to answer a small
98000 + number of simple questions about how you plan to use this kernel.
98001 + The settings of grsecurity and PaX will be automatically configured for
98002 + the highest commonly-used settings within the provided constraints.
98003 +
98004 + If you require additional configuration, custom changes can still be made
98005 + from the "custom configuration" menu.
98006 +
98007 +config GRKERNSEC_CONFIG_CUSTOM
98008 + bool "Custom"
98009 + help
98010 + If you choose this configuration method, you'll be able to configure all
98011 + grsecurity and PaX settings manually. Via this method, no options are
98012 + automatically enabled.
98013 +
98014 +endchoice
98015 +
98016 +choice
98017 + prompt "Usage Type"
98018 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98019 + default GRKERNSEC_CONFIG_SERVER
98020 + help
98021 +
98022 +config GRKERNSEC_CONFIG_SERVER
98023 + bool "Server"
98024 + help
98025 + Choose this option if you plan to use this kernel on a server.
98026 +
98027 +config GRKERNSEC_CONFIG_DESKTOP
98028 + bool "Desktop"
98029 + help
98030 + Choose this option if you plan to use this kernel on a desktop.
98031 +
98032 +endchoice
98033 +
98034 +choice
98035 + prompt "Virtualization Type"
98036 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
98037 + default GRKERNSEC_CONFIG_VIRT_NONE
98038 + help
98039 +
98040 +config GRKERNSEC_CONFIG_VIRT_NONE
98041 + bool "None"
98042 + help
98043 + Choose this option if this kernel will be run on bare metal.
98044 +
98045 +config GRKERNSEC_CONFIG_VIRT_GUEST
98046 + bool "Guest"
98047 + help
98048 + Choose this option if this kernel will be run as a VM guest.
98049 +
98050 +config GRKERNSEC_CONFIG_VIRT_HOST
98051 + bool "Host"
98052 + help
98053 + Choose this option if this kernel will be run as a VM host.
98054 +
98055 +endchoice
98056 +
98057 +choice
98058 + prompt "Virtualization Hardware"
98059 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98060 + help
98061 +
98062 +config GRKERNSEC_CONFIG_VIRT_EPT
98063 + bool "EPT/RVI Processor Support"
98064 + depends on X86
98065 + help
98066 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
98067 + hardware virtualization. This allows for additional kernel hardening protections
98068 + to operate without additional performance impact.
98069 +
98070 + To see if your Intel processor supports EPT, see:
98071 + http://ark.intel.com/Products/VirtualizationTechnology
98072 + (Most Core i3/5/7 support EPT)
98073 +
98074 + To see if your AMD processor supports RVI, see:
98075 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
98076 +
98077 +config GRKERNSEC_CONFIG_VIRT_SOFT
98078 + bool "First-gen/No Hardware Virtualization"
98079 + help
98080 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
98081 + support hardware virtualization or doesn't support the EPT/RVI extensions.
98082 +
98083 +endchoice
98084 +
98085 +choice
98086 + prompt "Virtualization Software"
98087 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98088 + help
98089 +
98090 +config GRKERNSEC_CONFIG_VIRT_XEN
98091 + bool "Xen"
98092 + help
98093 + Choose this option if this kernel is running as a Xen guest or host.
98094 +
98095 +config GRKERNSEC_CONFIG_VIRT_VMWARE
98096 + bool "VMWare"
98097 + help
98098 + Choose this option if this kernel is running as a VMWare guest or host.
98099 +
98100 +config GRKERNSEC_CONFIG_VIRT_KVM
98101 + bool "KVM"
98102 + help
98103 + Choose this option if this kernel is running as a KVM guest or host.
98104 +
98105 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
98106 + bool "VirtualBox"
98107 + help
98108 + Choose this option if this kernel is running as a VirtualBox guest or host.
98109 +
98110 +endchoice
98111 +
98112 +choice
98113 + prompt "Required Priorities"
98114 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98115 + default GRKERNSEC_CONFIG_PRIORITY_PERF
98116 + help
98117 +
98118 +config GRKERNSEC_CONFIG_PRIORITY_PERF
98119 + bool "Performance"
98120 + help
98121 + Choose this option if performance is of highest priority for this deployment
98122 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
98123 + clearing of structures intended for userland, and freed memory sanitizing will
98124 + be disabled.
98125 +
98126 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
98127 + bool "Security"
98128 + help
98129 + Choose this option if security is of highest priority for this deployment of
98130 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
98131 + for userland, and freed memory sanitizing will be enabled for this kernel.
98132 + In a worst-case scenario, these features can introduce a 20% performance hit
98133 + (UDEREF on x64 contributing half of this hit).
98134 +
98135 +endchoice
98136 +
98137 +menu "Default Special Groups"
98138 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98139 +
98140 +config GRKERNSEC_PROC_GID
98141 + int "GID exempted from /proc restrictions"
98142 + default 1001
98143 + help
98144 + Setting this GID determines which group will be exempted from
98145 + grsecurity's /proc restrictions, allowing users of the specified
98146 + group to view network statistics and the existence of other users'
98147 + processes on the system. This GID may also be chosen at boot time
98148 + via "grsec_proc_gid=" on the kernel commandline.
98149 +
98150 +config GRKERNSEC_TPE_UNTRUSTED_GID
98151 + int "GID for TPE-untrusted users"
98152 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
98153 + default 1005
98154 + help
98155 + Setting this GID determines which group untrusted users should
98156 + be added to. These users will be placed under grsecurity's Trusted Path
98157 + Execution mechanism, preventing them from executing their own binaries.
98158 + The users will only be able to execute binaries in directories owned and
98159 + writable only by the root user. If the sysctl option is enabled, a sysctl
98160 + option with name "tpe_gid" is created.
98161 +
98162 +config GRKERNSEC_TPE_TRUSTED_GID
98163 + int "GID for TPE-trusted users"
98164 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
98165 + default 1005
98166 + help
98167 + Setting this GID determines what group TPE restrictions will be
98168 + *disabled* for. If the sysctl option is enabled, a sysctl option
98169 + with name "tpe_gid" is created.
98170 +
98171 +config GRKERNSEC_SYMLINKOWN_GID
98172 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
98173 + depends on GRKERNSEC_CONFIG_SERVER
98174 + default 1006
98175 + help
98176 + Setting this GID determines what group kernel-enforced
98177 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
98178 + is enabled, a sysctl option with name "symlinkown_gid" is created.
98179 +
98180 +
98181 +endmenu
98182 +
98183 +menu "Customize Configuration"
98184 +depends on GRKERNSEC
98185 +
98186 +menu "PaX"
98187 +
98188 +config PAX
98189 + bool "Enable various PaX features"
98190 + default y if GRKERNSEC_CONFIG_AUTO
98191 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
98192 + help
98193 + This allows you to enable various PaX features. PaX adds
98194 + intrusion prevention mechanisms to the kernel that reduce
98195 + the risks posed by exploitable memory corruption bugs.
98196 +
98197 +menu "PaX Control"
98198 + depends on PAX
98199 +
98200 +config PAX_SOFTMODE
98201 + bool 'Support soft mode'
98202 + help
98203 + Enabling this option will allow you to run PaX in soft mode, that
98204 + is, PaX features will not be enforced by default, only on executables
98205 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
98206 + support as they are the only way to mark executables for soft mode use.
98207 +
98208 + Soft mode can be activated by using the "pax_softmode=1" kernel command
98209 + line option on boot. Furthermore you can control various PaX features
98210 + at runtime via the entries in /proc/sys/kernel/pax.
98211 +
98212 +config PAX_EI_PAX
98213 + bool 'Use legacy ELF header marking'
98214 + default y if GRKERNSEC_CONFIG_AUTO
98215 + help
98216 + Enabling this option will allow you to control PaX features on
98217 + a per executable basis via the 'chpax' utility available at
98218 + http://pax.grsecurity.net/. The control flags will be read from
98219 + an otherwise reserved part of the ELF header. This marking has
98220 + numerous drawbacks (no support for soft-mode, toolchain does not
98221 + know about the non-standard use of the ELF header) therefore it
98222 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
98223 + support.
98224 +
98225 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
98226 + support as well, they will override the legacy EI_PAX marks.
98227 +
98228 + If you enable none of the marking options then all applications
98229 + will run with PaX enabled on them by default.
98230 +
98231 +config PAX_PT_PAX_FLAGS
98232 + bool 'Use ELF program header marking'
98233 + default y if GRKERNSEC_CONFIG_AUTO
98234 + help
98235 + Enabling this option will allow you to control PaX features on
98236 + a per executable basis via the 'paxctl' utility available at
98237 + http://pax.grsecurity.net/. The control flags will be read from
98238 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
98239 + has the benefits of supporting both soft mode and being fully
98240 + integrated into the toolchain (the binutils patch is available
98241 + from http://pax.grsecurity.net).
98242 +
98243 + Note that if you enable the legacy EI_PAX marking support as well,
98244 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
98245 +
98246 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98247 + must make sure that the marks are the same if a binary has both marks.
98248 +
98249 + If you enable none of the marking options then all applications
98250 + will run with PaX enabled on them by default.
98251 +
98252 +config PAX_XATTR_PAX_FLAGS
98253 + bool 'Use filesystem extended attributes marking'
98254 + default y if GRKERNSEC_CONFIG_AUTO
98255 + select CIFS_XATTR if CIFS
98256 + select EXT2_FS_XATTR if EXT2_FS
98257 + select EXT3_FS_XATTR if EXT3_FS
98258 + select EXT4_FS_XATTR if EXT4_FS
98259 + select JFFS2_FS_XATTR if JFFS2_FS
98260 + select REISERFS_FS_XATTR if REISERFS_FS
98261 + select SQUASHFS_XATTR if SQUASHFS
98262 + select TMPFS_XATTR if TMPFS
98263 + select UBIFS_FS_XATTR if UBIFS_FS
98264 + help
98265 + Enabling this option will allow you to control PaX features on
98266 + a per executable basis via the 'setfattr' utility. The control
98267 + flags will be read from the user.pax.flags extended attribute of
98268 + the file. This marking has the benefit of supporting binary-only
98269 + applications that self-check themselves (e.g., skype) and would
98270 + not tolerate chpax/paxctl changes. The main drawback is that
98271 + extended attributes are not supported by some filesystems (e.g.,
98272 + isofs, udf, vfat) so copying files through such filesystems will
98273 + lose the extended attributes and these PaX markings.
98274 +
98275 + Note that if you enable the legacy EI_PAX marking support as well,
98276 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
98277 +
98278 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98279 + must make sure that the marks are the same if a binary has both marks.
98280 +
98281 + If you enable none of the marking options then all applications
98282 + will run with PaX enabled on them by default.
98283 +
98284 +choice
98285 + prompt 'MAC system integration'
98286 + default PAX_HAVE_ACL_FLAGS
98287 + help
98288 + Mandatory Access Control systems have the option of controlling
98289 + PaX flags on a per executable basis, choose the method supported
98290 + by your particular system.
98291 +
98292 + - "none": if your MAC system does not interact with PaX,
98293 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
98294 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
98295 +
98296 + NOTE: this option is for developers/integrators only.
98297 +
98298 + config PAX_NO_ACL_FLAGS
98299 + bool 'none'
98300 +
98301 + config PAX_HAVE_ACL_FLAGS
98302 + bool 'direct'
98303 +
98304 + config PAX_HOOK_ACL_FLAGS
98305 + bool 'hook'
98306 +endchoice
98307 +
98308 +endmenu
98309 +
98310 +menu "Non-executable pages"
98311 + depends on PAX
98312 +
98313 +config PAX_NOEXEC
98314 + bool "Enforce non-executable pages"
98315 + default y if GRKERNSEC_CONFIG_AUTO
98316 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
98317 + help
98318 + By design some architectures do not allow for protecting memory
98319 + pages against execution or even if they do, Linux does not make
98320 + use of this feature. In practice this means that if a page is
98321 + readable (such as the stack or heap) it is also executable.
98322 +
98323 + There is a well known exploit technique that makes use of this
98324 + fact and a common programming mistake where an attacker can
98325 + introduce code of his choice somewhere in the attacked program's
98326 + memory (typically the stack or the heap) and then execute it.
98327 +
98328 + If the attacked program was running with different (typically
98329 + higher) privileges than that of the attacker, then he can elevate
98330 + his own privilege level (e.g. get a root shell, write to files for
98331 + which he does not have write access to, etc).
98332 +
98333 + Enabling this option will let you choose from various features
98334 + that prevent the injection and execution of 'foreign' code in
98335 + a program.
98336 +
98337 + This will also break programs that rely on the old behaviour and
98338 + expect that dynamically allocated memory via the malloc() family
98339 + of functions is executable (which it is not). Notable examples
98340 + are the XFree86 4.x server, the java runtime and wine.
98341 +
98342 +config PAX_PAGEEXEC
98343 + bool "Paging based non-executable pages"
98344 + default y if GRKERNSEC_CONFIG_AUTO
98345 + 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)
98346 + select ARCH_TRACK_EXEC_LIMIT if X86_32
98347 + help
98348 + This implementation is based on the paging feature of the CPU.
98349 + On i386 without hardware non-executable bit support there is a
98350 + variable but usually low performance impact, however on Intel's
98351 + P4 core based CPUs it is very high so you should not enable this
98352 + for kernels meant to be used on such CPUs.
98353 +
98354 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
98355 + with hardware non-executable bit support there is no performance
98356 + impact, on ppc the impact is negligible.
98357 +
98358 + Note that several architectures require various emulations due to
98359 + badly designed userland ABIs, this will cause a performance impact
98360 + but will disappear as soon as userland is fixed. For example, ppc
98361 + userland MUST have been built with secure-plt by a recent toolchain.
98362 +
98363 +config PAX_SEGMEXEC
98364 + bool "Segmentation based non-executable pages"
98365 + default y if GRKERNSEC_CONFIG_AUTO
98366 + depends on PAX_NOEXEC && X86_32
98367 + help
98368 + This implementation is based on the segmentation feature of the
98369 + CPU and has a very small performance impact, however applications
98370 + will be limited to a 1.5 GB address space instead of the normal
98371 + 3 GB.
98372 +
98373 +config PAX_EMUTRAMP
98374 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98375 + default y if PARISC
98376 + help
98377 + There are some programs and libraries that for one reason or
98378 + another attempt to execute special small code snippets from
98379 + non-executable memory pages. Most notable examples are the
98380 + signal handler return code generated by the kernel itself and
98381 + the GCC trampolines.
98382 +
98383 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98384 + such programs will no longer work under your kernel.
98385 +
98386 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98387 + utilities to enable trampoline emulation for the affected programs
98388 + yet still have the protection provided by the non-executable pages.
98389 +
98390 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98391 + your system will not even boot.
98392 +
98393 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98394 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98395 + for the affected files.
98396 +
98397 + NOTE: enabling this feature *may* open up a loophole in the
98398 + protection provided by non-executable pages that an attacker
98399 + could abuse. Therefore the best solution is to not have any
98400 + files on your system that would require this option. This can
98401 + be achieved by not using libc5 (which relies on the kernel
98402 + signal handler return code) and not using or rewriting programs
98403 + that make use of the nested function implementation of GCC.
98404 + Skilled users can just fix GCC itself so that it implements
98405 + nested function calls in a way that does not interfere with PaX.
98406 +
98407 +config PAX_EMUSIGRT
98408 + bool "Automatically emulate sigreturn trampolines"
98409 + depends on PAX_EMUTRAMP && PARISC
98410 + default y
98411 + help
98412 + Enabling this option will have the kernel automatically detect
98413 + and emulate signal return trampolines executing on the stack
98414 + that would otherwise lead to task termination.
98415 +
98416 + This solution is intended as a temporary one for users with
98417 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98418 + Modula-3 runtime, etc) or executables linked to such, basically
98419 + everything that does not specify its own SA_RESTORER function in
98420 + normal executable memory like glibc 2.1+ does.
98421 +
98422 + On parisc you MUST enable this option, otherwise your system will
98423 + not even boot.
98424 +
98425 + NOTE: this feature cannot be disabled on a per executable basis
98426 + and since it *does* open up a loophole in the protection provided
98427 + by non-executable pages, the best solution is to not have any
98428 + files on your system that would require this option.
98429 +
98430 +config PAX_MPROTECT
98431 + bool "Restrict mprotect()"
98432 + default y if GRKERNSEC_CONFIG_AUTO
98433 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98434 + help
98435 + Enabling this option will prevent programs from
98436 + - changing the executable status of memory pages that were
98437 + not originally created as executable,
98438 + - making read-only executable pages writable again,
98439 + - creating executable pages from anonymous memory,
98440 + - making read-only-after-relocations (RELRO) data pages writable again.
98441 +
98442 + You should say Y here to complete the protection provided by
98443 + the enforcement of non-executable pages.
98444 +
98445 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98446 + this feature on a per file basis.
98447 +
98448 +config PAX_MPROTECT_COMPAT
98449 + bool "Use legacy/compat protection demoting (read help)"
98450 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98451 + depends on PAX_MPROTECT
98452 + help
98453 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98454 + by sending the proper error code to the application. For some broken
98455 + userland, this can cause problems with Python or other applications. The
98456 + current implementation however allows for applications like clamav to
98457 + detect if JIT compilation/execution is allowed and to fall back gracefully
98458 + to an interpreter-based mode if it does not. While we encourage everyone
98459 + to use the current implementation as-is and push upstream to fix broken
98460 + userland (note that the RWX logging option can assist with this), in some
98461 + environments this may not be possible. Having to disable MPROTECT
98462 + completely on certain binaries reduces the security benefit of PaX,
98463 + so this option is provided for those environments to revert to the old
98464 + behavior.
98465 +
98466 +config PAX_ELFRELOCS
98467 + bool "Allow ELF text relocations (read help)"
98468 + depends on PAX_MPROTECT
98469 + default n
98470 + help
98471 + Non-executable pages and mprotect() restrictions are effective
98472 + in preventing the introduction of new executable code into an
98473 + attacked task's address space. There remain only two venues
98474 + for this kind of attack: if the attacker can execute already
98475 + existing code in the attacked task then he can either have it
98476 + create and mmap() a file containing his code or have it mmap()
98477 + an already existing ELF library that does not have position
98478 + independent code in it and use mprotect() on it to make it
98479 + writable and copy his code there. While protecting against
98480 + the former approach is beyond PaX, the latter can be prevented
98481 + by having only PIC ELF libraries on one's system (which do not
98482 + need to relocate their code). If you are sure this is your case,
98483 + as is the case with all modern Linux distributions, then leave
98484 + this option disabled. You should say 'n' here.
98485 +
98486 +config PAX_ETEXECRELOCS
98487 + bool "Allow ELF ET_EXEC text relocations"
98488 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98489 + select PAX_ELFRELOCS
98490 + default y
98491 + help
98492 + On some architectures there are incorrectly created applications
98493 + that require text relocations and would not work without enabling
98494 + this option. If you are an alpha, ia64 or parisc user, you should
98495 + enable this option and disable it once you have made sure that
98496 + none of your applications need it.
98497 +
98498 +config PAX_EMUPLT
98499 + bool "Automatically emulate ELF PLT"
98500 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98501 + default y
98502 + help
98503 + Enabling this option will have the kernel automatically detect
98504 + and emulate the Procedure Linkage Table entries in ELF files.
98505 + On some architectures such entries are in writable memory, and
98506 + become non-executable leading to task termination. Therefore
98507 + it is mandatory that you enable this option on alpha, parisc,
98508 + sparc and sparc64, otherwise your system would not even boot.
98509 +
98510 + NOTE: this feature *does* open up a loophole in the protection
98511 + provided by the non-executable pages, therefore the proper
98512 + solution is to modify the toolchain to produce a PLT that does
98513 + not need to be writable.
98514 +
98515 +config PAX_DLRESOLVE
98516 + bool 'Emulate old glibc resolver stub'
98517 + depends on PAX_EMUPLT && SPARC
98518 + default n
98519 + help
98520 + This option is needed if userland has an old glibc (before 2.4)
98521 + that puts a 'save' instruction into the runtime generated resolver
98522 + stub that needs special emulation.
98523 +
98524 +config PAX_KERNEXEC
98525 + bool "Enforce non-executable kernel pages"
98526 + 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))
98527 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98528 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98529 + select PAX_KERNEXEC_PLUGIN if X86_64
98530 + help
98531 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98532 + that is, enabling this option will make it harder to inject
98533 + and execute 'foreign' code in kernel memory itself.
98534 +
98535 +choice
98536 + prompt "Return Address Instrumentation Method"
98537 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98538 + depends on PAX_KERNEXEC_PLUGIN
98539 + help
98540 + Select the method used to instrument function pointer dereferences.
98541 + Note that binary modules cannot be instrumented by this approach.
98542 +
98543 + Note that the implementation requires a gcc with plugin support,
98544 + i.e., gcc 4.5 or newer. You may need to install the supporting
98545 + headers explicitly in addition to the normal gcc package.
98546 +
98547 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98548 + bool "bts"
98549 + help
98550 + This method is compatible with binary only modules but has
98551 + a higher runtime overhead.
98552 +
98553 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98554 + bool "or"
98555 + depends on !PARAVIRT
98556 + help
98557 + This method is incompatible with binary only modules but has
98558 + a lower runtime overhead.
98559 +endchoice
98560 +
98561 +config PAX_KERNEXEC_PLUGIN_METHOD
98562 + string
98563 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98564 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98565 + default ""
98566 +
98567 +config PAX_KERNEXEC_MODULE_TEXT
98568 + int "Minimum amount of memory reserved for module code"
98569 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98570 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98571 + depends on PAX_KERNEXEC && X86_32
98572 + help
98573 + Due to implementation details the kernel must reserve a fixed
98574 + amount of memory for runtime allocated code (such as modules)
98575 + at compile time that cannot be changed at runtime. Here you
98576 + can specify the minimum amount in MB that will be reserved.
98577 + Due to the same implementation details this size will always
98578 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98579 + the actually available memory for runtime allocated code will
98580 + usually be more than this minimum.
98581 +
98582 + The default 4 MB should be enough for most users but if you have
98583 + an excessive number of modules (e.g., most distribution configs
98584 + compile many drivers as modules) or use huge modules such as
98585 + nvidia's kernel driver, you will need to adjust this amount.
98586 + A good rule of thumb is to look at your currently loaded kernel
98587 + modules and add up their sizes.
98588 +
98589 +endmenu
98590 +
98591 +menu "Address Space Layout Randomization"
98592 + depends on PAX
98593 +
98594 +config PAX_ASLR
98595 + bool "Address Space Layout Randomization"
98596 + default y if GRKERNSEC_CONFIG_AUTO
98597 + help
98598 + Many if not most exploit techniques rely on the knowledge of
98599 + certain addresses in the attacked program. The following options
98600 + will allow the kernel to apply a certain amount of randomization
98601 + to specific parts of the program thereby forcing an attacker to
98602 + guess them in most cases. Any failed guess will most likely crash
98603 + the attacked program which allows the kernel to detect such attempts
98604 + and react on them. PaX itself provides no reaction mechanisms,
98605 + instead it is strongly encouraged that you make use of Nergal's
98606 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98607 + (http://www.grsecurity.net/) built-in crash detection features or
98608 + develop one yourself.
98609 +
98610 + By saying Y here you can choose to randomize the following areas:
98611 + - top of the task's kernel stack
98612 + - top of the task's userland stack
98613 + - base address for mmap() requests that do not specify one
98614 + (this includes all libraries)
98615 + - base address of the main executable
98616 +
98617 + It is strongly recommended to say Y here as address space layout
98618 + randomization has negligible impact on performance yet it provides
98619 + a very effective protection.
98620 +
98621 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98622 + this feature on a per file basis.
98623 +
98624 +config PAX_RANDKSTACK
98625 + bool "Randomize kernel stack base"
98626 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98627 + depends on X86_TSC && X86
98628 + help
98629 + By saying Y here the kernel will randomize every task's kernel
98630 + stack on every system call. This will not only force an attacker
98631 + to guess it but also prevent him from making use of possible
98632 + leaked information about it.
98633 +
98634 + Since the kernel stack is a rather scarce resource, randomization
98635 + may cause unexpected stack overflows, therefore you should very
98636 + carefully test your system. Note that once enabled in the kernel
98637 + configuration, this feature cannot be disabled on a per file basis.
98638 +
98639 +config PAX_RANDUSTACK
98640 + bool "Randomize user stack base"
98641 + default y if GRKERNSEC_CONFIG_AUTO
98642 + depends on PAX_ASLR
98643 + help
98644 + By saying Y here the kernel will randomize every task's userland
98645 + stack. The randomization is done in two steps where the second
98646 + one may apply a big amount of shift to the top of the stack and
98647 + cause problems for programs that want to use lots of memory (more
98648 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98649 + For this reason the second step can be controlled by 'chpax' or
98650 + 'paxctl' on a per file basis.
98651 +
98652 +config PAX_RANDMMAP
98653 + bool "Randomize mmap() base"
98654 + default y if GRKERNSEC_CONFIG_AUTO
98655 + depends on PAX_ASLR
98656 + help
98657 + By saying Y here the kernel will use a randomized base address for
98658 + mmap() requests that do not specify one themselves. As a result
98659 + all dynamically loaded libraries will appear at random addresses
98660 + and therefore be harder to exploit by a technique where an attacker
98661 + attempts to execute library code for his purposes (e.g. spawn a
98662 + shell from an exploited program that is running at an elevated
98663 + privilege level).
98664 +
98665 + Furthermore, if a program is relinked as a dynamic ELF file, its
98666 + base address will be randomized as well, completing the full
98667 + randomization of the address space layout. Attacking such programs
98668 + becomes a guess game. You can find an example of doing this at
98669 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
98670 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
98671 +
98672 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
98673 + feature on a per file basis.
98674 +
98675 +endmenu
98676 +
98677 +menu "Miscellaneous hardening features"
98678 +
98679 +config PAX_MEMORY_SANITIZE
98680 + bool "Sanitize all freed memory"
98681 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98682 + depends on !HIBERNATION
98683 + help
98684 + By saying Y here the kernel will erase memory pages and slab objects
98685 + as soon as they are freed. This in turn reduces the lifetime of data
98686 + stored in them, making it less likely that sensitive information such
98687 + as passwords, cryptographic secrets, etc stay in memory for too long.
98688 +
98689 + This is especially useful for programs whose runtime is short, long
98690 + lived processes and the kernel itself benefit from this as long as
98691 + they ensure timely freeing of memory that may hold sensitive
98692 + information.
98693 +
98694 + A nice side effect of the sanitization of slab objects is the
98695 + reduction of possible info leaks caused by padding bytes within the
98696 + leaky structures. Use-after-free bugs for structures containing
98697 + pointers can also be detected as dereferencing the sanitized pointer
98698 + will generate an access violation.
98699 +
98700 + The tradeoff is performance impact, on a single CPU system kernel
98701 + compilation sees a 3% slowdown, other systems and workloads may vary
98702 + and you are advised to test this feature on your expected workload
98703 + before deploying it.
98704 +
98705 + To reduce the performance penalty by sanitizing pages only, albeit
98706 + limiting the effectiveness of this feature at the same time, slab
98707 + sanitization can be disabled with the kernel commandline parameter
98708 + "pax_sanitize_slab=0".
98709 +
98710 + Note that this feature does not protect data stored in live pages,
98711 + e.g., process memory swapped to disk may stay there for a long time.
98712 +
98713 +config PAX_MEMORY_STACKLEAK
98714 + bool "Sanitize kernel stack"
98715 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98716 + depends on X86
98717 + help
98718 + By saying Y here the kernel will erase the kernel stack before it
98719 + returns from a system call. This in turn reduces the information
98720 + that a kernel stack leak bug can reveal.
98721 +
98722 + Note that such a bug can still leak information that was put on
98723 + the stack by the current system call (the one eventually triggering
98724 + the bug) but traces of earlier system calls on the kernel stack
98725 + cannot leak anymore.
98726 +
98727 + The tradeoff is performance impact: on a single CPU system kernel
98728 + compilation sees a 1% slowdown, other systems and workloads may vary
98729 + and you are advised to test this feature on your expected workload
98730 + before deploying it.
98731 +
98732 + Note that the full feature requires a gcc with plugin support,
98733 + i.e., gcc 4.5 or newer. You may need to install the supporting
98734 + headers explicitly in addition to the normal gcc package. Using
98735 + older gcc versions means that functions with large enough stack
98736 + frames may leave uninitialized memory behind that may be exposed
98737 + to a later syscall leaking the stack.
98738 +
98739 +config PAX_MEMORY_STRUCTLEAK
98740 + bool "Forcibly initialize local variables copied to userland"
98741 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98742 + help
98743 + By saying Y here the kernel will zero initialize some local
98744 + variables that are going to be copied to userland. This in
98745 + turn prevents unintended information leakage from the kernel
98746 + stack should later code forget to explicitly set all parts of
98747 + the copied variable.
98748 +
98749 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
98750 + at a much smaller coverage.
98751 +
98752 + Note that the implementation requires a gcc with plugin support,
98753 + i.e., gcc 4.5 or newer. You may need to install the supporting
98754 + headers explicitly in addition to the normal gcc package.
98755 +
98756 +config PAX_MEMORY_UDEREF
98757 + bool "Prevent invalid userland pointer dereference"
98758 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
98759 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
98760 + select PAX_PER_CPU_PGD if X86_64
98761 + help
98762 + By saying Y here the kernel will be prevented from dereferencing
98763 + userland pointers in contexts where the kernel expects only kernel
98764 + pointers. This is both a useful runtime debugging feature and a
98765 + security measure that prevents exploiting a class of kernel bugs.
98766 +
98767 + The tradeoff is that some virtualization solutions may experience
98768 + a huge slowdown and therefore you should not enable this feature
98769 + for kernels meant to run in such environments. Whether a given VM
98770 + solution is affected or not is best determined by simply trying it
98771 + out, the performance impact will be obvious right on boot as this
98772 + mechanism engages from very early on. A good rule of thumb is that
98773 + VMs running on CPUs without hardware virtualization support (i.e.,
98774 + the majority of IA-32 CPUs) will likely experience the slowdown.
98775 +
98776 + On X86_64 the kernel will make use of PCID support when available
98777 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
98778 + or performance impact. Pass pax_weakuderef on the kernel command
98779 + line to choose the latter.
98780 +
98781 +config PAX_REFCOUNT
98782 + bool "Prevent various kernel object reference counter overflows"
98783 + default y if GRKERNSEC_CONFIG_AUTO
98784 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
98785 + help
98786 + By saying Y here the kernel will detect and prevent overflowing
98787 + various (but not all) kinds of object reference counters. Such
98788 + overflows can normally occur due to bugs only and are often, if
98789 + not always, exploitable.
98790 +
98791 + The tradeoff is that data structures protected by an overflowed
98792 + refcount will never be freed and therefore will leak memory. Note
98793 + that this leak also happens even without this protection but in
98794 + that case the overflow can eventually trigger the freeing of the
98795 + data structure while it is still being used elsewhere, resulting
98796 + in the exploitable situation that this feature prevents.
98797 +
98798 + Since this has a negligible performance impact, you should enable
98799 + this feature.
98800 +
98801 +config PAX_CONSTIFY_PLUGIN
98802 + bool "Automatically constify eligible structures"
98803 + default y
98804 + depends on !UML && PAX_KERNEXEC
98805 + help
98806 + By saying Y here the compiler will automatically constify a class
98807 + of types that contain only function pointers. This reduces the
98808 + kernel's attack surface and also produces a better memory layout.
98809 +
98810 + Note that the implementation requires a gcc with plugin support,
98811 + i.e., gcc 4.5 or newer. You may need to install the supporting
98812 + headers explicitly in addition to the normal gcc package.
98813 +
98814 + Note that if some code really has to modify constified variables
98815 + then the source code will have to be patched to allow it. Examples
98816 + can be found in PaX itself (the no_const attribute) and for some
98817 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98818 +
98819 +config PAX_USERCOPY
98820 + bool "Harden heap object copies between kernel and userland"
98821 + default y if GRKERNSEC_CONFIG_AUTO
98822 + depends on ARM || IA64 || PPC || SPARC || X86
98823 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
98824 + select PAX_USERCOPY_SLABS
98825 + help
98826 + By saying Y here the kernel will enforce the size of heap objects
98827 + when they are copied in either direction between the kernel and
98828 + userland, even if only a part of the heap object is copied.
98829 +
98830 + Specifically, this checking prevents information leaking from the
98831 + kernel heap during kernel to userland copies (if the kernel heap
98832 + object is otherwise fully initialized) and prevents kernel heap
98833 + overflows during userland to kernel copies.
98834 +
98835 + Note that the current implementation provides the strictest bounds
98836 + checks for the SLUB allocator.
98837 +
98838 + Enabling this option also enables per-slab cache protection against
98839 + data in a given cache being copied into/out of via userland
98840 + accessors. Though the whitelist of regions will be reduced over
98841 + time, it notably protects important data structures like task structs.
98842 +
98843 + If frame pointers are enabled on x86, this option will also restrict
98844 + copies into and out of the kernel stack to local variables within a
98845 + single frame.
98846 +
98847 + Since this has a negligible performance impact, you should enable
98848 + this feature.
98849 +
98850 +config PAX_USERCOPY_DEBUG
98851 + bool
98852 + depends on X86 && PAX_USERCOPY
98853 + default n
98854 +
98855 +config PAX_SIZE_OVERFLOW
98856 + bool "Prevent various integer overflows in function size parameters"
98857 + default y if GRKERNSEC_CONFIG_AUTO
98858 + depends on X86
98859 + help
98860 + By saying Y here the kernel recomputes expressions of function
98861 + arguments marked by a size_overflow attribute with double integer
98862 + precision (DImode/TImode for 32/64 bit integer types).
98863 +
98864 + The recomputed argument is checked against TYPE_MAX and an event
98865 + is logged on overflow and the triggering process is killed.
98866 +
98867 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98868 +
98869 + Note that the implementation requires a gcc with plugin support,
98870 + i.e., gcc 4.5 or newer. You may need to install the supporting
98871 + headers explicitly in addition to the normal gcc package.
98872 +
98873 +config PAX_LATENT_ENTROPY
98874 + bool "Generate some entropy during boot and runtime"
98875 + default y if GRKERNSEC_CONFIG_AUTO
98876 + help
98877 + By saying Y here the kernel will instrument some kernel code to
98878 + extract some entropy from both original and artificially created
98879 + program state. This will help especially embedded systems where
98880 + there is little 'natural' source of entropy normally. The cost
98881 + is some slowdown of the boot process and fork and irq processing.
98882 +
98883 + When pax_extra_latent_entropy is passed on the kernel command line,
98884 + entropy will be extracted from up to the first 4GB of RAM while the
98885 + runtime memory allocator is being initialized. This costs even more
98886 + slowdown of the boot process.
98887 +
98888 + Note that the implementation requires a gcc with plugin support,
98889 + i.e., gcc 4.5 or newer. You may need to install the supporting
98890 + headers explicitly in addition to the normal gcc package.
98891 +
98892 + Note that entropy extracted this way is not cryptographically
98893 + secure!
98894 +
98895 +endmenu
98896 +
98897 +endmenu
98898 +
98899 +source grsecurity/Kconfig
98900 +
98901 +endmenu
98902 +
98903 +endmenu
98904 +
98905 source security/keys/Kconfig
98906
98907 config SECURITY_DMESG_RESTRICT
98908 @@ -103,7 +1057,7 @@ config INTEL_TXT
98909 config LSM_MMAP_MIN_ADDR
98910 int "Low address space for LSM to protect from user allocation"
98911 depends on SECURITY && SECURITY_SELINUX
98912 - default 32768 if ARM
98913 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98914 default 65536
98915 help
98916 This is the portion of low virtual memory which should be protected
98917 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98918 index 9b9013b..51ebf96 100644
98919 --- a/security/apparmor/Kconfig
98920 +++ b/security/apparmor/Kconfig
98921 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98922 boot.
98923
98924 If you are unsure how to answer this question, answer 1.
98925 +
98926 +config SECURITY_APPARMOR_COMPAT_24
98927 + bool "Enable AppArmor 2.4 compatability"
98928 + depends on SECURITY_APPARMOR
98929 + default y
98930 + help
98931 + This option enables compatability with AppArmor 2.4. It is
98932 + recommended if compatability with older versions of AppArmor
98933 + is desired.
98934 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98935 index 16c15ec..42b7c9f 100644
98936 --- a/security/apparmor/apparmorfs.c
98937 +++ b/security/apparmor/apparmorfs.c
98938 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98939 .release = single_release,
98940 };
98941
98942 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98943 +/**
98944 + * __next_namespace - find the next namespace to list
98945 + * @root: root namespace to stop search at (NOT NULL)
98946 + * @ns: current ns position (NOT NULL)
98947 + *
98948 + * Find the next namespace from @ns under @root and handle all locking needed
98949 + * while switching current namespace.
98950 + *
98951 + * Returns: next namespace or NULL if at last namespace under @root
98952 + * NOTE: will not unlock root->lock
98953 + */
98954 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98955 + struct aa_namespace *ns)
98956 +{
98957 + struct aa_namespace *parent;
98958 +
98959 + /* is next namespace a child */
98960 + if (!list_empty(&ns->sub_ns)) {
98961 + struct aa_namespace *next;
98962 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98963 + read_lock(&next->lock);
98964 + return next;
98965 + }
98966 +
98967 + /* check if the next ns is a sibling, parent, gp, .. */
98968 + parent = ns->parent;
98969 + while (parent) {
98970 + read_unlock(&ns->lock);
98971 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98972 + read_lock(&ns->lock);
98973 + return ns;
98974 + }
98975 + if (parent == root)
98976 + return NULL;
98977 + ns = parent;
98978 + parent = parent->parent;
98979 + }
98980 +
98981 + return NULL;
98982 +}
98983 +
98984 +/**
98985 + * __first_profile - find the first profile in a namespace
98986 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98987 + * @ns: namespace to start in (NOT NULL)
98988 + *
98989 + * Returns: unrefcounted profile or NULL if no profile
98990 + */
98991 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98992 + struct aa_namespace *ns)
98993 +{
98994 + for ( ; ns; ns = __next_namespace(root, ns)) {
98995 + if (!list_empty(&ns->base.profiles))
98996 + return list_first_entry(&ns->base.profiles,
98997 + struct aa_profile, base.list);
98998 + }
98999 + return NULL;
99000 +}
99001 +
99002 +/**
99003 + * __next_profile - step to the next profile in a profile tree
99004 + * @profile: current profile in tree (NOT NULL)
99005 + *
99006 + * Perform a depth first taversal on the profile tree in a namespace
99007 + *
99008 + * Returns: next profile or NULL if done
99009 + * Requires: profile->ns.lock to be held
99010 + */
99011 +static struct aa_profile *__next_profile(struct aa_profile *p)
99012 +{
99013 + struct aa_profile *parent;
99014 + struct aa_namespace *ns = p->ns;
99015 +
99016 + /* is next profile a child */
99017 + if (!list_empty(&p->base.profiles))
99018 + return list_first_entry(&p->base.profiles, typeof(*p),
99019 + base.list);
99020 +
99021 + /* is next profile a sibling, parent sibling, gp, subling, .. */
99022 + parent = p->parent;
99023 + while (parent) {
99024 + list_for_each_entry_continue(p, &parent->base.profiles,
99025 + base.list)
99026 + return p;
99027 + p = parent;
99028 + parent = parent->parent;
99029 + }
99030 +
99031 + /* is next another profile in the namespace */
99032 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
99033 + return p;
99034 +
99035 + return NULL;
99036 +}
99037 +
99038 +/**
99039 + * next_profile - step to the next profile in where ever it may be
99040 + * @root: root namespace (NOT NULL)
99041 + * @profile: current profile (NOT NULL)
99042 + *
99043 + * Returns: next profile or NULL if there isn't one
99044 + */
99045 +static struct aa_profile *next_profile(struct aa_namespace *root,
99046 + struct aa_profile *profile)
99047 +{
99048 + struct aa_profile *next = __next_profile(profile);
99049 + if (next)
99050 + return next;
99051 +
99052 + /* finished all profiles in namespace move to next namespace */
99053 + return __first_profile(root, __next_namespace(root, profile->ns));
99054 +}
99055 +
99056 +/**
99057 + * p_start - start a depth first traversal of profile tree
99058 + * @f: seq_file to fill
99059 + * @pos: current position
99060 + *
99061 + * Returns: first profile under current namespace or NULL if none found
99062 + *
99063 + * acquires first ns->lock
99064 + */
99065 +static void *p_start(struct seq_file *f, loff_t *pos)
99066 + __acquires(root->lock)
99067 +{
99068 + struct aa_profile *profile = NULL;
99069 + struct aa_namespace *root = aa_current_profile()->ns;
99070 + loff_t l = *pos;
99071 + f->private = aa_get_namespace(root);
99072 +
99073 +
99074 + /* find the first profile */
99075 + read_lock(&root->lock);
99076 + profile = __first_profile(root, root);
99077 +
99078 + /* skip to position */
99079 + for (; profile && l > 0; l--)
99080 + profile = next_profile(root, profile);
99081 +
99082 + return profile;
99083 +}
99084 +
99085 +/**
99086 + * p_next - read the next profile entry
99087 + * @f: seq_file to fill
99088 + * @p: profile previously returned
99089 + * @pos: current position
99090 + *
99091 + * Returns: next profile after @p or NULL if none
99092 + *
99093 + * may acquire/release locks in namespace tree as necessary
99094 + */
99095 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
99096 +{
99097 + struct aa_profile *profile = p;
99098 + struct aa_namespace *root = f->private;
99099 + (*pos)++;
99100 +
99101 + return next_profile(root, profile);
99102 +}
99103 +
99104 +/**
99105 + * p_stop - stop depth first traversal
99106 + * @f: seq_file we are filling
99107 + * @p: the last profile writen
99108 + *
99109 + * Release all locking done by p_start/p_next on namespace tree
99110 + */
99111 +static void p_stop(struct seq_file *f, void *p)
99112 + __releases(root->lock)
99113 +{
99114 + struct aa_profile *profile = p;
99115 + struct aa_namespace *root = f->private, *ns;
99116 +
99117 + if (profile) {
99118 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
99119 + read_unlock(&ns->lock);
99120 + }
99121 + read_unlock(&root->lock);
99122 + aa_put_namespace(root);
99123 +}
99124 +
99125 +/**
99126 + * seq_show_profile - show a profile entry
99127 + * @f: seq_file to file
99128 + * @p: current position (profile) (NOT NULL)
99129 + *
99130 + * Returns: error on failure
99131 + */
99132 +static int seq_show_profile(struct seq_file *f, void *p)
99133 +{
99134 + struct aa_profile *profile = (struct aa_profile *)p;
99135 + struct aa_namespace *root = f->private;
99136 +
99137 + if (profile->ns != root)
99138 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
99139 + seq_printf(f, "%s (%s)\n", profile->base.hname,
99140 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
99141 +
99142 + return 0;
99143 +}
99144 +
99145 +static const struct seq_operations aa_fs_profiles_op = {
99146 + .start = p_start,
99147 + .next = p_next,
99148 + .stop = p_stop,
99149 + .show = seq_show_profile,
99150 +};
99151 +
99152 +static int profiles_open(struct inode *inode, struct file *file)
99153 +{
99154 + return seq_open(file, &aa_fs_profiles_op);
99155 +}
99156 +
99157 +static int profiles_release(struct inode *inode, struct file *file)
99158 +{
99159 + return seq_release(inode, file);
99160 +}
99161 +
99162 +const struct file_operations aa_fs_profiles_fops = {
99163 + .open = profiles_open,
99164 + .read = seq_read,
99165 + .llseek = seq_lseek,
99166 + .release = profiles_release,
99167 +};
99168 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
99169 +
99170 /** Base file system setup **/
99171
99172 static struct aa_fs_entry aa_fs_entry_file[] = {
99173 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
99174 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
99175 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
99176 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
99177 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
99178 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
99179 +#endif
99180 AA_FS_DIR("features", aa_fs_entry_features),
99181 { }
99182 };
99183 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
99184 index 2e2a0dd..a0cbc44 100644
99185 --- a/security/apparmor/lsm.c
99186 +++ b/security/apparmor/lsm.c
99187 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
99188 return error;
99189 }
99190
99191 -static struct security_operations apparmor_ops = {
99192 +static struct security_operations apparmor_ops __read_only = {
99193 .name = "apparmor",
99194
99195 .ptrace_access_check = apparmor_ptrace_access_check,
99196 diff --git a/security/commoncap.c b/security/commoncap.c
99197 index c44b6fe..932df30 100644
99198 --- a/security/commoncap.c
99199 +++ b/security/commoncap.c
99200 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
99201 return 0;
99202 }
99203
99204 +/* returns:
99205 + 1 for suid privilege
99206 + 2 for sgid privilege
99207 + 3 for fscap privilege
99208 +*/
99209 +int is_privileged_binary(const struct dentry *dentry)
99210 +{
99211 + struct cpu_vfs_cap_data capdata;
99212 + struct inode *inode = dentry->d_inode;
99213 +
99214 + if (!inode || S_ISDIR(inode->i_mode))
99215 + return 0;
99216 +
99217 + if (inode->i_mode & S_ISUID)
99218 + return 1;
99219 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
99220 + return 2;
99221 +
99222 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
99223 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
99224 + return 3;
99225 + }
99226 +
99227 + return 0;
99228 +}
99229 +
99230 /*
99231 * Attempt to get the on-exec apply capability sets for an executable file from
99232 * its xattrs and, if present, apply them to the proposed credentials being
99233 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
99234 const struct cred *cred = current_cred();
99235 kuid_t root_uid = make_kuid(cred->user_ns, 0);
99236
99237 + if (gr_acl_enable_at_secure())
99238 + return 1;
99239 +
99240 if (!uid_eq(cred->uid, root_uid)) {
99241 if (bprm->cap_effective)
99242 return 1;
99243 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
99244 index b3dd616..4bb17f3 100644
99245 --- a/security/integrity/ima/ima.h
99246 +++ b/security/integrity/ima/ima.h
99247 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
99248 extern spinlock_t ima_queue_lock;
99249
99250 struct ima_h_table {
99251 - atomic_long_t len; /* number of stored measurements in the list */
99252 - atomic_long_t violations;
99253 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
99254 + atomic_long_unchecked_t violations;
99255 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
99256 };
99257 extern struct ima_h_table ima_htable;
99258 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
99259 index 1c03e8f1..398a941 100644
99260 --- a/security/integrity/ima/ima_api.c
99261 +++ b/security/integrity/ima/ima_api.c
99262 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
99263 int result;
99264
99265 /* can overflow, only indicator */
99266 - atomic_long_inc(&ima_htable.violations);
99267 + atomic_long_inc_unchecked(&ima_htable.violations);
99268
99269 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
99270 if (!entry) {
99271 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
99272 index 38477c9..87a60c7 100644
99273 --- a/security/integrity/ima/ima_fs.c
99274 +++ b/security/integrity/ima/ima_fs.c
99275 @@ -28,12 +28,12 @@
99276 static int valid_policy = 1;
99277 #define TMPBUFLEN 12
99278 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
99279 - loff_t *ppos, atomic_long_t *val)
99280 + loff_t *ppos, atomic_long_unchecked_t *val)
99281 {
99282 char tmpbuf[TMPBUFLEN];
99283 ssize_t len;
99284
99285 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
99286 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
99287 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
99288 }
99289
99290 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
99291 index ff63fe0..809cd96 100644
99292 --- a/security/integrity/ima/ima_queue.c
99293 +++ b/security/integrity/ima/ima_queue.c
99294 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
99295 INIT_LIST_HEAD(&qe->later);
99296 list_add_tail_rcu(&qe->later, &ima_measurements);
99297
99298 - atomic_long_inc(&ima_htable.len);
99299 + atomic_long_inc_unchecked(&ima_htable.len);
99300 key = ima_hash_key(entry->digest);
99301 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
99302 return 0;
99303 diff --git a/security/keys/compat.c b/security/keys/compat.c
99304 index d65fa7f..cbfe366 100644
99305 --- a/security/keys/compat.c
99306 +++ b/security/keys/compat.c
99307 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
99308 if (ret == 0)
99309 goto no_payload_free;
99310
99311 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99312 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99313 err:
99314 if (iov != iovstack)
99315 kfree(iov);
99316 diff --git a/security/keys/internal.h b/security/keys/internal.h
99317 index d4f1468..cc52f92 100644
99318 --- a/security/keys/internal.h
99319 +++ b/security/keys/internal.h
99320 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99321 extern long keyctl_invalidate_key(key_serial_t);
99322
99323 extern long keyctl_instantiate_key_common(key_serial_t,
99324 - const struct iovec *,
99325 + const struct iovec __user *,
99326 unsigned, size_t, key_serial_t);
99327
99328 /*
99329 diff --git a/security/keys/key.c b/security/keys/key.c
99330 index 8fb7c7b..ba3610d 100644
99331 --- a/security/keys/key.c
99332 +++ b/security/keys/key.c
99333 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
99334
99335 atomic_set(&key->usage, 1);
99336 init_rwsem(&key->sem);
99337 - lockdep_set_class(&key->sem, &type->lock_class);
99338 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
99339 key->type = type;
99340 key->user = user;
99341 key->quotalen = quotalen;
99342 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
99343 struct key_type *p;
99344 int ret;
99345
99346 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
99347 + pax_open_kernel();
99348 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
99349 + pax_close_kernel();
99350
99351 ret = -EEXIST;
99352 down_write(&key_types_sem);
99353 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
99354 }
99355
99356 /* store the type */
99357 - list_add(&ktype->link, &key_types_list);
99358 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
99359
99360 pr_notice("Key type %s registered\n", ktype->name);
99361 ret = 0;
99362 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
99363 void unregister_key_type(struct key_type *ktype)
99364 {
99365 down_write(&key_types_sem);
99366 - list_del_init(&ktype->link);
99367 + pax_list_del_init((struct list_head *)&ktype->link);
99368 downgrade_write(&key_types_sem);
99369 key_gc_keytype(ktype);
99370 pr_notice("Key type %s unregistered\n", ktype->name);
99371 @@ -1084,10 +1086,10 @@ void __init key_init(void)
99372 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
99373
99374 /* add the special key types */
99375 - list_add_tail(&key_type_keyring.link, &key_types_list);
99376 - list_add_tail(&key_type_dead.link, &key_types_list);
99377 - list_add_tail(&key_type_user.link, &key_types_list);
99378 - list_add_tail(&key_type_logon.link, &key_types_list);
99379 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99380 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99381 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99382 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99383
99384 /* record the root user tracking */
99385 rb_link_node(&root_key_user.node,
99386 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99387 index 33cfd27..842fc5a 100644
99388 --- a/security/keys/keyctl.c
99389 +++ b/security/keys/keyctl.c
99390 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99391 /*
99392 * Copy the iovec data from userspace
99393 */
99394 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99395 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99396 unsigned ioc)
99397 {
99398 for (; ioc > 0; ioc--) {
99399 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99400 * If successful, 0 will be returned.
99401 */
99402 long keyctl_instantiate_key_common(key_serial_t id,
99403 - const struct iovec *payload_iov,
99404 + const struct iovec __user *payload_iov,
99405 unsigned ioc,
99406 size_t plen,
99407 key_serial_t ringid)
99408 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99409 [0].iov_len = plen
99410 };
99411
99412 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99413 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99414 }
99415
99416 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99417 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99418 if (ret == 0)
99419 goto no_payload_free;
99420
99421 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99422 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99423 err:
99424 if (iov != iovstack)
99425 kfree(iov);
99426 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99427 index 6ece7f2..ecdb55c 100644
99428 --- a/security/keys/keyring.c
99429 +++ b/security/keys/keyring.c
99430 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99431 ret = -EFAULT;
99432
99433 for (loop = 0; loop < klist->nkeys; loop++) {
99434 + key_serial_t serial;
99435 key = rcu_deref_link_locked(klist, loop,
99436 keyring);
99437 + serial = key->serial;
99438
99439 tmp = sizeof(key_serial_t);
99440 if (tmp > buflen)
99441 tmp = buflen;
99442
99443 - if (copy_to_user(buffer,
99444 - &key->serial,
99445 - tmp) != 0)
99446 + if (copy_to_user(buffer, &serial, tmp))
99447 goto error;
99448
99449 buflen -= tmp;
99450 diff --git a/security/min_addr.c b/security/min_addr.c
99451 index f728728..6457a0c 100644
99452 --- a/security/min_addr.c
99453 +++ b/security/min_addr.c
99454 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99455 */
99456 static void update_mmap_min_addr(void)
99457 {
99458 +#ifndef SPARC
99459 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99460 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99461 mmap_min_addr = dac_mmap_min_addr;
99462 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99463 #else
99464 mmap_min_addr = dac_mmap_min_addr;
99465 #endif
99466 +#endif
99467 }
99468
99469 /*
99470 diff --git a/security/security.c b/security/security.c
99471 index 94b35ae..f4e7751 100644
99472 --- a/security/security.c
99473 +++ b/security/security.c
99474 @@ -33,8 +33,8 @@
99475 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99476 CONFIG_DEFAULT_SECURITY;
99477
99478 -static struct security_operations *security_ops;
99479 -static struct security_operations default_security_ops = {
99480 +struct security_operations *security_ops __read_only;
99481 +struct security_operations default_security_ops __read_only = {
99482 .name = "default",
99483 };
99484
99485 @@ -73,11 +73,6 @@ int __init security_init(void)
99486 return 0;
99487 }
99488
99489 -void reset_security_ops(void)
99490 -{
99491 - security_ops = &default_security_ops;
99492 -}
99493 -
99494 /* Save user chosen LSM */
99495 static int __init choose_lsm(char *str)
99496 {
99497 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99498 index dad36a6..7e5ffbf 100644
99499 --- a/security/selinux/avc.c
99500 +++ b/security/selinux/avc.c
99501 @@ -59,7 +59,7 @@ struct avc_node {
99502 struct avc_cache {
99503 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99504 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99505 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99506 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99507 atomic_t active_nodes;
99508 u32 latest_notif; /* latest revocation notification */
99509 };
99510 @@ -167,7 +167,7 @@ void __init avc_init(void)
99511 spin_lock_init(&avc_cache.slots_lock[i]);
99512 }
99513 atomic_set(&avc_cache.active_nodes, 0);
99514 - atomic_set(&avc_cache.lru_hint, 0);
99515 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99516
99517 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99518 0, SLAB_PANIC, NULL);
99519 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99520 spinlock_t *lock;
99521
99522 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99523 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99524 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99525 head = &avc_cache.slots[hvalue];
99526 lock = &avc_cache.slots_lock[hvalue];
99527
99528 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99529 index c956390..1899f06 100644
99530 --- a/security/selinux/hooks.c
99531 +++ b/security/selinux/hooks.c
99532 @@ -97,8 +97,6 @@
99533
99534 #define NUM_SEL_MNT_OPTS 5
99535
99536 -extern struct security_operations *security_ops;
99537 -
99538 /* SECMARK reference count */
99539 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
99540
99541 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99542
99543 #endif
99544
99545 -static struct security_operations selinux_ops = {
99546 +static struct security_operations selinux_ops __read_only = {
99547 .name = "selinux",
99548
99549 .ptrace_access_check = selinux_ptrace_access_check,
99550 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
99551 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99552 static int selinux_disabled;
99553
99554 +extern struct security_operations *security_ops;
99555 +extern struct security_operations default_security_ops;
99556 +
99557 int selinux_disable(void)
99558 {
99559 if (ss_initialized) {
99560 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
99561 selinux_disabled = 1;
99562 selinux_enabled = 0;
99563
99564 - reset_security_ops();
99565 + pax_open_kernel();
99566 + security_ops = &default_security_ops;
99567 + pax_close_kernel();
99568
99569 /* Try to destroy the avc node cache */
99570 avc_disable();
99571 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99572 index 65f67cb..3f141ef 100644
99573 --- a/security/selinux/include/xfrm.h
99574 +++ b/security/selinux/include/xfrm.h
99575 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
99576
99577 static inline void selinux_xfrm_notify_policyload(void)
99578 {
99579 - atomic_inc(&flow_cache_genid);
99580 + atomic_inc_unchecked(&flow_cache_genid);
99581 rt_genid_bump(&init_net);
99582 }
99583 #else
99584 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99585 index eefbd10..9f10ddb 100644
99586 --- a/security/smack/smack_lsm.c
99587 +++ b/security/smack/smack_lsm.c
99588 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99589 return 0;
99590 }
99591
99592 -struct security_operations smack_ops = {
99593 +struct security_operations smack_ops __read_only = {
99594 .name = "smack",
99595
99596 .ptrace_access_check = smack_ptrace_access_check,
99597 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99598 index 390c646..f2f8db3 100644
99599 --- a/security/tomoyo/mount.c
99600 +++ b/security/tomoyo/mount.c
99601 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99602 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99603 need_dev = -1; /* dev_name is a directory */
99604 } else {
99605 + if (!capable(CAP_SYS_ADMIN)) {
99606 + error = -EPERM;
99607 + goto out;
99608 + }
99609 fstype = get_fs_type(type);
99610 if (!fstype) {
99611 error = -ENODEV;
99612 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99613 index f0b756e..b129202 100644
99614 --- a/security/tomoyo/tomoyo.c
99615 +++ b/security/tomoyo/tomoyo.c
99616 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99617 * tomoyo_security_ops is a "struct security_operations" which is used for
99618 * registering TOMOYO.
99619 */
99620 -static struct security_operations tomoyo_security_ops = {
99621 +static struct security_operations tomoyo_security_ops __read_only = {
99622 .name = "tomoyo",
99623 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99624 .cred_prepare = tomoyo_cred_prepare,
99625 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99626 index 20ef514..4182bed 100644
99627 --- a/security/yama/Kconfig
99628 +++ b/security/yama/Kconfig
99629 @@ -1,6 +1,6 @@
99630 config SECURITY_YAMA
99631 bool "Yama support"
99632 - depends on SECURITY
99633 + depends on SECURITY && !GRKERNSEC
99634 select SECURITYFS
99635 select SECURITY_PATH
99636 default n
99637 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99638 index 13c88fbc..f8c115e 100644
99639 --- a/security/yama/yama_lsm.c
99640 +++ b/security/yama/yama_lsm.c
99641 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99642 }
99643
99644 #ifndef CONFIG_SECURITY_YAMA_STACKED
99645 -static struct security_operations yama_ops = {
99646 +static struct security_operations yama_ops __read_only = {
99647 .name = "yama",
99648
99649 .ptrace_access_check = yama_ptrace_access_check,
99650 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99651 #endif
99652
99653 #ifdef CONFIG_SYSCTL
99654 +static int zero __read_only;
99655 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99656 +
99657 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99658 void __user *buffer, size_t *lenp, loff_t *ppos)
99659 {
99660 - int rc;
99661 + ctl_table_no_const yama_table;
99662
99663 if (write && !capable(CAP_SYS_PTRACE))
99664 return -EPERM;
99665
99666 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99667 - if (rc)
99668 - return rc;
99669 -
99670 + yama_table = *table;
99671 /* Lock the max value if it ever gets set. */
99672 - if (write && *(int *)table->data == *(int *)table->extra2)
99673 - table->extra1 = table->extra2;
99674 -
99675 - return rc;
99676 + if (ptrace_scope == max_scope)
99677 + yama_table.extra1 = &max_scope;
99678 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99679 }
99680
99681 -static int zero;
99682 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99683 -
99684 struct ctl_path yama_sysctl_path[] = {
99685 { .procname = "kernel", },
99686 { .procname = "yama", },
99687 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99688 index 4cedc69..e59d8a3 100644
99689 --- a/sound/aoa/codecs/onyx.c
99690 +++ b/sound/aoa/codecs/onyx.c
99691 @@ -54,7 +54,7 @@ struct onyx {
99692 spdif_locked:1,
99693 analog_locked:1,
99694 original_mute:2;
99695 - int open_count;
99696 + local_t open_count;
99697 struct codec_info *codec_info;
99698
99699 /* mutex serializes concurrent access to the device
99700 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99701 struct onyx *onyx = cii->codec_data;
99702
99703 mutex_lock(&onyx->mutex);
99704 - onyx->open_count++;
99705 + local_inc(&onyx->open_count);
99706 mutex_unlock(&onyx->mutex);
99707
99708 return 0;
99709 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99710 struct onyx *onyx = cii->codec_data;
99711
99712 mutex_lock(&onyx->mutex);
99713 - onyx->open_count--;
99714 - if (!onyx->open_count)
99715 + if (local_dec_and_test(&onyx->open_count))
99716 onyx->spdif_locked = onyx->analog_locked = 0;
99717 mutex_unlock(&onyx->mutex);
99718
99719 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99720 index ffd2025..df062c9 100644
99721 --- a/sound/aoa/codecs/onyx.h
99722 +++ b/sound/aoa/codecs/onyx.h
99723 @@ -11,6 +11,7 @@
99724 #include <linux/i2c.h>
99725 #include <asm/pmac_low_i2c.h>
99726 #include <asm/prom.h>
99727 +#include <asm/local.h>
99728
99729 /* PCM3052 register definitions */
99730
99731 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99732 index 4c1cc51..16040040 100644
99733 --- a/sound/core/oss/pcm_oss.c
99734 +++ b/sound/core/oss/pcm_oss.c
99735 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99736 if (in_kernel) {
99737 mm_segment_t fs;
99738 fs = snd_enter_user();
99739 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99740 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99741 snd_leave_user(fs);
99742 } else {
99743 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99744 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99745 }
99746 if (ret != -EPIPE && ret != -ESTRPIPE)
99747 break;
99748 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99749 if (in_kernel) {
99750 mm_segment_t fs;
99751 fs = snd_enter_user();
99752 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99753 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99754 snd_leave_user(fs);
99755 } else {
99756 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99757 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99758 }
99759 if (ret == -EPIPE) {
99760 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99761 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99762 struct snd_pcm_plugin_channel *channels;
99763 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99764 if (!in_kernel) {
99765 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99766 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99767 return -EFAULT;
99768 buf = runtime->oss.buffer;
99769 }
99770 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99771 }
99772 } else {
99773 tmp = snd_pcm_oss_write2(substream,
99774 - (const char __force *)buf,
99775 + (const char __force_kernel *)buf,
99776 runtime->oss.period_bytes, 0);
99777 if (tmp <= 0)
99778 goto err;
99779 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99780 struct snd_pcm_runtime *runtime = substream->runtime;
99781 snd_pcm_sframes_t frames, frames1;
99782 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99783 - char __user *final_dst = (char __force __user *)buf;
99784 + char __user *final_dst = (char __force_user *)buf;
99785 if (runtime->oss.plugin_first) {
99786 struct snd_pcm_plugin_channel *channels;
99787 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99788 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99789 xfer += tmp;
99790 runtime->oss.buffer_used -= tmp;
99791 } else {
99792 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99793 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99794 runtime->oss.period_bytes, 0);
99795 if (tmp <= 0)
99796 goto err;
99797 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99798 size1);
99799 size1 /= runtime->channels; /* frames */
99800 fs = snd_enter_user();
99801 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99802 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99803 snd_leave_user(fs);
99804 }
99805 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99806 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99807 index af49721..e85058e 100644
99808 --- a/sound/core/pcm_compat.c
99809 +++ b/sound/core/pcm_compat.c
99810 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99811 int err;
99812
99813 fs = snd_enter_user();
99814 - err = snd_pcm_delay(substream, &delay);
99815 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99816 snd_leave_user(fs);
99817 if (err < 0)
99818 return err;
99819 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99820 index a68d4c6..72af3cf 100644
99821 --- a/sound/core/pcm_native.c
99822 +++ b/sound/core/pcm_native.c
99823 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99824 switch (substream->stream) {
99825 case SNDRV_PCM_STREAM_PLAYBACK:
99826 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99827 - (void __user *)arg);
99828 + (void __force_user *)arg);
99829 break;
99830 case SNDRV_PCM_STREAM_CAPTURE:
99831 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99832 - (void __user *)arg);
99833 + (void __force_user *)arg);
99834 break;
99835 default:
99836 result = -EINVAL;
99837 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99838 index 040c60e..989a19a 100644
99839 --- a/sound/core/seq/seq_device.c
99840 +++ b/sound/core/seq/seq_device.c
99841 @@ -64,7 +64,7 @@ struct ops_list {
99842 int argsize; /* argument size */
99843
99844 /* operators */
99845 - struct snd_seq_dev_ops ops;
99846 + struct snd_seq_dev_ops *ops;
99847
99848 /* registered devices */
99849 struct list_head dev_list; /* list of devices */
99850 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99851
99852 mutex_lock(&ops->reg_mutex);
99853 /* copy driver operators */
99854 - ops->ops = *entry;
99855 + ops->ops = entry;
99856 ops->driver |= DRIVER_LOADED;
99857 ops->argsize = argsize;
99858
99859 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99860 dev->name, ops->id, ops->argsize, dev->argsize);
99861 return -EINVAL;
99862 }
99863 - if (ops->ops.init_device(dev) >= 0) {
99864 + if (ops->ops->init_device(dev) >= 0) {
99865 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99866 ops->num_init_devices++;
99867 } else {
99868 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99869 dev->name, ops->id, ops->argsize, dev->argsize);
99870 return -EINVAL;
99871 }
99872 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99873 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99874 dev->status = SNDRV_SEQ_DEVICE_FREE;
99875 dev->driver_data = NULL;
99876 ops->num_init_devices--;
99877 diff --git a/sound/core/sound.c b/sound/core/sound.c
99878 index f002bd9..c462985 100644
99879 --- a/sound/core/sound.c
99880 +++ b/sound/core/sound.c
99881 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99882 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99883 default: return;
99884 }
99885 - request_module(str);
99886 + request_module("%s", str);
99887 }
99888
99889 #endif /* modular kernel */
99890 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99891 index 4e0dd22..7a1f32c 100644
99892 --- a/sound/drivers/mts64.c
99893 +++ b/sound/drivers/mts64.c
99894 @@ -29,6 +29,7 @@
99895 #include <sound/initval.h>
99896 #include <sound/rawmidi.h>
99897 #include <sound/control.h>
99898 +#include <asm/local.h>
99899
99900 #define CARD_NAME "Miditerminal 4140"
99901 #define DRIVER_NAME "MTS64"
99902 @@ -67,7 +68,7 @@ struct mts64 {
99903 struct pardevice *pardev;
99904 int pardev_claimed;
99905
99906 - int open_count;
99907 + local_t open_count;
99908 int current_midi_output_port;
99909 int current_midi_input_port;
99910 u8 mode[MTS64_NUM_INPUT_PORTS];
99911 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99912 {
99913 struct mts64 *mts = substream->rmidi->private_data;
99914
99915 - if (mts->open_count == 0) {
99916 + if (local_read(&mts->open_count) == 0) {
99917 /* We don't need a spinlock here, because this is just called
99918 if the device has not been opened before.
99919 So there aren't any IRQs from the device */
99920 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99921
99922 msleep(50);
99923 }
99924 - ++(mts->open_count);
99925 + local_inc(&mts->open_count);
99926
99927 return 0;
99928 }
99929 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99930 struct mts64 *mts = substream->rmidi->private_data;
99931 unsigned long flags;
99932
99933 - --(mts->open_count);
99934 - if (mts->open_count == 0) {
99935 + if (local_dec_return(&mts->open_count) == 0) {
99936 /* We need the spinlock_irqsave here because we can still
99937 have IRQs at this point */
99938 spin_lock_irqsave(&mts->lock, flags);
99939 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99940
99941 msleep(500);
99942
99943 - } else if (mts->open_count < 0)
99944 - mts->open_count = 0;
99945 + } else if (local_read(&mts->open_count) < 0)
99946 + local_set(&mts->open_count, 0);
99947
99948 return 0;
99949 }
99950 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99951 index b953fb4..1999c01 100644
99952 --- a/sound/drivers/opl4/opl4_lib.c
99953 +++ b/sound/drivers/opl4/opl4_lib.c
99954 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99955 MODULE_DESCRIPTION("OPL4 driver");
99956 MODULE_LICENSE("GPL");
99957
99958 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99959 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99960 {
99961 int timeout = 10;
99962 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99963 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99964 index 991018d..8984740 100644
99965 --- a/sound/drivers/portman2x4.c
99966 +++ b/sound/drivers/portman2x4.c
99967 @@ -48,6 +48,7 @@
99968 #include <sound/initval.h>
99969 #include <sound/rawmidi.h>
99970 #include <sound/control.h>
99971 +#include <asm/local.h>
99972
99973 #define CARD_NAME "Portman 2x4"
99974 #define DRIVER_NAME "portman"
99975 @@ -85,7 +86,7 @@ struct portman {
99976 struct pardevice *pardev;
99977 int pardev_claimed;
99978
99979 - int open_count;
99980 + local_t open_count;
99981 int mode[PORTMAN_NUM_INPUT_PORTS];
99982 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99983 };
99984 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99985 index ea995af..f1bfa37 100644
99986 --- a/sound/firewire/amdtp.c
99987 +++ b/sound/firewire/amdtp.c
99988 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99989 ptr = s->pcm_buffer_pointer + data_blocks;
99990 if (ptr >= pcm->runtime->buffer_size)
99991 ptr -= pcm->runtime->buffer_size;
99992 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99993 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99994
99995 s->pcm_period_pointer += data_blocks;
99996 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99997 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99998 */
99999 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100000 {
100001 - ACCESS_ONCE(s->source_node_id_field) =
100002 + ACCESS_ONCE_RW(s->source_node_id_field) =
100003 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100004 }
100005 EXPORT_SYMBOL(amdtp_out_stream_update);
100006 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100007 index f6103d6..4843fbf 100644
100008 --- a/sound/firewire/amdtp.h
100009 +++ b/sound/firewire/amdtp.h
100010 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100011 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100012 struct snd_pcm_substream *pcm)
100013 {
100014 - ACCESS_ONCE(s->pcm) = pcm;
100015 + ACCESS_ONCE_RW(s->pcm) = pcm;
100016 }
100017
100018 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
100019 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
100020 index 58a5afe..af5bd64 100644
100021 --- a/sound/firewire/isight.c
100022 +++ b/sound/firewire/isight.c
100023 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
100024 ptr += count;
100025 if (ptr >= runtime->buffer_size)
100026 ptr -= runtime->buffer_size;
100027 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
100028 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
100029
100030 isight->period_counter += count;
100031 if (isight->period_counter >= runtime->period_size) {
100032 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
100033 if (err < 0)
100034 return err;
100035
100036 - ACCESS_ONCE(isight->pcm_active) = true;
100037 + ACCESS_ONCE_RW(isight->pcm_active) = true;
100038
100039 return 0;
100040 }
100041 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
100042 {
100043 struct isight *isight = substream->private_data;
100044
100045 - ACCESS_ONCE(isight->pcm_active) = false;
100046 + ACCESS_ONCE_RW(isight->pcm_active) = false;
100047
100048 mutex_lock(&isight->mutex);
100049 isight_stop_streaming(isight);
100050 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
100051
100052 switch (cmd) {
100053 case SNDRV_PCM_TRIGGER_START:
100054 - ACCESS_ONCE(isight->pcm_running) = true;
100055 + ACCESS_ONCE_RW(isight->pcm_running) = true;
100056 break;
100057 case SNDRV_PCM_TRIGGER_STOP:
100058 - ACCESS_ONCE(isight->pcm_running) = false;
100059 + ACCESS_ONCE_RW(isight->pcm_running) = false;
100060 break;
100061 default:
100062 return -EINVAL;
100063 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
100064 index 505fc81..62e569e 100644
100065 --- a/sound/firewire/scs1x.c
100066 +++ b/sound/firewire/scs1x.c
100067 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
100068 {
100069 struct scs *scs = stream->rmidi->private_data;
100070
100071 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
100072 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
100073 if (up) {
100074 scs->output_idle = false;
100075 tasklet_schedule(&scs->tasklet);
100076 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
100077 {
100078 struct scs *scs = stream->rmidi->private_data;
100079
100080 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
100081 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
100082 }
100083
100084 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
100085 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
100086
100087 snd_card_disconnect(scs->card);
100088
100089 - ACCESS_ONCE(scs->output) = NULL;
100090 - ACCESS_ONCE(scs->input) = NULL;
100091 + ACCESS_ONCE_RW(scs->output) = NULL;
100092 + ACCESS_ONCE_RW(scs->input) = NULL;
100093
100094 wait_event(scs->idle_wait, scs->output_idle);
100095
100096 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
100097 index 048439a..3be9f6f 100644
100098 --- a/sound/oss/sb_audio.c
100099 +++ b/sound/oss/sb_audio.c
100100 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
100101 buf16 = (signed short *)(localbuf + localoffs);
100102 while (c)
100103 {
100104 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100105 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100106 if (copy_from_user(lbuf8,
100107 userbuf+useroffs + p,
100108 locallen))
100109 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
100110 index 7d8803a..559f8d0 100644
100111 --- a/sound/oss/swarm_cs4297a.c
100112 +++ b/sound/oss/swarm_cs4297a.c
100113 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
100114 {
100115 struct cs4297a_state *s;
100116 u32 pwr, id;
100117 - mm_segment_t fs;
100118 int rval;
100119 #ifndef CONFIG_BCM_CS4297A_CSWARM
100120 u64 cfg;
100121 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
100122 if (!rval) {
100123 char *sb1250_duart_present;
100124
100125 +#if 0
100126 + mm_segment_t fs;
100127 fs = get_fs();
100128 set_fs(KERNEL_DS);
100129 -#if 0
100130 val = SOUND_MASK_LINE;
100131 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
100132 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
100133 val = initvol[i].vol;
100134 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
100135 }
100136 + set_fs(fs);
100137 // cs4297a_write_ac97(s, 0x18, 0x0808);
100138 #else
100139 // cs4297a_write_ac97(s, 0x5e, 0x180);
100140 cs4297a_write_ac97(s, 0x02, 0x0808);
100141 cs4297a_write_ac97(s, 0x18, 0x0808);
100142 #endif
100143 - set_fs(fs);
100144
100145 list_add(&s->list, &cs4297a_devs);
100146
100147 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
100148 index 7c9e7dc..3b2bd95 100644
100149 --- a/sound/pci/hda/hda_codec.c
100150 +++ b/sound/pci/hda/hda_codec.c
100151 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
100152 mutex_unlock(&preset_mutex);
100153
100154 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
100155 - char name[32];
100156 if (!mod_requested)
100157 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
100158 - codec->vendor_id);
100159 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
100160 else
100161 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
100162 - (codec->vendor_id >> 16) & 0xffff);
100163 - request_module(name);
100164 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
100165 mod_requested++;
100166 goto again;
100167 }
100168 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
100169 index 4631a23..001ae57 100644
100170 --- a/sound/pci/ymfpci/ymfpci.h
100171 +++ b/sound/pci/ymfpci/ymfpci.h
100172 @@ -358,7 +358,7 @@ struct snd_ymfpci {
100173 spinlock_t reg_lock;
100174 spinlock_t voice_lock;
100175 wait_queue_head_t interrupt_sleep;
100176 - atomic_t interrupt_sleep_count;
100177 + atomic_unchecked_t interrupt_sleep_count;
100178 struct snd_info_entry *proc_entry;
100179 const struct firmware *dsp_microcode;
100180 const struct firmware *controller_microcode;
100181 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
100182 index d591c15..8cb8f94 100644
100183 --- a/sound/pci/ymfpci/ymfpci_main.c
100184 +++ b/sound/pci/ymfpci/ymfpci_main.c
100185 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
100186 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
100187 break;
100188 }
100189 - if (atomic_read(&chip->interrupt_sleep_count)) {
100190 - atomic_set(&chip->interrupt_sleep_count, 0);
100191 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100192 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100193 wake_up(&chip->interrupt_sleep);
100194 }
100195 __end:
100196 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
100197 continue;
100198 init_waitqueue_entry(&wait, current);
100199 add_wait_queue(&chip->interrupt_sleep, &wait);
100200 - atomic_inc(&chip->interrupt_sleep_count);
100201 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
100202 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
100203 remove_wait_queue(&chip->interrupt_sleep, &wait);
100204 }
100205 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
100206 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
100207 spin_unlock(&chip->reg_lock);
100208
100209 - if (atomic_read(&chip->interrupt_sleep_count)) {
100210 - atomic_set(&chip->interrupt_sleep_count, 0);
100211 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100212 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100213 wake_up(&chip->interrupt_sleep);
100214 }
100215 }
100216 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
100217 spin_lock_init(&chip->reg_lock);
100218 spin_lock_init(&chip->voice_lock);
100219 init_waitqueue_head(&chip->interrupt_sleep);
100220 - atomic_set(&chip->interrupt_sleep_count, 0);
100221 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100222 chip->card = card;
100223 chip->pci = pci;
100224 chip->irq = -1;
100225 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
100226 index 2f2d837..3e3f1f6 100644
100227 --- a/sound/soc/fsl/fsl_ssi.c
100228 +++ b/sound/soc/fsl/fsl_ssi.c
100229 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
100230 {
100231 struct fsl_ssi_private *ssi_private;
100232 int ret = 0;
100233 - struct device_attribute *dev_attr = NULL;
100234 + device_attribute_no_const *dev_attr = NULL;
100235 struct device_node *np = pdev->dev.of_node;
100236 const char *p, *sprop;
100237 const uint32_t *iprop;
100238 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
100239 new file mode 100644
100240 index 0000000..50f2f2f
100241 --- /dev/null
100242 +++ b/tools/gcc/.gitignore
100243 @@ -0,0 +1 @@
100244 +size_overflow_hash.h
100245 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
100246 new file mode 100644
100247 index 0000000..144dbee
100248 --- /dev/null
100249 +++ b/tools/gcc/Makefile
100250 @@ -0,0 +1,45 @@
100251 +#CC := gcc
100252 +#PLUGIN_SOURCE_FILES := pax_plugin.c
100253 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
100254 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
100255 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
100256 +
100257 +ifeq ($(PLUGINCC),$(HOSTCC))
100258 +HOSTLIBS := hostlibs
100259 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
100260 +else
100261 +HOSTLIBS := hostcxxlibs
100262 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
100263 +endif
100264 +
100265 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
100266 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
100267 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
100268 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
100269 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
100270 +$(HOSTLIBS)-y += colorize_plugin.so
100271 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
100272 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
100273 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
100274 +
100275 +always := $($(HOSTLIBS)-y)
100276 +
100277 +constify_plugin-objs := constify_plugin.o
100278 +stackleak_plugin-objs := stackleak_plugin.o
100279 +kallocstat_plugin-objs := kallocstat_plugin.o
100280 +kernexec_plugin-objs := kernexec_plugin.o
100281 +checker_plugin-objs := checker_plugin.o
100282 +colorize_plugin-objs := colorize_plugin.o
100283 +size_overflow_plugin-objs := size_overflow_plugin.o
100284 +latent_entropy_plugin-objs := latent_entropy_plugin.o
100285 +structleak_plugin-objs := structleak_plugin.o
100286 +
100287 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
100288 +
100289 +quiet_cmd_build_size_overflow_hash = GENHASH $@
100290 + cmd_build_size_overflow_hash = \
100291 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
100292 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
100293 + $(call if_changed,build_size_overflow_hash)
100294 +
100295 +targets += size_overflow_hash.h
100296 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
100297 new file mode 100644
100298 index 0000000..22f03c0
100299 --- /dev/null
100300 +++ b/tools/gcc/checker_plugin.c
100301 @@ -0,0 +1,172 @@
100302 +/*
100303 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
100304 + * Licensed under the GPL v2
100305 + *
100306 + * Note: the choice of the license means that the compilation process is
100307 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100308 + * but for the kernel it doesn't matter since it doesn't link against
100309 + * any of the gcc libraries
100310 + *
100311 + * gcc plugin to implement various sparse (source code checker) features
100312 + *
100313 + * TODO:
100314 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100315 + *
100316 + * BUGS:
100317 + * - none known
100318 + */
100319 +#include "gcc-plugin.h"
100320 +#include "config.h"
100321 +#include "system.h"
100322 +#include "coretypes.h"
100323 +#include "tree.h"
100324 +#include "tree-pass.h"
100325 +#include "flags.h"
100326 +#include "intl.h"
100327 +#include "toplev.h"
100328 +#include "plugin.h"
100329 +//#include "expr.h" where are you...
100330 +#include "diagnostic.h"
100331 +#include "plugin-version.h"
100332 +#include "tm.h"
100333 +#include "function.h"
100334 +#include "basic-block.h"
100335 +#include "gimple.h"
100336 +#include "rtl.h"
100337 +#include "emit-rtl.h"
100338 +#include "tree-flow.h"
100339 +#include "target.h"
100340 +
100341 +extern void c_register_addr_space (const char *str, addr_space_t as);
100342 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
100343 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
100344 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
100345 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
100346 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
100347 +
100348 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100349 +extern rtx emit_move_insn(rtx x, rtx y);
100350 +
100351 +int plugin_is_GPL_compatible;
100352 +
100353 +static struct plugin_info checker_plugin_info = {
100354 + .version = "201111150100",
100355 + .help = NULL,
100356 +};
100357 +
100358 +#define ADDR_SPACE_KERNEL 0
100359 +#define ADDR_SPACE_FORCE_KERNEL 1
100360 +#define ADDR_SPACE_USER 2
100361 +#define ADDR_SPACE_FORCE_USER 3
100362 +#define ADDR_SPACE_IOMEM 0
100363 +#define ADDR_SPACE_FORCE_IOMEM 0
100364 +#define ADDR_SPACE_PERCPU 0
100365 +#define ADDR_SPACE_FORCE_PERCPU 0
100366 +#define ADDR_SPACE_RCU 0
100367 +#define ADDR_SPACE_FORCE_RCU 0
100368 +
100369 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
100370 +{
100371 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
100372 +}
100373 +
100374 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100375 +{
100376 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100377 +}
100378 +
100379 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100380 +{
100381 + return default_addr_space_valid_pointer_mode(mode, as);
100382 +}
100383 +
100384 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100385 +{
100386 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100387 +}
100388 +
100389 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100390 +{
100391 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100392 +}
100393 +
100394 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100395 +{
100396 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100397 + return true;
100398 +
100399 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100400 + return true;
100401 +
100402 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100403 + return true;
100404 +
100405 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100406 + return true;
100407 +
100408 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100409 + return true;
100410 +
100411 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100412 + return true;
100413 +
100414 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100415 + return true;
100416 +
100417 + return subset == superset;
100418 +}
100419 +
100420 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100421 +{
100422 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100423 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100424 +
100425 + return op;
100426 +}
100427 +
100428 +static void register_checker_address_spaces(void *event_data, void *data)
100429 +{
100430 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100431 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100432 + c_register_addr_space("__user", ADDR_SPACE_USER);
100433 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100434 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100435 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100436 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100437 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100438 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100439 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100440 +
100441 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100442 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100443 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100444 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100445 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100446 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100447 + targetm.addr_space.convert = checker_addr_space_convert;
100448 +}
100449 +
100450 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100451 +{
100452 + const char * const plugin_name = plugin_info->base_name;
100453 + const int argc = plugin_info->argc;
100454 + const struct plugin_argument * const argv = plugin_info->argv;
100455 + int i;
100456 +
100457 + if (!plugin_default_version_check(version, &gcc_version)) {
100458 + error(G_("incompatible gcc/plugin versions"));
100459 + return 1;
100460 + }
100461 +
100462 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100463 +
100464 + for (i = 0; i < argc; ++i)
100465 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100466 +
100467 + if (TARGET_64BIT == 0)
100468 + return 0;
100469 +
100470 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100471 +
100472 + return 0;
100473 +}
100474 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100475 new file mode 100644
100476 index 0000000..414fe5e
100477 --- /dev/null
100478 +++ b/tools/gcc/colorize_plugin.c
100479 @@ -0,0 +1,151 @@
100480 +/*
100481 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100482 + * Licensed under the GPL v2
100483 + *
100484 + * Note: the choice of the license means that the compilation process is
100485 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100486 + * but for the kernel it doesn't matter since it doesn't link against
100487 + * any of the gcc libraries
100488 + *
100489 + * gcc plugin to colorize diagnostic output
100490 + *
100491 + */
100492 +
100493 +#include "gcc-plugin.h"
100494 +#include "config.h"
100495 +#include "system.h"
100496 +#include "coretypes.h"
100497 +#include "tree.h"
100498 +#include "tree-pass.h"
100499 +#include "flags.h"
100500 +#include "intl.h"
100501 +#include "toplev.h"
100502 +#include "plugin.h"
100503 +#include "diagnostic.h"
100504 +#include "plugin-version.h"
100505 +#include "tm.h"
100506 +
100507 +int plugin_is_GPL_compatible;
100508 +
100509 +static struct plugin_info colorize_plugin_info = {
100510 + .version = "201302112000",
100511 + .help = NULL,
100512 +};
100513 +
100514 +#define GREEN "\033[32m\033[2m"
100515 +#define LIGHTGREEN "\033[32m\033[1m"
100516 +#define YELLOW "\033[33m\033[2m"
100517 +#define LIGHTYELLOW "\033[33m\033[1m"
100518 +#define RED "\033[31m\033[2m"
100519 +#define LIGHTRED "\033[31m\033[1m"
100520 +#define BLUE "\033[34m\033[2m"
100521 +#define LIGHTBLUE "\033[34m\033[1m"
100522 +#define BRIGHT "\033[m\033[1m"
100523 +#define NORMAL "\033[m"
100524 +
100525 +static diagnostic_starter_fn old_starter;
100526 +static diagnostic_finalizer_fn old_finalizer;
100527 +
100528 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100529 +{
100530 + const char *color;
100531 + char *newprefix;
100532 +
100533 + switch (diagnostic->kind) {
100534 + case DK_NOTE:
100535 + color = LIGHTBLUE;
100536 + break;
100537 +
100538 + case DK_PEDWARN:
100539 + case DK_WARNING:
100540 + color = LIGHTYELLOW;
100541 + break;
100542 +
100543 + case DK_ERROR:
100544 + case DK_FATAL:
100545 + case DK_ICE:
100546 + case DK_PERMERROR:
100547 + case DK_SORRY:
100548 + color = LIGHTRED;
100549 + break;
100550 +
100551 + default:
100552 + color = NORMAL;
100553 + }
100554 +
100555 + old_starter(context, diagnostic);
100556 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100557 + return;
100558 + pp_destroy_prefix(context->printer);
100559 + pp_set_prefix(context->printer, newprefix);
100560 +}
100561 +
100562 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100563 +{
100564 + old_finalizer(context, diagnostic);
100565 +}
100566 +
100567 +static void colorize_arm(void)
100568 +{
100569 + old_starter = diagnostic_starter(global_dc);
100570 + old_finalizer = diagnostic_finalizer(global_dc);
100571 +
100572 + diagnostic_starter(global_dc) = start_colorize;
100573 + diagnostic_finalizer(global_dc) = finalize_colorize;
100574 +}
100575 +
100576 +static unsigned int execute_colorize_rearm(void)
100577 +{
100578 + if (diagnostic_starter(global_dc) == start_colorize)
100579 + return 0;
100580 +
100581 + colorize_arm();
100582 + return 0;
100583 +}
100584 +
100585 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100586 + .pass = {
100587 + .type = SIMPLE_IPA_PASS,
100588 + .name = "colorize_rearm",
100589 +#if BUILDING_GCC_VERSION >= 4008
100590 + .optinfo_flags = OPTGROUP_NONE,
100591 +#endif
100592 + .gate = NULL,
100593 + .execute = execute_colorize_rearm,
100594 + .sub = NULL,
100595 + .next = NULL,
100596 + .static_pass_number = 0,
100597 + .tv_id = TV_NONE,
100598 + .properties_required = 0,
100599 + .properties_provided = 0,
100600 + .properties_destroyed = 0,
100601 + .todo_flags_start = 0,
100602 + .todo_flags_finish = 0
100603 + }
100604 +};
100605 +
100606 +static void colorize_start_unit(void *gcc_data, void *user_data)
100607 +{
100608 + colorize_arm();
100609 +}
100610 +
100611 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100612 +{
100613 + const char * const plugin_name = plugin_info->base_name;
100614 + struct register_pass_info colorize_rearm_pass_info = {
100615 + .pass = &pass_ipa_colorize_rearm.pass,
100616 + .reference_pass_name = "*free_lang_data",
100617 + .ref_pass_instance_number = 1,
100618 + .pos_op = PASS_POS_INSERT_AFTER
100619 + };
100620 +
100621 + if (!plugin_default_version_check(version, &gcc_version)) {
100622 + error(G_("incompatible gcc/plugin versions"));
100623 + return 1;
100624 + }
100625 +
100626 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100627 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100628 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100629 + return 0;
100630 +}
100631 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100632 new file mode 100644
100633 index 0000000..c17312d
100634 --- /dev/null
100635 +++ b/tools/gcc/constify_plugin.c
100636 @@ -0,0 +1,560 @@
100637 +/*
100638 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100639 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100640 + * Licensed under the GPL v2, or (at your option) v3
100641 + *
100642 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100643 + *
100644 + * Homepage:
100645 + * http://www.grsecurity.net/~ephox/const_plugin/
100646 + *
100647 + * Usage:
100648 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100649 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100650 + */
100651 +
100652 +#include "gcc-plugin.h"
100653 +#include "config.h"
100654 +#include "system.h"
100655 +#include "coretypes.h"
100656 +#include "tree.h"
100657 +#include "tree-pass.h"
100658 +#include "flags.h"
100659 +#include "intl.h"
100660 +#include "toplev.h"
100661 +#include "plugin.h"
100662 +#include "diagnostic.h"
100663 +#include "plugin-version.h"
100664 +#include "tm.h"
100665 +#include "function.h"
100666 +#include "basic-block.h"
100667 +#include "gimple.h"
100668 +#include "rtl.h"
100669 +#include "emit-rtl.h"
100670 +#include "tree-flow.h"
100671 +#include "target.h"
100672 +#include "langhooks.h"
100673 +
100674 +// should come from c-tree.h if only it were installed for gcc 4.5...
100675 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100676 +
100677 +// unused type flag in all versions 4.5-4.8
100678 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100679 +
100680 +int plugin_is_GPL_compatible;
100681 +
100682 +static struct plugin_info const_plugin_info = {
100683 + .version = "201305231310",
100684 + .help = "no-constify\tturn off constification\n",
100685 +};
100686 +
100687 +typedef struct {
100688 + bool has_fptr_field;
100689 + bool has_writable_field;
100690 + bool has_do_const_field;
100691 + bool has_no_const_field;
100692 +} constify_info;
100693 +
100694 +static const_tree get_field_type(const_tree field)
100695 +{
100696 + return strip_array_types(TREE_TYPE(field));
100697 +}
100698 +
100699 +static bool is_fptr(const_tree field)
100700 +{
100701 + const_tree ptr = get_field_type(field);
100702 +
100703 + if (TREE_CODE(ptr) != POINTER_TYPE)
100704 + return false;
100705 +
100706 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100707 +}
100708 +
100709 +/*
100710 + * determine whether the given structure type meets the requirements for automatic constification,
100711 + * including the constification attributes on nested structure types
100712 + */
100713 +static void constifiable(const_tree node, constify_info *cinfo)
100714 +{
100715 + const_tree field;
100716 +
100717 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100718 +
100719 + // e.g., pointer to structure fields while still constructing the structure type
100720 + if (TYPE_FIELDS(node) == NULL_TREE)
100721 + return;
100722 +
100723 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100724 + const_tree type = get_field_type(field);
100725 + enum tree_code code = TREE_CODE(type);
100726 +
100727 + if (node == type)
100728 + continue;
100729 +
100730 + if (is_fptr(field))
100731 + cinfo->has_fptr_field = true;
100732 + else if (!TREE_READONLY(field))
100733 + cinfo->has_writable_field = true;
100734 +
100735 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100736 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100737 + cinfo->has_do_const_field = true;
100738 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100739 + cinfo->has_no_const_field = true;
100740 + else
100741 + constifiable(type, cinfo);
100742 + }
100743 + }
100744 +}
100745 +
100746 +static bool constified(const_tree node)
100747 +{
100748 + constify_info cinfo = {
100749 + .has_fptr_field = false,
100750 + .has_writable_field = false,
100751 + .has_do_const_field = false,
100752 + .has_no_const_field = false
100753 + };
100754 +
100755 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100756 +
100757 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100758 + gcc_assert(!TYPE_READONLY(node));
100759 + return false;
100760 + }
100761 +
100762 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100763 + gcc_assert(TYPE_READONLY(node));
100764 + return true;
100765 + }
100766 +
100767 + constifiable(node, &cinfo);
100768 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100769 + return false;
100770 +
100771 + return TYPE_READONLY(node);
100772 +}
100773 +
100774 +static void deconstify_tree(tree node);
100775 +
100776 +static void deconstify_type(tree type)
100777 +{
100778 + tree field;
100779 +
100780 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100781 +
100782 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100783 + const_tree fieldtype = get_field_type(field);
100784 +
100785 + // special case handling of simple ptr-to-same-array-type members
100786 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100787 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100788 +
100789 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100790 + continue;
100791 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100792 + continue;
100793 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100794 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100795 + TREE_TYPE(TREE_TYPE(field)) = type;
100796 + }
100797 + continue;
100798 + }
100799 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100800 + continue;
100801 + if (!constified(fieldtype))
100802 + continue;
100803 +
100804 + deconstify_tree(field);
100805 + TREE_READONLY(field) = 0;
100806 + }
100807 + TYPE_READONLY(type) = 0;
100808 + C_TYPE_FIELDS_READONLY(type) = 0;
100809 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100810 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100811 +}
100812 +
100813 +static void deconstify_tree(tree node)
100814 +{
100815 + tree old_type, new_type, field;
100816 +
100817 + old_type = TREE_TYPE(node);
100818 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100819 + node = TREE_TYPE(node) = copy_node(old_type);
100820 + old_type = TREE_TYPE(old_type);
100821 + }
100822 +
100823 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100824 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100825 +
100826 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100827 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100828 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100829 + DECL_FIELD_CONTEXT(field) = new_type;
100830 +
100831 + deconstify_type(new_type);
100832 +
100833 + TREE_TYPE(node) = new_type;
100834 +}
100835 +
100836 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100837 +{
100838 + tree type;
100839 + constify_info cinfo = {
100840 + .has_fptr_field = false,
100841 + .has_writable_field = false,
100842 + .has_do_const_field = false,
100843 + .has_no_const_field = false
100844 + };
100845 +
100846 + *no_add_attrs = true;
100847 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100848 + error("%qE attribute does not apply to functions", name);
100849 + return NULL_TREE;
100850 + }
100851 +
100852 + if (TREE_CODE(*node) == PARM_DECL) {
100853 + error("%qE attribute does not apply to function parameters", name);
100854 + return NULL_TREE;
100855 + }
100856 +
100857 + if (TREE_CODE(*node) == VAR_DECL) {
100858 + error("%qE attribute does not apply to variables", name);
100859 + return NULL_TREE;
100860 + }
100861 +
100862 + if (TYPE_P(*node)) {
100863 + *no_add_attrs = false;
100864 + type = *node;
100865 + } else {
100866 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100867 + type = TREE_TYPE(*node);
100868 + }
100869 +
100870 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100871 + error("%qE attribute applies to struct and union types only", name);
100872 + return NULL_TREE;
100873 + }
100874 +
100875 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100876 + error("%qE attribute is already applied to the type", name);
100877 + return NULL_TREE;
100878 + }
100879 +
100880 + if (TYPE_P(*node)) {
100881 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100882 + error("%qE attribute is incompatible with 'do_const'", name);
100883 + return NULL_TREE;
100884 + }
100885 +
100886 + constifiable(type, &cinfo);
100887 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100888 + deconstify_tree(*node);
100889 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100890 + return NULL_TREE;
100891 + }
100892 +
100893 + error("%qE attribute used on type that is not constified", name);
100894 + return NULL_TREE;
100895 +}
100896 +
100897 +static void constify_type(tree type)
100898 +{
100899 + TYPE_READONLY(type) = 1;
100900 + C_TYPE_FIELDS_READONLY(type) = 1;
100901 + TYPE_CONSTIFY_VISITED(type) = 1;
100902 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100903 +}
100904 +
100905 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100906 +{
100907 + *no_add_attrs = true;
100908 + if (!TYPE_P(*node)) {
100909 + error("%qE attribute applies to types only", name);
100910 + return NULL_TREE;
100911 + }
100912 +
100913 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100914 + error("%qE attribute applies to struct and union types only", name);
100915 + return NULL_TREE;
100916 + }
100917 +
100918 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100919 + error("%qE attribute is already applied to the type", name);
100920 + return NULL_TREE;
100921 + }
100922 +
100923 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100924 + error("%qE attribute is incompatible with 'no_const'", name);
100925 + return NULL_TREE;
100926 + }
100927 +
100928 + *no_add_attrs = false;
100929 + return NULL_TREE;
100930 +}
100931 +
100932 +static struct attribute_spec no_const_attr = {
100933 + .name = "no_const",
100934 + .min_length = 0,
100935 + .max_length = 0,
100936 + .decl_required = false,
100937 + .type_required = false,
100938 + .function_type_required = false,
100939 + .handler = handle_no_const_attribute,
100940 +#if BUILDING_GCC_VERSION >= 4007
100941 + .affects_type_identity = true
100942 +#endif
100943 +};
100944 +
100945 +static struct attribute_spec do_const_attr = {
100946 + .name = "do_const",
100947 + .min_length = 0,
100948 + .max_length = 0,
100949 + .decl_required = false,
100950 + .type_required = false,
100951 + .function_type_required = false,
100952 + .handler = handle_do_const_attribute,
100953 +#if BUILDING_GCC_VERSION >= 4007
100954 + .affects_type_identity = true
100955 +#endif
100956 +};
100957 +
100958 +static void register_attributes(void *event_data, void *data)
100959 +{
100960 + register_attribute(&no_const_attr);
100961 + register_attribute(&do_const_attr);
100962 +}
100963 +
100964 +static void finish_type(void *event_data, void *data)
100965 +{
100966 + tree type = (tree)event_data;
100967 + constify_info cinfo = {
100968 + .has_fptr_field = false,
100969 + .has_writable_field = false,
100970 + .has_do_const_field = false,
100971 + .has_no_const_field = false
100972 + };
100973 +
100974 + if (type == NULL_TREE || type == error_mark_node)
100975 + return;
100976 +
100977 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100978 + return;
100979 +
100980 + constifiable(type, &cinfo);
100981 +
100982 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100983 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100984 + return;
100985 + if (cinfo.has_writable_field)
100986 + return;
100987 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100988 + return;
100989 + }
100990 +
100991 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100992 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100993 + deconstify_type(type);
100994 + TYPE_CONSTIFY_VISITED(type) = 1;
100995 + } else
100996 + error("'no_const' attribute used on type that is not constified");
100997 + return;
100998 + }
100999 +
101000 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101001 + constify_type(type);
101002 + return;
101003 + }
101004 +
101005 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
101006 + constify_type(type);
101007 + return;
101008 + }
101009 +
101010 + deconstify_type(type);
101011 + TYPE_CONSTIFY_VISITED(type) = 1;
101012 +}
101013 +
101014 +static void check_global_variables(void)
101015 +{
101016 + struct varpool_node *node;
101017 +
101018 +#if BUILDING_GCC_VERSION <= 4007
101019 + for (node = varpool_nodes; node; node = node->next) {
101020 + tree var = node->decl;
101021 +#else
101022 + FOR_EACH_VARIABLE(node) {
101023 + tree var = node->symbol.decl;
101024 +#endif
101025 + tree type = TREE_TYPE(var);
101026 +
101027 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101028 + continue;
101029 +
101030 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101031 + continue;
101032 +
101033 + if (!TYPE_CONSTIFY_VISITED(type))
101034 + continue;
101035 +
101036 + if (DECL_EXTERNAL(var))
101037 + continue;
101038 +
101039 + if (DECL_INITIAL(var))
101040 + continue;
101041 +
101042 + // this works around a gcc bug/feature where uninitialized globals
101043 + // are moved into the .bss section regardless of any constification
101044 + DECL_INITIAL(var) = build_constructor(type, NULL);
101045 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
101046 + }
101047 +}
101048 +
101049 +static unsigned int check_local_variables(void)
101050 +{
101051 + unsigned int ret = 0;
101052 + tree var;
101053 +
101054 +#if BUILDING_GCC_VERSION == 4005
101055 + tree vars;
101056 +#else
101057 + unsigned int i;
101058 +#endif
101059 +
101060 +#if BUILDING_GCC_VERSION == 4005
101061 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
101062 + var = TREE_VALUE(vars);
101063 +#else
101064 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
101065 +#endif
101066 + tree type = TREE_TYPE(var);
101067 +
101068 + gcc_assert(DECL_P(var));
101069 + if (is_global_var(var))
101070 + continue;
101071 +
101072 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101073 + continue;
101074 +
101075 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101076 + continue;
101077 +
101078 + if (!TYPE_CONSTIFY_VISITED(type))
101079 + continue;
101080 +
101081 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
101082 + ret = 1;
101083 + }
101084 + return ret;
101085 +}
101086 +
101087 +static unsigned int check_variables(void)
101088 +{
101089 + check_global_variables();
101090 + return check_local_variables();
101091 +}
101092 +
101093 + unsigned int ret = 0;
101094 +static struct gimple_opt_pass pass_local_variable = {
101095 + {
101096 + .type = GIMPLE_PASS,
101097 + .name = "check_variables",
101098 +#if BUILDING_GCC_VERSION >= 4008
101099 + .optinfo_flags = OPTGROUP_NONE,
101100 +#endif
101101 + .gate = NULL,
101102 + .execute = check_variables,
101103 + .sub = NULL,
101104 + .next = NULL,
101105 + .static_pass_number = 0,
101106 + .tv_id = TV_NONE,
101107 + .properties_required = 0,
101108 + .properties_provided = 0,
101109 + .properties_destroyed = 0,
101110 + .todo_flags_start = 0,
101111 + .todo_flags_finish = 0
101112 + }
101113 +};
101114 +
101115 +static struct {
101116 + const char *name;
101117 + const char *asm_op;
101118 +} sections[] = {
101119 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
101120 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
101121 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
101122 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
101123 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
101124 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
101125 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
101126 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
101127 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
101128 +};
101129 +
101130 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
101131 +
101132 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
101133 +{
101134 + size_t i;
101135 +
101136 + for (i = 0; i < ARRAY_SIZE(sections); i++)
101137 + if (!strcmp(sections[i].name, name))
101138 + return 0;
101139 + return old_section_type_flags(decl, name, reloc);
101140 +}
101141 +
101142 +static void constify_start_unit(void *gcc_data, void *user_data)
101143 +{
101144 +// size_t i;
101145 +
101146 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
101147 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
101148 +// sections[i].section = get_section(sections[i].name, 0, NULL);
101149 +
101150 + old_section_type_flags = targetm.section_type_flags;
101151 + targetm.section_type_flags = constify_section_type_flags;
101152 +}
101153 +
101154 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101155 +{
101156 + const char * const plugin_name = plugin_info->base_name;
101157 + const int argc = plugin_info->argc;
101158 + const struct plugin_argument * const argv = plugin_info->argv;
101159 + int i;
101160 + bool constify = true;
101161 +
101162 + struct register_pass_info local_variable_pass_info = {
101163 + .pass = &pass_local_variable.pass,
101164 + .reference_pass_name = "ssa",
101165 + .ref_pass_instance_number = 1,
101166 + .pos_op = PASS_POS_INSERT_BEFORE
101167 + };
101168 +
101169 + if (!plugin_default_version_check(version, &gcc_version)) {
101170 + error(G_("incompatible gcc/plugin versions"));
101171 + return 1;
101172 + }
101173 +
101174 + for (i = 0; i < argc; ++i) {
101175 + if (!(strcmp(argv[i].key, "no-constify"))) {
101176 + constify = false;
101177 + continue;
101178 + }
101179 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101180 + }
101181 +
101182 + if (strcmp(lang_hooks.name, "GNU C")) {
101183 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
101184 + constify = false;
101185 + }
101186 +
101187 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
101188 + if (constify) {
101189 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
101190 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
101191 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
101192 + }
101193 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101194 +
101195 + return 0;
101196 +}
101197 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
101198 new file mode 100644
101199 index 0000000..e518932
101200 --- /dev/null
101201 +++ b/tools/gcc/generate_size_overflow_hash.sh
101202 @@ -0,0 +1,94 @@
101203 +#!/bin/bash
101204 +
101205 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
101206 +
101207 +header1="size_overflow_hash.h"
101208 +database="size_overflow_hash.data"
101209 +n=65536
101210 +
101211 +usage() {
101212 +cat <<EOF
101213 +usage: $0 options
101214 +OPTIONS:
101215 + -h|--help help
101216 + -o header file
101217 + -d database file
101218 + -n hash array size
101219 +EOF
101220 + return 0
101221 +}
101222 +
101223 +while true
101224 +do
101225 + case "$1" in
101226 + -h|--help) usage && exit 0;;
101227 + -n) n=$2; shift 2;;
101228 + -o) header1="$2"; shift 2;;
101229 + -d) database="$2"; shift 2;;
101230 + --) shift 1; break ;;
101231 + *) break ;;
101232 + esac
101233 +done
101234 +
101235 +create_defines() {
101236 + for i in `seq 0 31`
101237 + do
101238 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
101239 + done
101240 + echo >> "$header1"
101241 +}
101242 +
101243 +create_structs() {
101244 + rm -f "$header1"
101245 +
101246 + create_defines
101247 +
101248 + cat "$database" | while read data
101249 + do
101250 + data_array=($data)
101251 + struct_hash_name="${data_array[0]}"
101252 + funcn="${data_array[1]}"
101253 + params="${data_array[2]}"
101254 + next="${data_array[4]}"
101255 +
101256 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
101257 +
101258 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
101259 + echo -en "\t.param\t= " >> "$header1"
101260 + line=
101261 + for param_num in ${params//-/ };
101262 + do
101263 + line="${line}PARAM"$param_num"|"
101264 + done
101265 +
101266 + echo -e "${line%?},\n};\n" >> "$header1"
101267 + done
101268 +}
101269 +
101270 +create_headers() {
101271 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
101272 +}
101273 +
101274 +create_array_elements() {
101275 + index=0
101276 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
101277 + do
101278 + data_array=($data)
101279 + i="${data_array[3]}"
101280 + hash="${data_array[0]}"
101281 + while [[ $index -lt $i ]]
101282 + do
101283 + echo -e "\t["$index"]\t= NULL," >> "$header1"
101284 + index=$(($index + 1))
101285 + done
101286 + index=$(($index + 1))
101287 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
101288 + done
101289 + echo '};' >> $header1
101290 +}
101291 +
101292 +create_structs
101293 +create_headers
101294 +create_array_elements
101295 +
101296 +exit 0
101297 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
101298 new file mode 100644
101299 index 0000000..568b360
101300 --- /dev/null
101301 +++ b/tools/gcc/kallocstat_plugin.c
101302 @@ -0,0 +1,170 @@
101303 +/*
101304 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101305 + * Licensed under the GPL v2
101306 + *
101307 + * Note: the choice of the license means that the compilation process is
101308 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101309 + * but for the kernel it doesn't matter since it doesn't link against
101310 + * any of the gcc libraries
101311 + *
101312 + * gcc plugin to find the distribution of k*alloc sizes
101313 + *
101314 + * TODO:
101315 + *
101316 + * BUGS:
101317 + * - none known
101318 + */
101319 +#include "gcc-plugin.h"
101320 +#include "config.h"
101321 +#include "system.h"
101322 +#include "coretypes.h"
101323 +#include "tree.h"
101324 +#include "tree-pass.h"
101325 +#include "flags.h"
101326 +#include "intl.h"
101327 +#include "toplev.h"
101328 +#include "plugin.h"
101329 +//#include "expr.h" where are you...
101330 +#include "diagnostic.h"
101331 +#include "plugin-version.h"
101332 +#include "tm.h"
101333 +#include "function.h"
101334 +#include "basic-block.h"
101335 +#include "gimple.h"
101336 +#include "rtl.h"
101337 +#include "emit-rtl.h"
101338 +
101339 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101340 +
101341 +int plugin_is_GPL_compatible;
101342 +
101343 +static const char * const kalloc_functions[] = {
101344 + "__kmalloc",
101345 + "kmalloc",
101346 + "kmalloc_large",
101347 + "kmalloc_node",
101348 + "kmalloc_order",
101349 + "kmalloc_order_trace",
101350 + "kmalloc_slab",
101351 + "kzalloc",
101352 + "kzalloc_node",
101353 +};
101354 +
101355 +static struct plugin_info kallocstat_plugin_info = {
101356 + .version = "201302112000",
101357 +};
101358 +
101359 +static unsigned int execute_kallocstat(void);
101360 +
101361 +static struct gimple_opt_pass kallocstat_pass = {
101362 + .pass = {
101363 + .type = GIMPLE_PASS,
101364 + .name = "kallocstat",
101365 +#if BUILDING_GCC_VERSION >= 4008
101366 + .optinfo_flags = OPTGROUP_NONE,
101367 +#endif
101368 + .gate = NULL,
101369 + .execute = execute_kallocstat,
101370 + .sub = NULL,
101371 + .next = NULL,
101372 + .static_pass_number = 0,
101373 + .tv_id = TV_NONE,
101374 + .properties_required = 0,
101375 + .properties_provided = 0,
101376 + .properties_destroyed = 0,
101377 + .todo_flags_start = 0,
101378 + .todo_flags_finish = 0
101379 + }
101380 +};
101381 +
101382 +static bool is_kalloc(const char *fnname)
101383 +{
101384 + size_t i;
101385 +
101386 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101387 + if (!strcmp(fnname, kalloc_functions[i]))
101388 + return true;
101389 + return false;
101390 +}
101391 +
101392 +static unsigned int execute_kallocstat(void)
101393 +{
101394 + basic_block bb;
101395 +
101396 + // 1. loop through BBs and GIMPLE statements
101397 + FOR_EACH_BB(bb) {
101398 + gimple_stmt_iterator gsi;
101399 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101400 + // gimple match:
101401 + tree fndecl, size;
101402 + gimple call_stmt;
101403 + const char *fnname;
101404 +
101405 + // is it a call
101406 + call_stmt = gsi_stmt(gsi);
101407 + if (!is_gimple_call(call_stmt))
101408 + continue;
101409 + fndecl = gimple_call_fndecl(call_stmt);
101410 + if (fndecl == NULL_TREE)
101411 + continue;
101412 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101413 + continue;
101414 +
101415 + // is it a call to k*alloc
101416 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101417 + if (!is_kalloc(fnname))
101418 + continue;
101419 +
101420 + // is the size arg the result of a simple const assignment
101421 + size = gimple_call_arg(call_stmt, 0);
101422 + while (true) {
101423 + gimple def_stmt;
101424 + expanded_location xloc;
101425 + size_t size_val;
101426 +
101427 + if (TREE_CODE(size) != SSA_NAME)
101428 + break;
101429 + def_stmt = SSA_NAME_DEF_STMT(size);
101430 + if (!def_stmt || !is_gimple_assign(def_stmt))
101431 + break;
101432 + if (gimple_num_ops(def_stmt) != 2)
101433 + break;
101434 + size = gimple_assign_rhs1(def_stmt);
101435 + if (!TREE_CONSTANT(size))
101436 + continue;
101437 + xloc = expand_location(gimple_location(def_stmt));
101438 + if (!xloc.file)
101439 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101440 + size_val = TREE_INT_CST_LOW(size);
101441 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101442 + break;
101443 + }
101444 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101445 +//debug_tree(gimple_call_fn(call_stmt));
101446 +//print_node(stderr, "pax", fndecl, 4);
101447 + }
101448 + }
101449 +
101450 + return 0;
101451 +}
101452 +
101453 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101454 +{
101455 + const char * const plugin_name = plugin_info->base_name;
101456 + struct register_pass_info kallocstat_pass_info = {
101457 + .pass = &kallocstat_pass.pass,
101458 + .reference_pass_name = "ssa",
101459 + .ref_pass_instance_number = 1,
101460 + .pos_op = PASS_POS_INSERT_AFTER
101461 + };
101462 +
101463 + if (!plugin_default_version_check(version, &gcc_version)) {
101464 + error(G_("incompatible gcc/plugin versions"));
101465 + return 1;
101466 + }
101467 +
101468 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101469 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101470 +
101471 + return 0;
101472 +}
101473 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101474 new file mode 100644
101475 index 0000000..698da67
101476 --- /dev/null
101477 +++ b/tools/gcc/kernexec_plugin.c
101478 @@ -0,0 +1,471 @@
101479 +/*
101480 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101481 + * Licensed under the GPL v2
101482 + *
101483 + * Note: the choice of the license means that the compilation process is
101484 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101485 + * but for the kernel it doesn't matter since it doesn't link against
101486 + * any of the gcc libraries
101487 + *
101488 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101489 + *
101490 + * TODO:
101491 + *
101492 + * BUGS:
101493 + * - none known
101494 + */
101495 +#include "gcc-plugin.h"
101496 +#include "config.h"
101497 +#include "system.h"
101498 +#include "coretypes.h"
101499 +#include "tree.h"
101500 +#include "tree-pass.h"
101501 +#include "flags.h"
101502 +#include "intl.h"
101503 +#include "toplev.h"
101504 +#include "plugin.h"
101505 +//#include "expr.h" where are you...
101506 +#include "diagnostic.h"
101507 +#include "plugin-version.h"
101508 +#include "tm.h"
101509 +#include "function.h"
101510 +#include "basic-block.h"
101511 +#include "gimple.h"
101512 +#include "rtl.h"
101513 +#include "emit-rtl.h"
101514 +#include "tree-flow.h"
101515 +
101516 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101517 +extern rtx emit_move_insn(rtx x, rtx y);
101518 +
101519 +#if BUILDING_GCC_VERSION <= 4006
101520 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101521 +#endif
101522 +
101523 +#if BUILDING_GCC_VERSION >= 4008
101524 +#define TODO_dump_func 0
101525 +#endif
101526 +
101527 +int plugin_is_GPL_compatible;
101528 +
101529 +static struct plugin_info kernexec_plugin_info = {
101530 + .version = "201308230150",
101531 + .help = "method=[bts|or]\tinstrumentation method\n"
101532 +};
101533 +
101534 +static unsigned int execute_kernexec_reload(void);
101535 +static unsigned int execute_kernexec_fptr(void);
101536 +static unsigned int execute_kernexec_retaddr(void);
101537 +static bool kernexec_cmodel_check(void);
101538 +
101539 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101540 +static void (*kernexec_instrument_retaddr)(rtx);
101541 +
101542 +static struct gimple_opt_pass kernexec_reload_pass = {
101543 + .pass = {
101544 + .type = GIMPLE_PASS,
101545 + .name = "kernexec_reload",
101546 +#if BUILDING_GCC_VERSION >= 4008
101547 + .optinfo_flags = OPTGROUP_NONE,
101548 +#endif
101549 + .gate = kernexec_cmodel_check,
101550 + .execute = execute_kernexec_reload,
101551 + .sub = NULL,
101552 + .next = NULL,
101553 + .static_pass_number = 0,
101554 + .tv_id = TV_NONE,
101555 + .properties_required = 0,
101556 + .properties_provided = 0,
101557 + .properties_destroyed = 0,
101558 + .todo_flags_start = 0,
101559 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101560 + }
101561 +};
101562 +
101563 +static struct gimple_opt_pass kernexec_fptr_pass = {
101564 + .pass = {
101565 + .type = GIMPLE_PASS,
101566 + .name = "kernexec_fptr",
101567 +#if BUILDING_GCC_VERSION >= 4008
101568 + .optinfo_flags = OPTGROUP_NONE,
101569 +#endif
101570 + .gate = kernexec_cmodel_check,
101571 + .execute = execute_kernexec_fptr,
101572 + .sub = NULL,
101573 + .next = NULL,
101574 + .static_pass_number = 0,
101575 + .tv_id = TV_NONE,
101576 + .properties_required = 0,
101577 + .properties_provided = 0,
101578 + .properties_destroyed = 0,
101579 + .todo_flags_start = 0,
101580 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101581 + }
101582 +};
101583 +
101584 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101585 + .pass = {
101586 + .type = RTL_PASS,
101587 + .name = "kernexec_retaddr",
101588 +#if BUILDING_GCC_VERSION >= 4008
101589 + .optinfo_flags = OPTGROUP_NONE,
101590 +#endif
101591 + .gate = kernexec_cmodel_check,
101592 + .execute = execute_kernexec_retaddr,
101593 + .sub = NULL,
101594 + .next = NULL,
101595 + .static_pass_number = 0,
101596 + .tv_id = TV_NONE,
101597 + .properties_required = 0,
101598 + .properties_provided = 0,
101599 + .properties_destroyed = 0,
101600 + .todo_flags_start = 0,
101601 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101602 + }
101603 +};
101604 +
101605 +static bool kernexec_cmodel_check(void)
101606 +{
101607 + tree section;
101608 +
101609 + if (ix86_cmodel != CM_KERNEL)
101610 + return false;
101611 +
101612 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101613 + if (!section || !TREE_VALUE(section))
101614 + return true;
101615 +
101616 + section = TREE_VALUE(TREE_VALUE(section));
101617 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101618 + return true;
101619 +
101620 + return false;
101621 +}
101622 +
101623 +/*
101624 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101625 + */
101626 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101627 +{
101628 + gimple asm_movabs_stmt;
101629 +
101630 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101631 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101632 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101633 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101634 + update_stmt(asm_movabs_stmt);
101635 +}
101636 +
101637 +/*
101638 + * find all asm() stmts that clobber r10 and add a reload of r10
101639 + */
101640 +static unsigned int execute_kernexec_reload(void)
101641 +{
101642 + basic_block bb;
101643 +
101644 + // 1. loop through BBs and GIMPLE statements
101645 + FOR_EACH_BB(bb) {
101646 + gimple_stmt_iterator gsi;
101647 +
101648 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101649 + // gimple match: __asm__ ("" : : : "r10");
101650 + gimple asm_stmt;
101651 + size_t nclobbers;
101652 +
101653 + // is it an asm ...
101654 + asm_stmt = gsi_stmt(gsi);
101655 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101656 + continue;
101657 +
101658 + // ... clobbering r10
101659 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101660 + while (nclobbers--) {
101661 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101662 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101663 + continue;
101664 + kernexec_reload_fptr_mask(&gsi);
101665 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101666 + break;
101667 + }
101668 + }
101669 + }
101670 +
101671 + return 0;
101672 +}
101673 +
101674 +/*
101675 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101676 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101677 + */
101678 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101679 +{
101680 + gimple assign_intptr, assign_new_fptr, call_stmt;
101681 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101682 +
101683 + call_stmt = gsi_stmt(*gsi);
101684 + old_fptr = gimple_call_fn(call_stmt);
101685 +
101686 + // create temporary unsigned long variable used for bitops and cast fptr to it
101687 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101688 +#if BUILDING_GCC_VERSION <= 4007
101689 + add_referenced_var(intptr);
101690 +#endif
101691 + intptr = make_ssa_name(intptr, NULL);
101692 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101693 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101694 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101695 + update_stmt(assign_intptr);
101696 +
101697 + // apply logical or to temporary unsigned long and bitmask
101698 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101699 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101700 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101701 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101702 + assign_intptr = gimple_build_assign(intptr, orptr);
101703 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101704 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101705 + update_stmt(assign_intptr);
101706 +
101707 + // cast temporary unsigned long back to a temporary fptr variable
101708 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101709 +#if BUILDING_GCC_VERSION <= 4007
101710 + add_referenced_var(new_fptr);
101711 +#endif
101712 + new_fptr = make_ssa_name(new_fptr, NULL);
101713 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101714 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101715 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101716 + update_stmt(assign_new_fptr);
101717 +
101718 + // replace call stmt fn with the new fptr
101719 + gimple_call_set_fn(call_stmt, new_fptr);
101720 + update_stmt(call_stmt);
101721 +}
101722 +
101723 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101724 +{
101725 + gimple asm_or_stmt, call_stmt;
101726 + tree old_fptr, new_fptr, input, output;
101727 +#if BUILDING_GCC_VERSION <= 4007
101728 + VEC(tree, gc) *inputs = NULL;
101729 + VEC(tree, gc) *outputs = NULL;
101730 +#else
101731 + vec<tree, va_gc> *inputs = NULL;
101732 + vec<tree, va_gc> *outputs = NULL;
101733 +#endif
101734 +
101735 + call_stmt = gsi_stmt(*gsi);
101736 + old_fptr = gimple_call_fn(call_stmt);
101737 +
101738 + // create temporary fptr variable
101739 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101740 +#if BUILDING_GCC_VERSION <= 4007
101741 + add_referenced_var(new_fptr);
101742 +#endif
101743 + new_fptr = make_ssa_name(new_fptr, NULL);
101744 +
101745 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101746 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101747 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101748 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101749 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101750 +#if BUILDING_GCC_VERSION <= 4007
101751 + VEC_safe_push(tree, gc, inputs, input);
101752 + VEC_safe_push(tree, gc, outputs, output);
101753 +#else
101754 + vec_safe_push(inputs, input);
101755 + vec_safe_push(outputs, output);
101756 +#endif
101757 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101758 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101759 + gimple_asm_set_volatile(asm_or_stmt, true);
101760 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101761 + update_stmt(asm_or_stmt);
101762 +
101763 + // replace call stmt fn with the new fptr
101764 + gimple_call_set_fn(call_stmt, new_fptr);
101765 + update_stmt(call_stmt);
101766 +}
101767 +
101768 +/*
101769 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101770 + */
101771 +static unsigned int execute_kernexec_fptr(void)
101772 +{
101773 + basic_block bb;
101774 +
101775 + // 1. loop through BBs and GIMPLE statements
101776 + FOR_EACH_BB(bb) {
101777 + gimple_stmt_iterator gsi;
101778 +
101779 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101780 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101781 + tree fn;
101782 + gimple call_stmt;
101783 +
101784 + // is it a call ...
101785 + call_stmt = gsi_stmt(gsi);
101786 + if (!is_gimple_call(call_stmt))
101787 + continue;
101788 + fn = gimple_call_fn(call_stmt);
101789 + if (TREE_CODE(fn) == ADDR_EXPR)
101790 + continue;
101791 + if (TREE_CODE(fn) != SSA_NAME)
101792 + gcc_unreachable();
101793 +
101794 + // ... through a function pointer
101795 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101796 + fn = SSA_NAME_VAR(fn);
101797 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101798 + debug_tree(fn);
101799 + gcc_unreachable();
101800 + }
101801 + }
101802 + fn = TREE_TYPE(fn);
101803 + if (TREE_CODE(fn) != POINTER_TYPE)
101804 + continue;
101805 + fn = TREE_TYPE(fn);
101806 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101807 + continue;
101808 +
101809 + kernexec_instrument_fptr(&gsi);
101810 +
101811 +//debug_tree(gimple_call_fn(call_stmt));
101812 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101813 + }
101814 + }
101815 +
101816 + return 0;
101817 +}
101818 +
101819 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101820 +static void kernexec_instrument_retaddr_bts(rtx insn)
101821 +{
101822 + rtx btsq;
101823 + rtvec argvec, constraintvec, labelvec;
101824 + int line;
101825 +
101826 + // create asm volatile("btsq $63,(%%rsp)":::)
101827 + argvec = rtvec_alloc(0);
101828 + constraintvec = rtvec_alloc(0);
101829 + labelvec = rtvec_alloc(0);
101830 + line = expand_location(RTL_LOCATION(insn)).line;
101831 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101832 + MEM_VOLATILE_P(btsq) = 1;
101833 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101834 + emit_insn_before(btsq, insn);
101835 +}
101836 +
101837 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101838 +static void kernexec_instrument_retaddr_or(rtx insn)
101839 +{
101840 + rtx orq;
101841 + rtvec argvec, constraintvec, labelvec;
101842 + int line;
101843 +
101844 + // create asm volatile("orq %%r10,(%%rsp)":::)
101845 + argvec = rtvec_alloc(0);
101846 + constraintvec = rtvec_alloc(0);
101847 + labelvec = rtvec_alloc(0);
101848 + line = expand_location(RTL_LOCATION(insn)).line;
101849 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101850 + MEM_VOLATILE_P(orq) = 1;
101851 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101852 + emit_insn_before(orq, insn);
101853 +}
101854 +
101855 +/*
101856 + * find all asm level function returns and forcibly set the highest bit of the return address
101857 + */
101858 +static unsigned int execute_kernexec_retaddr(void)
101859 +{
101860 + rtx insn;
101861 +
101862 + // 1. find function returns
101863 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101864 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101865 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101866 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101867 + rtx body;
101868 +
101869 + // is it a retn
101870 + if (!JUMP_P(insn))
101871 + continue;
101872 + body = PATTERN(insn);
101873 + if (GET_CODE(body) == PARALLEL)
101874 + body = XVECEXP(body, 0, 0);
101875 + if (!ANY_RETURN_P(body))
101876 + continue;
101877 + kernexec_instrument_retaddr(insn);
101878 + }
101879 +
101880 +// print_simple_rtl(stderr, get_insns());
101881 +// print_rtl(stderr, get_insns());
101882 +
101883 + return 0;
101884 +}
101885 +
101886 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101887 +{
101888 + const char * const plugin_name = plugin_info->base_name;
101889 + const int argc = plugin_info->argc;
101890 + const struct plugin_argument * const argv = plugin_info->argv;
101891 + int i;
101892 + struct register_pass_info kernexec_reload_pass_info = {
101893 + .pass = &kernexec_reload_pass.pass,
101894 + .reference_pass_name = "ssa",
101895 + .ref_pass_instance_number = 1,
101896 + .pos_op = PASS_POS_INSERT_AFTER
101897 + };
101898 + struct register_pass_info kernexec_fptr_pass_info = {
101899 + .pass = &kernexec_fptr_pass.pass,
101900 + .reference_pass_name = "ssa",
101901 + .ref_pass_instance_number = 1,
101902 + .pos_op = PASS_POS_INSERT_AFTER
101903 + };
101904 + struct register_pass_info kernexec_retaddr_pass_info = {
101905 + .pass = &kernexec_retaddr_pass.pass,
101906 + .reference_pass_name = "pro_and_epilogue",
101907 + .ref_pass_instance_number = 1,
101908 + .pos_op = PASS_POS_INSERT_AFTER
101909 + };
101910 +
101911 + if (!plugin_default_version_check(version, &gcc_version)) {
101912 + error(G_("incompatible gcc/plugin versions"));
101913 + return 1;
101914 + }
101915 +
101916 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101917 +
101918 + if (TARGET_64BIT == 0)
101919 + return 0;
101920 +
101921 + for (i = 0; i < argc; ++i) {
101922 + if (!strcmp(argv[i].key, "method")) {
101923 + if (!argv[i].value) {
101924 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101925 + continue;
101926 + }
101927 + if (!strcmp(argv[i].value, "bts")) {
101928 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101929 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101930 + } else if (!strcmp(argv[i].value, "or")) {
101931 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101932 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101933 + fix_register("r10", 1, 1);
101934 + } else
101935 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101936 + continue;
101937 + }
101938 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101939 + }
101940 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101941 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101942 +
101943 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101944 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101945 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101946 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101947 +
101948 + return 0;
101949 +}
101950 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101951 new file mode 100644
101952 index 0000000..679b9ef
101953 --- /dev/null
101954 +++ b/tools/gcc/latent_entropy_plugin.c
101955 @@ -0,0 +1,335 @@
101956 +/*
101957 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101958 + * Licensed under the GPL v2
101959 + *
101960 + * Note: the choice of the license means that the compilation process is
101961 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101962 + * but for the kernel it doesn't matter since it doesn't link against
101963 + * any of the gcc libraries
101964 + *
101965 + * gcc plugin to help generate a little bit of entropy from program state,
101966 + * used during boot in the kernel
101967 + *
101968 + * TODO:
101969 + * - add ipa pass to identify not explicitly marked candidate functions
101970 + * - mix in more program state (function arguments/return values, loop variables, etc)
101971 + * - more instrumentation control via attribute parameters
101972 + *
101973 + * BUGS:
101974 + * - LTO needs -flto-partition=none for now
101975 + */
101976 +#include "gcc-plugin.h"
101977 +#include "config.h"
101978 +#include "system.h"
101979 +#include "coretypes.h"
101980 +#include "tree.h"
101981 +#include "tree-pass.h"
101982 +#include "flags.h"
101983 +#include "intl.h"
101984 +#include "toplev.h"
101985 +#include "plugin.h"
101986 +//#include "expr.h" where are you...
101987 +#include "diagnostic.h"
101988 +#include "plugin-version.h"
101989 +#include "tm.h"
101990 +#include "function.h"
101991 +#include "basic-block.h"
101992 +#include "gimple.h"
101993 +#include "rtl.h"
101994 +#include "emit-rtl.h"
101995 +#include "tree-flow.h"
101996 +#include "langhooks.h"
101997 +
101998 +#if BUILDING_GCC_VERSION >= 4008
101999 +#define TODO_dump_func 0
102000 +#endif
102001 +
102002 +int plugin_is_GPL_compatible;
102003 +
102004 +static tree latent_entropy_decl;
102005 +
102006 +static struct plugin_info latent_entropy_plugin_info = {
102007 + .version = "201308230230",
102008 + .help = NULL
102009 +};
102010 +
102011 +static unsigned int execute_latent_entropy(void);
102012 +static bool gate_latent_entropy(void);
102013 +
102014 +static struct gimple_opt_pass latent_entropy_pass = {
102015 + .pass = {
102016 + .type = GIMPLE_PASS,
102017 + .name = "latent_entropy",
102018 +#if BUILDING_GCC_VERSION >= 4008
102019 + .optinfo_flags = OPTGROUP_NONE,
102020 +#endif
102021 + .gate = gate_latent_entropy,
102022 + .execute = execute_latent_entropy,
102023 + .sub = NULL,
102024 + .next = NULL,
102025 + .static_pass_number = 0,
102026 + .tv_id = TV_NONE,
102027 + .properties_required = PROP_gimple_leh | PROP_cfg,
102028 + .properties_provided = 0,
102029 + .properties_destroyed = 0,
102030 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102031 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102032 + }
102033 +};
102034 +
102035 +static unsigned HOST_WIDE_INT seed;
102036 +static unsigned HOST_WIDE_INT get_random_const(void)
102037 +{
102038 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
102039 + return seed;
102040 +}
102041 +
102042 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102043 +{
102044 + switch (TREE_CODE(*node)) {
102045 + default:
102046 + *no_add_attrs = true;
102047 + error("%qE attribute only applies to functions and variables", name);
102048 + break;
102049 +
102050 + case VAR_DECL:
102051 + if (DECL_INITIAL(*node)) {
102052 + *no_add_attrs = true;
102053 + error("variable %qD with %qE attribute must not be initialized", *node, name);
102054 + break;
102055 + }
102056 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
102057 + break;
102058 +
102059 + case FUNCTION_DECL:
102060 + break;
102061 + }
102062 +
102063 + return NULL_TREE;
102064 +}
102065 +
102066 +static struct attribute_spec latent_entropy_attr = {
102067 + .name = "latent_entropy",
102068 + .min_length = 0,
102069 + .max_length = 0,
102070 + .decl_required = true,
102071 + .type_required = false,
102072 + .function_type_required = false,
102073 + .handler = handle_latent_entropy_attribute,
102074 +#if BUILDING_GCC_VERSION >= 4007
102075 + .affects_type_identity = false
102076 +#endif
102077 +};
102078 +
102079 +static void register_attributes(void *event_data, void *data)
102080 +{
102081 + register_attribute(&latent_entropy_attr);
102082 +}
102083 +
102084 +static bool gate_latent_entropy(void)
102085 +{
102086 + tree latent_entropy_attr;
102087 +
102088 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
102089 + return latent_entropy_attr != NULL_TREE;
102090 +}
102091 +
102092 +static enum tree_code get_op(tree *rhs)
102093 +{
102094 + static enum tree_code op;
102095 + unsigned HOST_WIDE_INT random_const;
102096 +
102097 + random_const = get_random_const();
102098 +
102099 + switch (op) {
102100 + case BIT_XOR_EXPR:
102101 + op = PLUS_EXPR;
102102 + break;
102103 +
102104 + case PLUS_EXPR:
102105 + if (rhs) {
102106 + op = LROTATE_EXPR;
102107 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
102108 + break;
102109 + }
102110 +
102111 + case LROTATE_EXPR:
102112 + default:
102113 + op = BIT_XOR_EXPR;
102114 + break;
102115 + }
102116 + if (rhs)
102117 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
102118 + return op;
102119 +}
102120 +
102121 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
102122 +{
102123 + gimple_stmt_iterator gsi;
102124 + gimple assign;
102125 + tree addxorrol, rhs;
102126 + enum tree_code op;
102127 +
102128 + op = get_op(&rhs);
102129 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
102130 + assign = gimple_build_assign(local_entropy, addxorrol);
102131 + gsi = gsi_after_labels(bb);
102132 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102133 + update_stmt(assign);
102134 +//debug_bb(bb);
102135 +}
102136 +
102137 +static void perturb_latent_entropy(basic_block bb, tree rhs)
102138 +{
102139 + gimple_stmt_iterator gsi;
102140 + gimple assign;
102141 + tree addxorrol, temp;
102142 +
102143 + // 1. create temporary copy of latent_entropy
102144 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
102145 +#if BUILDING_GCC_VERSION <= 4007
102146 + add_referenced_var(temp);
102147 +#endif
102148 +
102149 + // 2. read...
102150 + temp = make_ssa_name(temp, NULL);
102151 + assign = gimple_build_assign(temp, latent_entropy_decl);
102152 + SSA_NAME_DEF_STMT(temp) = assign;
102153 +#if BUILDING_GCC_VERSION <= 4007
102154 + add_referenced_var(latent_entropy_decl);
102155 +#endif
102156 + gsi = gsi_after_labels(bb);
102157 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102158 + update_stmt(assign);
102159 +
102160 + // 3. ...modify...
102161 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
102162 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
102163 + assign = gimple_build_assign(temp, addxorrol);
102164 + SSA_NAME_DEF_STMT(temp) = assign;
102165 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102166 + update_stmt(assign);
102167 +
102168 + // 4. ...write latent_entropy
102169 + assign = gimple_build_assign(latent_entropy_decl, temp);
102170 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102171 + update_stmt(assign);
102172 +}
102173 +
102174 +static unsigned int execute_latent_entropy(void)
102175 +{
102176 + basic_block bb;
102177 + gimple assign;
102178 + gimple_stmt_iterator gsi;
102179 + tree local_entropy;
102180 +
102181 + if (!latent_entropy_decl) {
102182 + struct varpool_node *node;
102183 +
102184 +#if BUILDING_GCC_VERSION <= 4007
102185 + for (node = varpool_nodes; node; node = node->next) {
102186 + tree var = node->decl;
102187 +#else
102188 + FOR_EACH_VARIABLE(node) {
102189 + tree var = node->symbol.decl;
102190 +#endif
102191 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
102192 + continue;
102193 + latent_entropy_decl = var;
102194 +// debug_tree(var);
102195 + break;
102196 + }
102197 + if (!latent_entropy_decl) {
102198 +// debug_tree(current_function_decl);
102199 + return 0;
102200 + }
102201 + }
102202 +
102203 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102204 +
102205 + // 1. create local entropy variable
102206 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
102207 +#if BUILDING_GCC_VERSION <= 4007
102208 + add_referenced_var(local_entropy);
102209 + mark_sym_for_renaming(local_entropy);
102210 +#endif
102211 +
102212 + // 2. initialize local entropy variable
102213 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102214 + if (dom_info_available_p(CDI_DOMINATORS))
102215 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102216 + gsi = gsi_start_bb(bb);
102217 +
102218 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
102219 +// gimple_set_location(assign, loc);
102220 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102221 + update_stmt(assign);
102222 +//debug_bb(bb);
102223 + bb = bb->next_bb;
102224 +
102225 + // 3. instrument each BB with an operation on the local entropy variable
102226 + while (bb != EXIT_BLOCK_PTR) {
102227 + perturb_local_entropy(bb, local_entropy);
102228 +//debug_bb(bb);
102229 + bb = bb->next_bb;
102230 + };
102231 +
102232 + // 4. mix local entropy into the global entropy variable
102233 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
102234 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
102235 + return 0;
102236 +}
102237 +
102238 +static void start_unit_callback(void *gcc_data, void *user_data)
102239 +{
102240 + tree latent_entropy_type;
102241 +
102242 +#if BUILDING_GCC_VERSION >= 4007
102243 + seed = get_random_seed(false);
102244 +#else
102245 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
102246 + seed *= seed;
102247 +#endif
102248 +
102249 + if (in_lto_p)
102250 + return;
102251 +
102252 + // extern volatile u64 latent_entropy
102253 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
102254 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
102255 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
102256 +
102257 + TREE_STATIC(latent_entropy_decl) = 1;
102258 + TREE_PUBLIC(latent_entropy_decl) = 1;
102259 + TREE_USED(latent_entropy_decl) = 1;
102260 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
102261 + DECL_EXTERNAL(latent_entropy_decl) = 1;
102262 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
102263 + lang_hooks.decls.pushdecl(latent_entropy_decl);
102264 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
102265 +// varpool_finalize_decl(latent_entropy_decl);
102266 +// varpool_mark_needed_node(latent_entropy_decl);
102267 +}
102268 +
102269 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102270 +{
102271 + const char * const plugin_name = plugin_info->base_name;
102272 + struct register_pass_info latent_entropy_pass_info = {
102273 + .pass = &latent_entropy_pass.pass,
102274 + .reference_pass_name = "optimized",
102275 + .ref_pass_instance_number = 1,
102276 + .pos_op = PASS_POS_INSERT_BEFORE
102277 + };
102278 +
102279 + if (!plugin_default_version_check(version, &gcc_version)) {
102280 + error(G_("incompatible gcc/plugin versions"));
102281 + return 1;
102282 + }
102283 +
102284 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
102285 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102286 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
102287 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102288 +
102289 + return 0;
102290 +}
102291 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
102292 new file mode 100644
102293 index 0000000..b04803b
102294 --- /dev/null
102295 +++ b/tools/gcc/size_overflow_hash.data
102296 @@ -0,0 +1,6350 @@
102297 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
102298 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
102299 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
102300 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
102301 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
102302 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
102303 +padzero_55 padzero 1 55 &sel_read_policyvers_55
102304 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
102305 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
102306 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
102307 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
102308 +load_msg_95 load_msg 2 95 NULL
102309 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
102310 +init_q_132 init_q 4 132 NULL
102311 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
102312 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
102313 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
102314 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
102315 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
102316 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
102317 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
102318 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
102319 +br_port_info_size_268 br_port_info_size 0 268 NULL
102320 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
102321 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
102322 +SYSC_connect_304 SYSC_connect 3 304 NULL
102323 +syslog_print_307 syslog_print 2 307 NULL
102324 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
102325 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
102326 +next_node_allowed_318 next_node_allowed 1 318 NULL
102327 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
102328 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
102329 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
102330 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
102331 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
102332 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
102333 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
102334 +pidlist_resize_496 pidlist_resize 2 496 NULL
102335 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
102336 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
102337 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
102338 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
102339 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
102340 +dle_count_543 dle_count 0 543 NULL
102341 +devres_alloc_551 devres_alloc 2 551 NULL
102342 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
102343 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
102344 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
102345 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
102346 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
102347 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
102348 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
102349 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
102350 +isp1760_register_628 isp1760_register 1-2 628 NULL
102351 +clone_split_bio_633 clone_split_bio 6 633 NULL
102352 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
102353 +remap_to_cache_640 remap_to_cache 3 640 NULL
102354 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
102355 +unlink_queued_645 unlink_queued 3-4 645 NULL
102356 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
102357 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
102358 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
102359 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
102360 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
102361 +disk_max_parts_719 disk_max_parts 0 719 NULL
102362 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
102363 +dvb_video_write_754 dvb_video_write 3 754 NULL
102364 +if_writecmd_815 if_writecmd 2 815 NULL
102365 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
102366 +read_fifo_826 read_fifo 3 826 NULL
102367 +um_idi_read_850 um_idi_read 3 850 NULL
102368 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
102369 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
102370 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
102371 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
102372 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
102373 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102374 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
102375 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102376 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
102377 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
102378 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
102379 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102380 +_do_truncate_1019 _do_truncate 2 1019 NULL
102381 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102382 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102383 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
102384 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102385 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102386 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102387 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
102388 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102389 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102390 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
102391 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102392 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102393 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
102394 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102395 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102396 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102397 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102398 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102399 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102400 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
102401 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102402 +nested_get_page_1252 nested_get_page 2 1252 NULL
102403 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102404 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102405 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102406 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102407 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102408 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
102409 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
102410 +ffs_1322 ffs 0 1322 NULL
102411 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
102412 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
102413 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102414 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102415 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
102416 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102417 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102418 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102419 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102420 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102421 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102422 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102423 +zone_page_state_1393 zone_page_state 0 1393 NULL
102424 +file_read_actor_1401 file_read_actor 4 1401 NULL
102425 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102426 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102427 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102428 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102429 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102430 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102431 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102432 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102433 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
102434 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102435 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102436 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102437 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
102438 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102439 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102440 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102441 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
102442 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102443 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102444 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
102445 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
102446 +rmap_add_1677 rmap_add 3 1677 NULL
102447 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102448 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
102449 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102450 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102451 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102452 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
102453 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
102454 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102455 +cosa_write_1774 cosa_write 3 1774 NULL
102456 +update_macheader_1775 update_macheader 7 1775 NULL
102457 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
102458 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102459 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
102460 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
102461 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102462 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102463 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102464 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
102465 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102466 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
102467 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102468 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102469 +read_swap_header_1957 read_swap_header 0 1957 NULL
102470 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102471 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102472 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
102473 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102474 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102475 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102476 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102477 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102478 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102479 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
102480 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
102481 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102482 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102483 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
102484 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102485 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102486 +audit_expand_2098 audit_expand 2 2098 NULL
102487 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102488 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102489 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102490 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
102491 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
102492 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102493 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102494 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102495 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
102496 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102497 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
102498 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102499 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
102500 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102501 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102502 +vhci_write_2224 vhci_write 3 2224 NULL
102503 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
102504 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
102505 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102506 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102507 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102508 +do_update_counters_2259 do_update_counters 4 2259 NULL
102509 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102510 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102511 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
102512 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102513 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
102514 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
102515 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102516 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102517 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102518 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
102519 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
102520 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102521 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
102522 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102523 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
102524 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102525 +raid1_size_2419 raid1_size 0-2 2419 NULL
102526 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
102527 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
102528 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
102529 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102530 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
102531 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102532 +update_pmkid_2481 update_pmkid 4 2481 NULL
102533 +wiphy_new_2482 wiphy_new 2 2482 NULL
102534 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102535 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102536 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102537 +dm_write_2513 dm_write 3 2513 NULL
102538 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102539 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102540 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102541 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
102542 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102543 +slot_bytes_2609 slot_bytes 0 2609 NULL
102544 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102545 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102546 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
102547 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102548 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
102549 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
102550 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
102551 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102552 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102553 +__next_cpu_2782 __next_cpu 1 2782 NULL
102554 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102555 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102556 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
102557 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102558 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102559 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102560 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102561 +mq_map_2871 mq_map 2 2871 NULL
102562 +nla_padlen_2883 nla_padlen 1 2883 NULL
102563 +cmm_write_2896 cmm_write 3 2896 NULL
102564 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102565 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102566 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102567 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102568 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102569 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
102570 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102571 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102572 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102573 +depth_write_3021 depth_write 3 3021 NULL
102574 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102575 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102576 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
102577 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102578 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102579 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102580 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
102581 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102582 +free_coherent_3082 free_coherent 4-2 3082 NULL
102583 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102584 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102585 +rb_alloc_3102 rb_alloc 1 3102 NULL
102586 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
102587 +print_time_3132 print_time 0 3132 NULL
102588 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102589 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102590 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102591 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102592 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102593 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102594 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102595 +alloc_context_3194 alloc_context 1 3194 NULL
102596 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
102597 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102598 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102599 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102600 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102601 +key_key_read_3241 key_key_read 3 3241 NULL
102602 +number_3243 number 0 3243 NULL
102603 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
102604 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102605 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
102606 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102607 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102608 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
102609 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102610 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102611 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102612 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102613 +scnprintf_3360 scnprintf 0-2 3360 NULL
102614 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102615 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102616 +send_stream_3397 send_stream 4 3397 NULL
102617 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102618 +msix_map_region_3411 msix_map_region 3 3411 NULL
102619 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102620 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102621 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102622 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102623 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102624 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
102625 +map_single_3449 map_single 0-2 3449 NULL
102626 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102627 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
102628 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
102629 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102630 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102631 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
102632 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
102633 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
102634 +SyS_readv_3539 SyS_readv 3 3539 NULL
102635 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102636 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
102637 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102638 +evtchn_read_3569 evtchn_read 3 3569 NULL
102639 +vc_resize_3585 vc_resize 2-3 3585 NULL
102640 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
102641 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102642 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102643 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102644 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102645 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
102646 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
102647 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102648 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102649 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102650 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
102651 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
102652 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102653 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102654 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102655 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102656 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102657 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
102658 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102659 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102660 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102661 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102662 +get_fd_set_3866 get_fd_set 1 3866 NULL
102663 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102664 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
102665 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102666 +nvram_write_3894 nvram_write 3 3894 NULL
102667 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102668 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102669 +vcs_write_3910 vcs_write 3 3910 NULL
102670 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102671 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
102672 +do_add_counters_3992 do_add_counters 3 3992 NULL
102673 +userspace_status_4004 userspace_status 4 4004 NULL
102674 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102675 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102676 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102677 +mm_populate_4016 mm_populate 1 4016 NULL
102678 +blk_end_request_4024 blk_end_request 3 4024 NULL
102679 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102680 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
102681 +read_file_queues_4078 read_file_queues 3 4078 NULL
102682 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102683 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102684 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
102685 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
102686 +tm6000_read_4151 tm6000_read 3 4151 NULL
102687 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102688 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102689 +get_alua_req_4166 get_alua_req 3 4166 NULL
102690 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102691 +read_file_bool_4180 read_file_bool 3 4180 NULL
102692 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102693 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102694 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102695 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102696 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102697 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102698 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102699 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102700 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102701 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102702 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
102703 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
102704 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102705 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
102706 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102707 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102708 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102709 +memparse_4444 memparse 0 4444 NULL
102710 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102711 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
102712 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
102713 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102714 +set_link_security_4502 set_link_security 4 4502 NULL
102715 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102716 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
102717 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
102718 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102719 +tty_register_device_4544 tty_register_device 2 4544 NULL
102720 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102721 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102722 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102723 +bch_alloc_4593 bch_alloc 1 4593 NULL
102724 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102725 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102726 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102727 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102728 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102729 +kone_receive_4690 kone_receive 4 4690 NULL
102730 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
102731 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102732 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102733 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
102734 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102735 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102736 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102737 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
102738 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
102739 +create_subvol_4791 create_subvol 4 4791 NULL
102740 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102741 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
102742 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102743 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102744 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
102745 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102746 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102747 +sys_ipc_4889 sys_ipc 3 4889 NULL
102748 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
102749 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
102750 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102751 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
102752 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102753 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102754 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102755 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102756 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
102757 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
102758 +do_mincore_5018 do_mincore 0-1 5018 NULL
102759 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
102760 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
102761 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102762 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102763 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102764 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
102765 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102766 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
102767 +sound_write_5102 sound_write 3 5102 NULL
102768 +clear_dirty_5105 clear_dirty 3 5105 NULL
102769 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102770 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
102771 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102772 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102773 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102774 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
102775 +skb_network_header_5203 skb_network_header 0 5203 NULL
102776 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
102777 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
102778 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102779 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102780 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
102781 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
102782 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
102783 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
102784 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102785 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102786 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102787 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102788 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102789 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102790 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102791 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
102792 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
102793 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102794 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102795 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
102796 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102797 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102798 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102799 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102800 +tty_write_5494 tty_write 3 5494 NULL
102801 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102802 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102803 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102804 +spidev_message_5518 spidev_message 3 5518 NULL
102805 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102806 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102807 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
102808 +le_readq_5557 le_readq 0 5557 NULL
102809 +inw_5558 inw 0 5558 NULL
102810 +fir16_create_5574 fir16_create 3 5574 NULL
102811 +bioset_create_5580 bioset_create 1 5580 NULL
102812 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
102813 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
102814 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102815 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102816 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102817 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102818 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102819 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
102820 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
102821 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102822 +get_arg_5694 get_arg 3 5694 NULL
102823 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102824 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102825 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
102826 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102827 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
102828 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
102829 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
102830 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
102831 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102832 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102833 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102834 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102835 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
102836 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102837 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
102838 +setup_req_5848 setup_req 3 5848 NULL
102839 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102840 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
102841 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
102842 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102843 +port_show_regs_5904 port_show_regs 3 5904 NULL
102844 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102845 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102846 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
102847 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
102848 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102849 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102850 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102851 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
102852 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102853 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102854 +native_pte_val_5978 native_pte_val 0 5978 NULL
102855 +SyS_semop_5980 SyS_semop 3 5980 NULL
102856 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
102857 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
102858 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102859 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102860 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102861 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102862 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102863 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
102864 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102865 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102866 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102867 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102868 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102869 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102870 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102871 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102872 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102873 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102874 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102875 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102876 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102877 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102878 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102879 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102880 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102881 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102882 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102883 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102884 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102885 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102886 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102887 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102888 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102889 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102890 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102891 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102892 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102893 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102894 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102895 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102896 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102897 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102898 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102899 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102900 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102901 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102902 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102903 +mei_read_6507 mei_read 3 6507 NULL
102904 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102905 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102906 +wdm_read_6549 wdm_read 3 6549 NULL
102907 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102908 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102909 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102910 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102911 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102912 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102913 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102914 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102915 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102916 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102917 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102918 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102919 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102920 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102921 +mpeg_read_6708 mpeg_read 3 6708 NULL
102922 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102923 +video_proc_write_6724 video_proc_write 3 6724 NULL
102924 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102925 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102926 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102927 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102928 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102929 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102930 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102931 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102932 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102933 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102934 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102935 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102936 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102937 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102938 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102939 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102940 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102941 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102942 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102943 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102944 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102945 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102946 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102947 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102948 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102949 +request_key_async_6990 request_key_async 4 6990 NULL
102950 +tpl_write_6998 tpl_write 3 6998 NULL
102951 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102952 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102953 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102954 +wimax_msg_7030 wimax_msg 4 7030 NULL
102955 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102956 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102957 +event_enable_read_7074 event_enable_read 3 7074 NULL
102958 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102959 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102960 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102961 +check_header_7108 check_header 0 7108 NULL
102962 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102963 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102964 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102965 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102966 +get_param_h_7247 get_param_h 0 7247 NULL
102967 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102968 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102969 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102970 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102971 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102972 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102973 +mgmt_control_7349 mgmt_control 3 7349 NULL
102974 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102975 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102976 +hweight_long_7388 hweight_long 0-1 7388 NULL
102977 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102978 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102979 +readb_7401 readb 0 7401 NULL
102980 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102981 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102982 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102983 +numa_emulation_7466 numa_emulation 2 7466 NULL
102984 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102985 +garp_request_join_7471 garp_request_join 4 7471 NULL
102986 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102987 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102988 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102989 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102990 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102991 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102992 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102993 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102994 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102995 +groups_alloc_7614 groups_alloc 1 7614 NULL
102996 +sg_virt_7616 sg_virt 0 7616 NULL
102997 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102998 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102999 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103000 +dev_write_7708 dev_write 3 7708 NULL
103001 +unmap_region_7709 unmap_region 1 7709 NULL
103002 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
103003 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
103004 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103005 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
103006 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103007 +ioread32be_7773 ioread32be 0 7773 NULL
103008 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103009 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103010 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
103011 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
103012 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103013 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
103014 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
103015 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
103016 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
103017 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
103018 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
103019 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
103020 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
103021 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
103022 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
103023 +sys_mbind_7990 sys_mbind 5 7990 NULL
103024 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
103025 +vcs_read_8017 vcs_read 3 8017 NULL
103026 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
103027 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
103028 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
103029 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
103030 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
103031 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
103032 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
103033 +venus_lookup_8121 venus_lookup 4 8121 NULL
103034 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
103035 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
103036 +ore_truncate_8181 ore_truncate 3 8181 NULL
103037 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
103038 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
103039 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
103040 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
103041 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
103042 +play_iframe_8219 play_iframe 3 8219 NULL
103043 +create_log_8225 create_log 2 8225 NULL nohasharray
103044 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
103045 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
103046 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
103047 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
103048 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
103049 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
103050 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
103051 +init_cdev_8274 init_cdev 1 8274 NULL
103052 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
103053 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
103054 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
103055 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
103056 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
103057 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
103058 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
103059 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
103060 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
103061 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
103062 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
103063 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
103064 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
103065 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
103066 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
103067 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
103068 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
103069 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
103070 +dev_config_8506 dev_config 3 8506 NULL
103071 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
103072 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
103073 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
103074 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
103075 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
103076 +user_on_off_8552 user_on_off 2 8552 NULL
103077 +profile_remove_8556 profile_remove 3 8556 NULL
103078 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
103079 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
103080 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
103081 +tower_write_8580 tower_write 3 8580 NULL
103082 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
103083 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
103084 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
103085 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
103086 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
103087 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
103088 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
103089 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
103090 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
103091 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
103092 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
103093 +arcfb_write_8702 arcfb_write 3 8702 NULL
103094 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
103095 +init_header_8703 init_header 0 8703 &i_size_read_8703
103096 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
103097 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
103098 +f_dupfd_8730 f_dupfd 1 8730 NULL
103099 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
103100 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
103101 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
103102 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
103103 +sys_prctl_8766 sys_prctl 4 8766 NULL
103104 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
103105 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
103106 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
103107 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
103108 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
103109 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
103110 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
103111 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
103112 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
103113 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
103114 +clear_bitset_8840 clear_bitset 2 8840 NULL
103115 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
103116 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
103117 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
103118 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
103119 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
103120 +layout_commit_8926 layout_commit 3 8926 NULL
103121 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
103122 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
103123 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
103124 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
103125 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
103126 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
103127 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
103128 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
103129 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
103130 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
103131 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
103132 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
103133 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
103134 +nla_put_9042 nla_put 3 9042 NULL
103135 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
103136 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
103137 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
103138 +string_9080 string 0 9080 NULL
103139 +create_queues_9088 create_queues 2-3 9088 NULL
103140 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
103141 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
103142 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
103143 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
103144 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
103145 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
103146 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
103147 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
103148 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
103149 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
103150 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
103151 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
103152 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
103153 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
103154 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
103155 +get_pfn_9207 get_pfn 1 9207 NULL
103156 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
103157 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
103158 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
103159 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
103160 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
103161 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
103162 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
103163 +flakey_status_9274 flakey_status 5 9274 NULL
103164 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
103165 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
103166 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
103167 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
103168 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
103169 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
103170 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
103171 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
103172 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
103173 +read_9397 read 3 9397 NULL
103174 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
103175 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
103176 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
103177 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
103178 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
103179 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
103180 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
103181 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
103182 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
103183 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
103184 +lp_write_9511 lp_write 3 9511 NULL
103185 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
103186 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
103187 +read_file_dma_9530 read_file_dma 3 9530 NULL
103188 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
103189 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
103190 +fw_node_create_9559 fw_node_create 2 9559 NULL
103191 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
103192 +kobj_map_9566 kobj_map 2-3 9566 NULL
103193 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
103194 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
103195 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
103196 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
103197 +do_sync_9604 do_sync 1 9604 NULL
103198 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
103199 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
103200 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
103201 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
103202 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
103203 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
103204 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
103205 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
103206 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
103207 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
103208 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
103209 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
103210 +is_hole_9694 is_hole 2 9694 NULL nohasharray
103211 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
103212 +fnb_9703 fnb 2-3 9703 NULL
103213 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
103214 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
103215 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
103216 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
103217 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
103218 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
103219 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
103220 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
103221 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
103222 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
103223 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
103224 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
103225 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
103226 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
103227 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
103228 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
103229 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
103230 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
103231 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
103232 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
103233 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
103234 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
103235 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
103236 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
103237 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
103238 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
103239 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
103240 +read_file_misc_9948 read_file_misc 3 9948 NULL
103241 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
103242 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
103243 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
103244 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
103245 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
103246 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
103247 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
103248 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
103249 +handle_request_10024 handle_request 9 10024 NULL
103250 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
103251 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
103252 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
103253 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
103254 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
103255 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
103256 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
103257 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
103258 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
103259 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
103260 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
103261 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
103262 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
103263 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
103264 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
103265 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
103266 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
103267 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
103268 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
103269 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
103270 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
103271 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
103272 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
103273 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
103274 +read_emulate_10310 read_emulate 2-4 10310 NULL
103275 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
103276 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
103277 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
103278 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
103279 +get_dump_page_10338 get_dump_page 1 10338 NULL
103280 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
103281 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
103282 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
103283 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
103284 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
103285 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
103286 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
103287 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
103288 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
103289 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
103290 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
103291 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
103292 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
103293 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
103294 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
103295 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
103296 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
103297 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
103298 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
103299 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
103300 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
103301 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
103302 +otp_read_10594 otp_read 2-4-5 10594 NULL
103303 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
103304 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
103305 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
103306 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
103307 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
103308 +parport_write_10669 parport_write 0 10669 NULL
103309 +inl_10708 inl 0 10708 NULL nohasharray
103310 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
103311 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
103312 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
103313 +spi_sync_10731 spi_sync 0 10731 NULL
103314 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
103315 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
103316 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
103317 +sys_syslog_10746 sys_syslog 3 10746 NULL
103318 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
103319 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
103320 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
103321 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
103322 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
103323 +sys_bind_10799 sys_bind 3 10799 NULL
103324 +compat_put_int_10828 compat_put_int 1 10828 NULL
103325 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
103326 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
103327 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
103328 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
103329 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
103330 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
103331 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
103332 +get_scq_10897 get_scq 2 10897 NULL
103333 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
103334 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
103335 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
103336 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
103337 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
103338 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
103339 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
103340 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
103341 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
103342 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
103343 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
103344 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
103345 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
103346 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
103347 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
103348 +count_argc_11083 count_argc 0 11083 NULL
103349 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
103350 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
103351 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
103352 +page_offset_11120 page_offset 0 11120 NULL
103353 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
103354 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
103355 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
103356 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
103357 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
103358 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
103359 +__swab16p_11220 __swab16p 0 11220 NULL
103360 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
103361 +mmap_region_11247 mmap_region 0-2 11247 NULL
103362 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
103363 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
103364 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
103365 +cru_detect_11272 cru_detect 1 11272 NULL
103366 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
103367 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
103368 +construct_key_11329 construct_key 3 11329 NULL nohasharray
103369 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
103370 +next_segment_11330 next_segment 0-2-1 11330 NULL
103371 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
103372 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
103373 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
103374 +sel_write_create_11353 sel_write_create 3 11353 NULL
103375 +handle_unit_11355 handle_unit 0-1 11355 NULL
103376 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
103377 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103378 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103379 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103380 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103381 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
103382 +str_to_user_11411 str_to_user 2 11411 NULL
103383 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103384 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103385 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103386 +trace_options_read_11419 trace_options_read 3 11419 NULL
103387 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
103388 +prepare_image_11424 prepare_image 0 11424 NULL
103389 +vring_size_11426 vring_size 0-1-2 11426 NULL
103390 +bttv_read_11432 bttv_read 3 11432 NULL
103391 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103392 +swp_offset_11475 swp_offset 0 11475 NULL
103393 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
103394 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103395 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103396 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103397 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103398 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103399 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
103400 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
103401 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103402 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103403 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103404 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103405 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103406 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103407 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103408 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103409 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
103410 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103411 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103412 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103413 +split_11691 split 2 11691 NULL
103414 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103415 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103416 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
103417 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
103418 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103419 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103420 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103421 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103422 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103423 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
103424 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103425 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103426 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103427 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103428 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
103429 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103430 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103431 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
103432 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103433 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103434 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103435 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
103436 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103437 +atmel_read16_11981 atmel_read16 0 11981 NULL
103438 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103439 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103440 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103441 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103442 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103443 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103444 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103445 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103446 +set_powered_12129 set_powered 4 12129 NULL
103447 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
103448 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103449 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103450 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
103451 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103452 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103453 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103454 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103455 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103456 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
103457 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103458 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103459 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103460 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103461 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
103462 +scaled_div_12201 scaled_div 1-2 12201 NULL
103463 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
103464 +receive_copy_12216 receive_copy 3 12216 NULL
103465 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103466 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103467 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103468 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
103469 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103470 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
103471 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103472 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103473 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103474 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
103475 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
103476 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
103477 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103478 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
103479 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103480 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103481 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103482 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103483 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103484 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
103485 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103486 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103487 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103488 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
103489 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103490 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
103491 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103492 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
103493 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103494 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103495 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103496 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103497 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103498 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
103499 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103500 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
103501 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103502 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
103503 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103504 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
103505 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103506 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103507 +wb_create_12651 wb_create 1 12651 NULL
103508 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103509 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103510 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103511 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103512 +ivtv_write_12721 ivtv_write 3 12721 NULL
103513 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103514 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103515 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
103516 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103517 +listxattr_12769 listxattr 3 12769 NULL
103518 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103519 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
103520 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
103521 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
103522 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103523 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103524 +readq_12825 readq 0 12825 NULL
103525 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103526 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
103527 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
103528 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103529 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103530 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103531 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103532 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103533 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103534 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103535 +bm_status_write_12964 bm_status_write 3 12964 NULL
103536 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
103537 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103538 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
103539 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103540 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103541 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103542 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103543 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103544 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
103545 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103546 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103547 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103548 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
103549 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
103550 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
103551 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103552 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103553 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103554 +blk_update_request_13146 blk_update_request 3 13146 NULL
103555 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103556 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103557 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103558 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103559 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103560 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
103561 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103562 +comedi_read_13199 comedi_read 3 13199 NULL
103563 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103564 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103565 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103566 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103567 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103568 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
103569 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
103570 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103571 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
103572 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103573 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103574 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
103575 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103576 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103577 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103578 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
103579 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
103580 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103581 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
103582 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103583 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103584 +cache_ctr_13364 cache_ctr 2 13364 NULL
103585 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
103586 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103587 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103588 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
103589 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
103590 +sky2_receive_13407 sky2_receive 2 13407 NULL
103591 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103592 +keyring_read_13438 keyring_read 3 13438 NULL
103593 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
103594 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
103595 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103596 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
103597 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
103598 +core_status_13515 core_status 4 13515 NULL
103599 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103600 +bm_init_13529 bm_init 2 13529 NULL
103601 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
103602 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
103603 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103604 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103605 +sys_madvise_13569 sys_madvise 1 13569 NULL
103606 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103607 +cache_write_13589 cache_write 3 13589 NULL
103608 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
103609 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
103610 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
103611 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
103612 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103613 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103614 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103615 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
103616 +packet_snd_13634 packet_snd 3 13634 NULL
103617 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103618 +cache_downcall_13666 cache_downcall 3 13666 NULL
103619 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103620 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103621 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103622 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103623 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103624 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103625 +random_read_13815 random_read 3 13815 NULL
103626 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103627 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103628 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
103629 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
103630 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
103631 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
103632 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103633 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103634 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103635 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103636 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103637 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
103638 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103639 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103640 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103641 +com90xx_found_13974 com90xx_found 3 13974 NULL
103642 +qcam_read_13977 qcam_read 3 13977 NULL
103643 +dsp_read_13980 dsp_read 2 13980 NULL
103644 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103645 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103646 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103647 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103648 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
103649 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103650 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103651 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103652 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103653 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103654 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
103655 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103656 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
103657 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
103658 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
103659 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
103660 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
103661 +em_canid_change_14150 em_canid_change 3 14150 NULL
103662 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
103663 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
103664 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
103665 +alloc_async_14208 alloc_async 1 14208 NULL
103666 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
103667 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
103668 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
103669 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
103670 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
103671 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
103672 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
103673 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
103674 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
103675 +rr_status_14293 rr_status 5 14293 NULL
103676 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
103677 +oo_objects_14319 oo_objects 0 14319 NULL
103678 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
103679 +scsi2int_14358 scsi2int 0 14358 NULL
103680 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
103681 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
103682 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
103683 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
103684 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
103685 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
103686 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
103687 +block_size_14443 block_size 0 14443 NULL
103688 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
103689 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
103690 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
103691 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
103692 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
103693 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
103694 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
103695 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
103696 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
103697 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
103698 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
103699 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
103700 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
103701 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
103702 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
103703 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
103704 +dbJoin_14644 dbJoin 0 14644 NULL
103705 +profile_replace_14652 profile_replace 3 14652 NULL
103706 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
103707 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
103708 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
103709 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
103710 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
103711 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
103712 +get_bio_block_14714 get_bio_block 0 14714 NULL
103713 +vfd_write_14717 vfd_write 3 14717 NULL
103714 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
103715 +raid1_resize_14740 raid1_resize 2 14740 NULL
103716 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
103717 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
103718 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
103719 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
103720 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
103721 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
103722 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
103723 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
103724 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
103725 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
103726 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
103727 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
103728 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
103729 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
103730 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
103731 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
103732 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
103733 +unifi_read_14899 unifi_read 3 14899 NULL
103734 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
103735 +krealloc_14908 krealloc 2 14908 NULL
103736 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
103737 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
103738 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
103739 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
103740 +queue_cnt_14951 queue_cnt 0 14951 NULL
103741 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
103742 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
103743 +setkey_14987 setkey 3 14987 NULL nohasharray
103744 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
103745 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
103746 +vmap_15025 vmap 2 15025 NULL
103747 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
103748 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
103749 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
103750 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
103751 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
103752 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
103753 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
103754 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
103755 +start_port_15124 start_port 0 15124 NULL
103756 +memchr_15126 memchr 0 15126 NULL
103757 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
103758 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
103759 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
103760 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
103761 +reserve_resources_15194 reserve_resources 3 15194 NULL
103762 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
103763 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
103764 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
103765 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
103766 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
103767 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
103768 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
103769 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
103770 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
103771 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
103772 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
103773 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
103774 +ioread16_15342 ioread16 0 15342 NULL
103775 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
103776 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
103777 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
103778 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
103779 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
103780 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
103781 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
103782 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
103783 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
103784 +get_modalias_15406 get_modalias 2 15406 NULL
103785 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
103786 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
103787 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
103788 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
103789 +memweight_15450 memweight 2 15450 NULL
103790 +vmalloc_15464 vmalloc 1 15464 NULL
103791 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
103792 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
103793 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
103794 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
103795 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
103796 +persistent_status_15574 persistent_status 4 15574 NULL
103797 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
103798 +vme_user_write_15587 vme_user_write 3 15587 NULL
103799 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
103800 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
103801 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
103802 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
103803 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
103804 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
103805 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
103806 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
103807 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
103808 +fs_path_add_15648 fs_path_add 3 15648 NULL
103809 +xsd_read_15653 xsd_read 3 15653 NULL
103810 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
103811 +unix_bind_15668 unix_bind 3 15668 NULL
103812 +dm_read_15674 dm_read 3 15674 NULL
103813 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
103814 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
103815 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
103816 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
103817 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
103818 +do_test_15766 do_test 1 15766 NULL
103819 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
103820 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
103821 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
103822 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
103823 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
103824 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
103825 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
103826 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
103827 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
103828 +table_size_15851 table_size 0-1-2 15851 NULL
103829 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
103830 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
103831 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
103832 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
103833 +native_read_msr_15905 native_read_msr 0 15905 NULL
103834 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
103835 +power_read_15939 power_read 3 15939 NULL
103836 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
103837 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
103838 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
103839 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
103840 +frame_alloc_15981 frame_alloc 4 15981 NULL
103841 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
103842 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
103843 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
103844 +got_frame_16028 got_frame 2 16028 NULL
103845 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
103846 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
103847 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
103848 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
103849 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
103850 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
103851 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
103852 +fsm_init_16134 fsm_init 2 16134 NULL
103853 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
103854 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
103855 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
103856 +mapping_level_16188 mapping_level 2 16188 NULL
103857 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
103858 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
103859 +create_table_16213 create_table 2 16213 NULL
103860 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
103861 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
103862 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
103863 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
103864 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
103865 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
103866 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
103867 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103868 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103869 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103870 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103871 +account_16283 account 0-2-4 16283 NULL nohasharray
103872 +mirror_status_16283 mirror_status 5 16283 &account_16283
103873 +retry_instruction_16285 retry_instruction 2 16285 NULL
103874 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103875 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103876 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103877 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103878 +wb_map_16301 wb_map 2 16301 NULL
103879 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103880 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103881 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103882 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103883 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103884 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103885 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103886 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103887 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103888 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103889 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103890 +raid10_resize_16537 raid10_resize 2 16537 NULL
103891 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103892 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103893 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103894 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103895 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103896 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103897 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103898 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103899 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103900 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103901 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103902 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103903 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103904 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103905 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103906 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103907 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103908 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103909 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103910 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103911 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103912 +st_write_16874 st_write 3 16874 NULL
103913 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103914 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103915 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103916 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103917 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103918 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103919 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103920 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103921 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103922 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103923 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103924 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103925 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103926 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103927 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103928 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103929 +mac_address_string_17091 mac_address_string 0 17091 NULL
103930 +entry_length_17093 entry_length 0 17093 NULL
103931 +sys_preadv_17100 sys_preadv 3 17100 NULL
103932 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103933 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103934 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103935 +sep_read_17161 sep_read 3 17161 NULL
103936 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103937 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103938 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103939 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103940 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103941 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103942 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103943 +to_oblock_17254 to_oblock 0-1 17254 NULL
103944 +unpack_value_17259 unpack_value 1 17259 NULL
103945 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103946 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103947 +alloc_ep_17269 alloc_ep 1 17269 NULL
103948 +pg_read_17276 pg_read 3 17276 NULL
103949 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103950 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103951 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103952 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103953 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103954 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103955 +skb_pad_17302 skb_pad 2 17302 NULL
103956 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103957 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103958 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103959 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103960 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103961 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103962 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103963 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103964 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103965 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103966 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103967 +compat_cmd_17465 compat_cmd 2 17465 NULL
103968 +probe_bios_17467 probe_bios 1 17467 NULL
103969 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103970 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103971 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103972 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103973 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103974 +copy_from_user_17559 copy_from_user 3 17559 NULL
103975 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103976 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103977 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103978 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103979 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103980 +osst_execute_17607 osst_execute 7-6 17607 NULL
103981 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103982 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103983 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103984 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103985 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103986 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103987 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103988 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103989 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103990 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103991 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103992 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103993 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103994 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103995 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103996 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103997 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103998 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103999 +perf_clock_17787 perf_clock 0 17787 NULL
104000 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
104001 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
104002 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
104003 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
104004 +count_leafs_17842 count_leafs 0 17842 NULL
104005 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
104006 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
104007 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
104008 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
104009 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
104010 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
104011 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
104012 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
104013 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
104014 +recover_head_17904 recover_head 3 17904 NULL
104015 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
104016 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
104017 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
104018 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
104019 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
104020 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
104021 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
104022 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
104023 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
104024 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
104025 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
104026 +fill_read_18019 fill_read 0 18019 NULL
104027 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
104028 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
104029 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
104030 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
104031 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
104032 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
104033 +packet_came_18072 packet_came 3 18072 NULL
104034 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
104035 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
104036 +get_vm_area_18080 get_vm_area 1 18080 NULL
104037 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
104038 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
104039 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
104040 +svc_getnl_18120 svc_getnl 0 18120 NULL
104041 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
104042 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
104043 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
104044 +_has_tag_18169 _has_tag 2 18169 NULL
104045 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
104046 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
104047 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
104048 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
104049 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
104050 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
104051 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
104052 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
104053 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
104054 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
104055 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
104056 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
104057 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
104058 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
104059 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
104060 +um_idi_write_18293 um_idi_write 3 18293 NULL
104061 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
104062 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
104063 +vga_r_18310 vga_r 0 18310 NULL
104064 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
104065 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
104066 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
104067 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
104068 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
104069 +ep_io_18367 ep_io 0 18367 NULL
104070 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
104071 +ci_role_write_18388 ci_role_write 3 18388 NULL
104072 +__video_register_device_18399 __video_register_device 3 18399 NULL
104073 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
104074 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
104075 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
104076 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
104077 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
104078 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
104079 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
104080 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
104081 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
104082 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
104083 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
104084 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
104085 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
104086 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
104087 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
104088 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
104089 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
104090 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
104091 +debug_output_18575 debug_output 3 18575 NULL
104092 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
104093 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
104094 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
104095 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
104096 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
104097 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
104098 +from_buffer_18625 from_buffer 3 18625 NULL
104099 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
104100 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
104101 +unmap_page_18665 unmap_page 2-3 18665 NULL
104102 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
104103 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
104104 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
104105 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
104106 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
104107 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
104108 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
104109 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
104110 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
104111 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
104112 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
104113 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
104114 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
104115 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
104116 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
104117 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
104118 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
104119 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
104120 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
104121 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
104122 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
104123 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
104124 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
104125 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
104126 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
104127 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
104128 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
104129 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
104130 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
104131 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
104132 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
104133 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
104134 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
104135 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
104136 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
104137 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
104138 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
104139 +huge_page_size_19008 huge_page_size 0 19008 NULL
104140 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
104141 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
104142 +revalidate_19043 revalidate 2 19043 NULL
104143 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
104144 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
104145 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
104146 +msix_map_region_19072 msix_map_region 2 19072 NULL
104147 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
104148 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
104149 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
104150 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
104151 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
104152 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
104153 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
104154 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
104155 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
104156 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
104157 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
104158 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
104159 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
104160 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
104161 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
104162 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
104163 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
104164 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
104165 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
104166 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
104167 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
104168 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
104169 +qc_capture_19298 qc_capture 3 19298 NULL
104170 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
104171 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
104172 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
104173 +debug_read_19322 debug_read 3 19322 NULL
104174 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
104175 +closure_sub_19359 closure_sub 2 19359 NULL
104176 +read_zero_19366 read_zero 3 19366 NULL
104177 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
104178 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
104179 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
104180 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
104181 +__phys_addr_19434 __phys_addr 0 19434 NULL
104182 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
104183 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
104184 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
104185 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
104186 +sky2_read16_19475 sky2_read16 0 19475 NULL
104187 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
104188 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
104189 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
104190 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
104191 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
104192 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
104193 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
104194 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
104195 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
104196 +nfsd_read_19568 nfsd_read 5 19568 NULL
104197 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
104198 +bm_status_read_19583 bm_status_read 3 19583 NULL
104199 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
104200 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
104201 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
104202 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
104203 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
104204 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
104205 +bio_detain_19690 bio_detain 2 19690 NULL
104206 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
104207 +read_reg_19723 read_reg 0 19723 NULL
104208 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
104209 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
104210 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
104211 +p9_client_read_19750 p9_client_read 5 19750 NULL
104212 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
104213 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
104214 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
104215 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
104216 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
104217 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
104218 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
104219 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
104220 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
104221 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
104222 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
104223 +__nla_put_19857 __nla_put 3 19857 NULL
104224 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
104225 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
104226 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
104227 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
104228 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
104229 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
104230 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
104231 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
104232 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
104233 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
104234 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
104235 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
104236 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
104237 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
104238 +team_options_register_20091 team_options_register 3 20091 NULL
104239 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
104240 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
104241 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
104242 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
104243 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
104244 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
104245 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
104246 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
104247 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
104248 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
104249 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
104250 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
104251 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
104252 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
104253 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
104254 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
104255 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
104256 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
104257 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
104258 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
104259 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
104260 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
104261 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
104262 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
104263 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
104264 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
104265 +read_buf_20469 read_buf 2 20469 NULL
104266 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
104267 +fast_user_write_20494 fast_user_write 5 20494 NULL
104268 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
104269 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
104270 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
104271 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
104272 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
104273 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
104274 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
104275 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
104276 +venus_create_20555 venus_create 4 20555 NULL
104277 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
104278 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
104279 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
104280 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
104281 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
104282 +lirc_write_20604 lirc_write 3 20604 NULL
104283 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
104284 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
104285 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
104286 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
104287 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
104288 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
104289 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
104290 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
104291 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
104292 +cpumask_size_20683 cpumask_size 0 20683 NULL
104293 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
104294 +gru_vtop_20689 gru_vtop 2 20689 NULL
104295 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
104296 +__maestro_read_20700 __maestro_read 0 20700 NULL
104297 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
104298 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
104299 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
104300 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
104301 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
104302 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
104303 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
104304 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
104305 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
104306 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
104307 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
104308 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
104309 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
104310 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
104311 +sys_sendto_20809 sys_sendto 6 20809 NULL
104312 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
104313 +strndup_user_20819 strndup_user 2 20819 NULL
104314 +calc_layout_20829 calc_layout 3 20829 NULL
104315 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
104316 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
104317 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
104318 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
104319 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
104320 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
104321 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
104322 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
104323 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
104324 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
104325 +htable_bits_20933 htable_bits 0 20933 NULL
104326 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
104327 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
104328 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
104329 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
104330 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
104331 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
104332 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
104333 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
104334 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
104335 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
104336 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
104337 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
104338 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
104339 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
104340 +multipath_status_21094 multipath_status 5 21094 NULL
104341 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
104342 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
104343 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
104344 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
104345 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
104346 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
104347 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
104348 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
104349 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
104350 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
104351 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
104352 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
104353 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
104354 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
104355 +input_ff_create_21240 input_ff_create 2 21240 NULL
104356 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
104357 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
104358 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
104359 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
104360 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
104361 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
104362 +add_res_range_21310 add_res_range 4 21310 NULL
104363 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
104364 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
104365 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
104366 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
104367 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
104368 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
104369 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
104370 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
104371 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
104372 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
104373 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104374 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104375 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104376 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104377 +concat_writev_21451 concat_writev 3 21451 NULL
104378 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104379 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104380 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104381 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104382 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104383 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104384 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104385 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104386 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104387 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104388 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
104389 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104390 +validate_nnode_21638 validate_nnode 0 21638 NULL
104391 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
104392 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
104393 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104394 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104395 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
104396 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
104397 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104398 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
104399 +vm_brk_21739 vm_brk 1 21739 NULL
104400 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
104401 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104402 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
104403 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104404 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
104405 +min_odd_21802 min_odd 0 21802 NULL
104406 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104407 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104408 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104409 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
104410 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104411 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104412 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
104413 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
104414 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
104415 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
104416 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104417 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104418 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104419 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
104420 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104421 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104422 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104423 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104424 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104425 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104426 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104427 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104428 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104429 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
104430 +write_opcode_22082 write_opcode 2 22082 NULL
104431 +mem_rw_22085 mem_rw 3 22085 NULL
104432 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
104433 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
104434 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104435 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
104436 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
104437 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
104438 +compat_insn_22142 compat_insn 2 22142 NULL
104439 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104440 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
104441 +fls_22210 fls 0 22210 NULL
104442 +mem_write_22232 mem_write 3 22232 NULL
104443 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104444 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104445 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104446 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104447 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104448 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104449 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104450 +extend_brk_22301 extend_brk 0 22301 NULL
104451 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104452 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
104453 +get_segment_base_22324 get_segment_base 0 22324 NULL
104454 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
104455 +atomic_read_22342 atomic_read 0 22342 NULL
104456 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104457 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104458 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104459 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104460 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104461 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104462 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
104463 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
104464 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
104465 +zoran_write_22404 zoran_write 3 22404 NULL
104466 +queue_reply_22416 queue_reply 3 22416 NULL
104467 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104468 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104469 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104470 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104471 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
104472 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
104473 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
104474 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
104475 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
104476 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
104477 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
104478 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
104479 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
104480 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
104481 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
104482 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
104483 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
104484 +snapshot_read_22601 snapshot_read 3 22601 NULL
104485 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
104486 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
104487 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
104488 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
104489 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
104490 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
104491 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
104492 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
104493 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
104494 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
104495 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
104496 +map_22700 map 2 22700 NULL
104497 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
104498 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
104499 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
104500 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
104501 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
104502 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
104503 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
104504 +print_frame_22769 print_frame 0 22769 NULL
104505 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
104506 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
104507 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
104508 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
104509 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
104510 +create_attr_set_22861 create_attr_set 1 22861 NULL
104511 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
104512 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
104513 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
104514 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
104515 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
104516 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
104517 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
104518 +vme_get_size_22964 vme_get_size 0 22964 NULL
104519 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
104520 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
104521 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
104522 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
104523 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
104524 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
104525 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
104526 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
104527 +st_status_23032 st_status 5 23032 NULL
104528 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
104529 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
104530 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
104531 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
104532 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
104533 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
104534 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
104535 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
104536 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
104537 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
104538 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
104539 +fls_long_23096 fls_long 0 23096 NULL
104540 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
104541 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
104542 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
104543 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
104544 +__clear_user_23118 __clear_user 0 23118 NULL
104545 +dm_write_async_23120 dm_write_async 3 23120 NULL
104546 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
104547 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
104548 +read_file_ani_23161 read_file_ani 3 23161 NULL
104549 +ioremap_23172 ioremap 1-2 23172 NULL
104550 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
104551 +usblp_write_23178 usblp_write 3 23178 NULL
104552 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
104553 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
104554 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
104555 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
104556 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
104557 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
104558 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
104559 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
104560 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
104561 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
104562 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
104563 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
104564 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
104565 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
104566 +doc_probe_23285 doc_probe 1 23285 NULL
104567 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
104568 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
104569 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
104570 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
104571 +page_readlink_23346 page_readlink 3 23346 NULL
104572 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
104573 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
104574 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
104575 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
104576 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
104577 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
104578 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
104579 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
104580 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
104581 +event_filter_read_23494 event_filter_read 3 23494 NULL
104582 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
104583 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
104584 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
104585 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
104586 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
104587 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
104588 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
104589 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
104590 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
104591 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
104592 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
104593 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
104594 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
104595 +sInW_23663 sInW 0 23663 NULL
104596 +SyS_connect_23669 SyS_connect 3 23669 NULL
104597 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
104598 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
104599 +cx18_read_23699 cx18_read 3 23699 NULL
104600 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
104601 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
104602 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
104603 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
104604 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
104605 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
104606 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
104607 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
104608 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
104609 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
104610 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
104611 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
104612 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
104613 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
104614 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
104615 +p54_init_common_23850 p54_init_common 1 23850 NULL
104616 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
104617 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
104618 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
104619 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
104620 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
104621 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
104622 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
104623 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
104624 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
104625 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
104626 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
104627 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
104628 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
104629 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
104630 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
104631 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
104632 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
104633 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
104634 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
104635 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
104636 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
104637 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
104638 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
104639 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
104640 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
104641 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
104642 +mpu401_read_24126 mpu401_read 3 24126 NULL
104643 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
104644 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
104645 +set_discard_24162 set_discard 2 24162 NULL
104646 +adu_read_24177 adu_read 3 24177 NULL
104647 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
104648 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
104649 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
104650 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
104651 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
104652 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
104653 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
104654 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
104655 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
104656 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
104657 +thin_status_24278 thin_status 5 24278 NULL
104658 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
104659 +msg_size_24288 msg_size 0 24288 NULL
104660 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
104661 +map_page_24298 map_page 3-4 24298 NULL
104662 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
104663 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
104664 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
104665 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
104666 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
104667 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
104668 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
104669 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
104670 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
104671 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
104672 +igetword_24373 igetword 0 24373 NULL
104673 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
104674 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
104675 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
104676 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
104677 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
104678 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
104679 +smk_user_access_24440 smk_user_access 3 24440 NULL
104680 +page_address_24444 page_address 0 24444 NULL
104681 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
104682 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
104683 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
104684 +pd_video_read_24510 pd_video_read 3 24510 NULL
104685 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
104686 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
104687 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
104688 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
104689 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
104690 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
104691 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
104692 +count_preds_24600 count_preds 0 24600 NULL
104693 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
104694 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
104695 +context_alloc_24645 context_alloc 3 24645 NULL
104696 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
104697 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
104698 +read_fs_24717 read_fs 0 24717 NULL
104699 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
104700 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
104701 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
104702 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
104703 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
104704 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
104705 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
104706 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
104707 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
104708 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
104709 +cache_read_24790 cache_read 3 24790 NULL
104710 +unpack_str_24798 unpack_str 0 24798 NULL
104711 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
104712 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
104713 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
104714 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
104715 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
104716 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
104717 +setup_buffering_24872 setup_buffering 3 24872 NULL
104718 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
104719 +queues_read_24877 queues_read 3 24877 NULL nohasharray
104720 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
104721 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
104722 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
104723 +next_token_24929 next_token 0 24929 NULL
104724 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
104725 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
104726 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
104727 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
104728 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
104729 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
104730 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
104731 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
104732 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
104733 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
104734 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
104735 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
104736 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
104737 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
104738 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
104739 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
104740 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
104741 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
104742 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
104743 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
104744 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
104745 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
104746 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
104747 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
104748 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
104749 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
104750 +stripe_status_25259 stripe_status 5 25259 NULL
104751 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
104752 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
104753 +vfs_writev_25278 vfs_writev 3 25278 NULL
104754 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
104755 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
104756 +help_25316 help 5 25316 NULL nohasharray
104757 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
104758 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
104759 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
104760 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
104761 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
104762 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
104763 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
104764 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
104765 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
104766 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
104767 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
104768 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
104769 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
104770 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
104771 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
104772 +sb_permission_25523 sb_permission 0 25523 NULL
104773 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
104774 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
104775 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
104776 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
104777 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
104778 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
104779 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
104780 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
104781 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
104782 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
104783 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
104784 +__direct_map_25647 __direct_map 5-6 25647 NULL
104785 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
104786 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
104787 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
104788 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
104789 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
104790 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
104791 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
104792 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
104793 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
104794 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
104795 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
104796 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
104797 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
104798 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
104799 +sg_read_25799 sg_read 3 25799 NULL
104800 +system_enable_read_25815 system_enable_read 3 25815 NULL
104801 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
104802 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
104803 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
104804 +parport_read_25855 parport_read 0 25855 NULL
104805 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
104806 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
104807 +key_attr_size_25865 key_attr_size 0 25865 NULL
104808 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
104809 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
104810 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
104811 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
104812 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
104813 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
104814 +rcname_read_25919 rcname_read 3 25919 NULL
104815 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
104816 +key_flags_read_25931 key_flags_read 3 25931 NULL
104817 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
104818 +flush_25957 flush 2 25957 NULL
104819 +video_register_device_25971 video_register_device 3 25971 NULL
104820 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
104821 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
104822 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
104823 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
104824 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
104825 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
104826 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
104827 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
104828 +tun_do_read_26047 tun_do_read 5 26047 NULL
104829 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
104830 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
104831 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
104832 +skb_cow_26138 skb_cow 2 26138 NULL
104833 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
104834 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
104835 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
104836 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
104837 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
104838 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
104839 +disk_devt_26180 disk_devt 0 26180 NULL
104840 +get_registers_26187 get_registers 3 26187 NULL
104841 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
104842 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
104843 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
104844 +mce_write_26201 mce_write 3 26201 NULL
104845 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
104846 +bio_split_26235 bio_split 2 26235 NULL
104847 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
104848 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
104849 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
104850 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
104851 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
104852 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
104853 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
104854 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
104855 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
104856 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
104857 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
104858 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
104859 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
104860 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
104861 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
104862 +read_vmcore_26501 read_vmcore 3 26501 NULL
104863 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
104864 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
104865 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
104866 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
104867 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104868 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104869 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104870 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104871 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104872 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104873 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104874 +pack_value_26625 pack_value 1 26625 NULL
104875 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104876 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104877 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104878 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104879 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104880 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104881 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104882 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104883 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104884 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104885 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104886 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104887 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104888 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104889 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104890 +smk_write_load_26829 smk_write_load 3 26829 NULL
104891 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104892 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104893 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104894 +scnprint_id_26842 scnprint_id 3 26842 NULL
104895 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104896 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104897 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104898 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104899 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104900 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104901 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104902 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104903 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104904 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104905 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104906 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104907 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104908 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104909 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104910 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104911 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104912 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104913 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104914 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104915 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104916 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104917 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104918 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104919 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104920 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104921 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104922 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104923 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104924 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104925 +pms_capture_27142 pms_capture 4 27142 NULL
104926 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104927 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104928 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104929 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104930 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104931 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104932 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104933 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104934 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104935 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104936 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104937 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104938 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104939 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104940 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104941 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104942 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104943 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104944 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104945 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104946 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104947 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104948 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104949 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104950 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104951 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104952 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104953 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104954 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104955 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104956 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104957 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104958 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104959 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104960 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104961 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104962 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104963 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104964 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104965 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104966 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104967 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104968 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104969 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104970 +qword_get_27670 qword_get 0 27670 NULL
104971 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104972 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104973 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104974 +evm_write_key_27715 evm_write_key 3 27715 NULL
104975 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104976 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104977 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104978 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104979 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104980 +kcalloc_27770 kcalloc 1-2 27770 NULL
104981 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104982 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104983 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104984 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104985 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104986 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104987 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104988 +read_profile_27859 read_profile 3 27859 NULL
104989 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104990 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104991 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104992 +gluebi_write_27905 gluebi_write 3 27905 NULL
104993 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104994 +bm_find_next_27929 bm_find_next 2 27929 NULL
104995 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104996 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104997 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104998 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104999 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
105000 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
105001 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
105002 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
105003 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
105004 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
105005 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
105006 +pool_status_28055 pool_status 5 28055 NULL
105007 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
105008 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
105009 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
105010 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
105011 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
105012 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
105013 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
105014 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
105015 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
105016 +video_read_28148 video_read 3 28148 NULL
105017 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
105018 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
105019 +vread_28173 vread 0 28173 NULL
105020 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
105021 +d_path_28198 d_path 0 28198 NULL
105022 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
105023 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
105024 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
105025 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
105026 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
105027 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
105028 +usemap_size_28281 usemap_size 0 28281 NULL
105029 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
105030 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
105031 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
105032 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
105033 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
105034 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
105035 +snapshot_write_28351 snapshot_write 3 28351 NULL
105036 +sys_writev_28384 sys_writev 3 28384 NULL
105037 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
105038 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
105039 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
105040 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
105041 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
105042 +__split_large_page_28429 __split_large_page 2 28429 NULL
105043 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
105044 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
105045 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
105046 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
105047 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
105048 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
105049 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
105050 +max_response_pages_28492 max_response_pages 0 28492 NULL
105051 +clear_discard_28494 clear_discard 2 28494 NULL
105052 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
105053 +__next_node_28521 __next_node 1 28521 NULL
105054 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
105055 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
105056 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
105057 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
105058 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
105059 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
105060 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
105061 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
105062 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
105063 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
105064 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
105065 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
105066 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
105067 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
105068 +_set_range_28627 _set_range 3 28627 NULL
105069 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
105070 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
105071 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
105072 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
105073 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
105074 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
105075 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
105076 +spi_execute_28736 spi_execute 5 28736 NULL
105077 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
105078 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
105079 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
105080 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
105081 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
105082 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
105083 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
105084 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
105085 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
105086 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
105087 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
105088 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
105089 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
105090 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
105091 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
105092 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
105093 +to_cblock_28899 to_cblock 0-1 28899 NULL
105094 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
105095 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
105096 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
105097 +push_rx_28939 push_rx 3 28939 NULL
105098 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
105099 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
105100 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
105101 +bin_uuid_28999 bin_uuid 3 28999 NULL
105102 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
105103 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
105104 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
105105 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
105106 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
105107 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
105108 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
105109 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
105110 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
105111 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
105112 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
105113 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
105114 +snprintf_29125 snprintf 0 29125 NULL
105115 +iov_shorten_29130 iov_shorten 0 29130 NULL
105116 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
105117 +reshape_ring_29147 reshape_ring 2 29147 NULL
105118 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
105119 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
105120 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
105121 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
105122 +__mm_populate_29204 __mm_populate 1 29204 NULL
105123 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
105124 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
105125 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
105126 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
105127 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
105128 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
105129 +recover_peb_29238 recover_peb 6-7 29238 NULL
105130 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
105131 +block_div_29268 block_div 0-1-2 29268 NULL
105132 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
105133 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
105134 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
105135 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
105136 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
105137 +tun_put_user_29337 tun_put_user 5 29337 NULL
105138 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
105139 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
105140 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
105141 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
105142 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
105143 +mempool_create_29437 mempool_create 1 29437 NULL
105144 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
105145 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
105146 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
105147 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
105148 +do_register_entry_29478 do_register_entry 4 29478 NULL
105149 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
105150 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
105151 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
105152 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
105153 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
105154 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
105155 +set_brk_29551 set_brk 1 29551 NULL nohasharray
105156 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
105157 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
105158 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
105159 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
105160 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
105161 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
105162 +slots_per_page_29601 slots_per_page 0 29601 NULL
105163 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
105164 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
105165 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
105166 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
105167 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
105168 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
105169 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
105170 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
105171 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
105172 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
105173 +probes_write_29711 probes_write 3 29711 NULL
105174 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
105175 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
105176 +std_nic_write_29752 std_nic_write 3 29752 NULL
105177 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
105178 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
105179 +dbAlloc_29794 dbAlloc 0 29794 NULL
105180 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
105181 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
105182 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
105183 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
105184 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
105185 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
105186 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
105187 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
105188 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
105189 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
105190 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
105191 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
105192 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
105193 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
105194 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
105195 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
105196 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
105197 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
105198 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
105199 +drp_wmove_30043 drp_wmove 4 30043 NULL
105200 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
105201 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
105202 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
105203 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
105204 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
105205 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
105206 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
105207 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
105208 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
105209 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
105210 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
105211 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
105212 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
105213 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
105214 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
105215 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
105216 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
105217 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
105218 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
105219 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
105220 +compat_readv_30273 compat_readv 3 30273 NULL
105221 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
105222 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
105223 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
105224 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
105225 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
105226 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
105227 +resource_from_user_30341 resource_from_user 3 30341 NULL
105228 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
105229 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
105230 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
105231 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
105232 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
105233 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
105234 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
105235 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
105236 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
105237 +mq_create_30425 mq_create 1 30425 NULL
105238 +enable_write_30456 enable_write 3 30456 NULL
105239 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
105240 +urandom_read_30462 urandom_read 3 30462 NULL
105241 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
105242 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
105243 +write_head_30481 write_head 4 30481 NULL
105244 +adu_write_30487 adu_write 3 30487 NULL
105245 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
105246 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
105247 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
105248 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
105249 +set_le_30581 set_le 4 30581 NULL
105250 +from_cblock_30582 from_cblock 0-1 30582 NULL
105251 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
105252 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
105253 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
105254 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
105255 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
105256 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
105257 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
105258 +agp_remap_30665 agp_remap 2 30665 NULL
105259 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
105260 +il_free_pages_30692 il_free_pages 2 30692 NULL
105261 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
105262 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
105263 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
105264 +snapshot_status_30744 snapshot_status 5 30744 NULL
105265 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
105266 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
105267 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
105268 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
105269 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
105270 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
105271 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
105272 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
105273 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
105274 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
105275 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
105276 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
105277 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
105278 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
105279 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
105280 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
105281 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
105282 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
105283 +sys_mincore_31079 sys_mincore 1 31079 NULL
105284 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
105285 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
105286 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
105287 +depth_read_31112 depth_read 3 31112 NULL
105288 +ssb_read16_31139 ssb_read16 0 31139 NULL
105289 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
105290 +size_inside_page_31141 size_inside_page 0 31141 NULL
105291 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
105292 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
105293 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
105294 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
105295 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
105296 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
105297 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
105298 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
105299 +__read_reg_31216 __read_reg 0 31216 NULL
105300 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
105301 +cyy_readb_31240 cyy_readb 0 31240 NULL
105302 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
105303 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
105304 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
105305 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
105306 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
105307 +command_file_write_31318 command_file_write 3 31318 NULL
105308 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
105309 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
105310 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
105311 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
105312 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
105313 +inb_31388 inb 0 31388 NULL
105314 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
105315 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
105316 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
105317 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
105318 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
105319 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
105320 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
105321 +do_fcntl_31468 do_fcntl 3 31468 NULL
105322 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
105323 +alg_setkey_31485 alg_setkey 3 31485 NULL
105324 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
105325 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
105326 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
105327 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
105328 +hidraw_write_31536 hidraw_write 3 31536 NULL
105329 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
105330 +usbvision_read_31555 usbvision_read 3 31555 NULL
105331 +normalize_31566 normalize 0-1-2 31566 NULL
105332 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
105333 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
105334 +osst_write_31581 osst_write 3 31581 NULL
105335 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
105336 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
105337 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
105338 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
105339 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
105340 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
105341 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
105342 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
105343 +__lgread_31668 __lgread 4 31668 NULL
105344 +symbol_string_31670 symbol_string 0 31670 NULL
105345 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
105346 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
105347 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
105348 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
105349 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
105350 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
105351 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
105352 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
105353 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
105354 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
105355 +muldiv64_31743 muldiv64 2-3 31743 NULL
105356 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
105357 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
105358 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
105359 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
105360 +get_count_order_31800 get_count_order 0 31800 NULL
105361 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
105362 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
105363 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
105364 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
105365 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
105366 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
105367 +xattr_permission_31907 xattr_permission 0 31907 NULL
105368 +new_dir_31919 new_dir 3 31919 NULL
105369 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
105370 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
105371 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
105372 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
105373 +vb2_write_31948 vb2_write 3 31948 NULL
105374 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
105375 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
105376 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
105377 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
105378 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
105379 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
105380 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
105381 +calc_hmac_32010 calc_hmac 3 32010 NULL
105382 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
105383 +aead_len_32021 aead_len 0 32021 NULL
105384 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
105385 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
105386 +stk_read_32038 stk_read 3 32038 NULL
105387 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
105388 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
105389 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
105390 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
105391 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
105392 +bio_alloc_32095 bio_alloc 2 32095 NULL
105393 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
105394 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
105395 +disk_status_32120 disk_status 4 32120 NULL
105396 +venus_link_32165 venus_link 5 32165 NULL
105397 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
105398 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
105399 +load_header_32183 load_header 0 32183 NULL
105400 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
105401 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
105402 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
105403 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
105404 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
105405 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
105406 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
105407 +hex_string_32310 hex_string 0 32310 NULL
105408 +SyS_select_32319 SyS_select 1 32319 NULL
105409 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
105410 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
105411 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
105412 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
105413 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
105414 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
105415 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
105416 +local_clock_32385 local_clock 0 32385 NULL
105417 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
105418 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
105419 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
105420 +log_text_32428 log_text 0 32428 NULL
105421 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
105422 +hid_input_report_32458 hid_input_report 4 32458 NULL
105423 +cache_status_32462 cache_status 5 32462 NULL
105424 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
105425 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
105426 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
105427 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
105428 +disconnect_32521 disconnect 4 32521 NULL
105429 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
105430 +ilo_read_32531 ilo_read 3 32531 NULL
105431 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
105432 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
105433 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
105434 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
105435 +__first_node_32558 __first_node 0 32558 NULL
105436 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
105437 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
105438 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
105439 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
105440 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
105441 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
105442 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
105443 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
105444 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
105445 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
105446 +kvmalloc_32646 kvmalloc 1 32646 NULL
105447 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
105448 +generic_readlink_32654 generic_readlink 3 32654 NULL
105449 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
105450 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
105451 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
105452 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
105453 +get_arg_page_32746 get_arg_page 2 32746 NULL
105454 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
105455 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
105456 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
105457 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
105458 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
105459 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
105460 +vga_rseq_32848 vga_rseq 0 32848 NULL
105461 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
105462 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
105463 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
105464 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
105465 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
105466 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
105467 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
105468 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
105469 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
105470 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
105471 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
105472 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
105473 +compat_filldir_32999 compat_filldir 3 32999 NULL
105474 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
105475 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
105476 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
105477 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
105478 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
105479 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
105480 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
105481 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
105482 +alloc_tio_33077 alloc_tio 3 33077 NULL
105483 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
105484 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
105485 +write_node_33121 write_node 4 33121 NULL
105486 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
105487 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
105488 +__len_within_target_33132 __len_within_target 0 33132 NULL
105489 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
105490 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
105491 +pp_read_33210 pp_read 3 33210 NULL
105492 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
105493 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
105494 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
105495 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
105496 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
105497 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
105498 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
105499 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
105500 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
105501 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
105502 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
105503 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
105504 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
105505 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
105506 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
105507 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
105508 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
105509 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
105510 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
105511 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
105512 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
105513 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
105514 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
105515 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
105516 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
105517 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
105518 +create_entry_33479 create_entry 2 33479 NULL
105519 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
105520 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
105521 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
105522 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
105523 +res_counter_read_33499 res_counter_read 4 33499 NULL
105524 +fb_read_33506 fb_read 3 33506 NULL
105525 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
105526 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
105527 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
105528 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
105529 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
105530 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
105531 +dup_array_33551 dup_array 3 33551 NULL
105532 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
105533 +count_subheaders_33591 count_subheaders 0 33591 NULL
105534 +scsi_execute_33596 scsi_execute 5 33596 NULL
105535 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
105536 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
105537 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
105538 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
105539 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
105540 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
105541 +inw_p_33668 inw_p 0 33668 NULL
105542 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
105543 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
105544 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
105545 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
105546 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
105547 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
105548 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
105549 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
105550 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
105551 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
105552 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
105553 +Read_hfc_33755 Read_hfc 0 33755 NULL
105554 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
105555 +hashtab_create_33769 hashtab_create 3 33769 NULL
105556 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
105557 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
105558 +find_next_offset_33804 find_next_offset 3 33804 NULL
105559 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
105560 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
105561 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
105562 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
105563 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
105564 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
105565 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
105566 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
105567 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
105568 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
105569 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
105570 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
105571 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
105572 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
105573 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
105574 +ppp_write_34034 ppp_write 3 34034 NULL
105575 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
105576 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
105577 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
105578 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
105579 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
105580 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
105581 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
105582 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
105583 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
105584 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
105585 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
105586 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
105587 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
105588 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
105589 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
105590 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
105591 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
105592 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
105593 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
105594 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
105595 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
105596 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
105597 +__insert_34349 __insert 2-3 34349 NULL
105598 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
105599 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
105600 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
105601 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
105602 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
105603 +ea_read_34378 ea_read 0 34378 NULL
105604 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
105605 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
105606 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
105607 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
105608 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
105609 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
105610 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
105611 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
105612 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
105613 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
105614 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
105615 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
105616 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
105617 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
105618 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
105619 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
105620 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
105621 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
105622 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
105623 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
105624 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
105625 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
105626 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
105627 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
105628 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
105629 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
105630 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
105631 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
105632 +port_print_34704 port_print 3 34704 NULL
105633 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
105634 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
105635 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
105636 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
105637 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
105638 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
105639 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
105640 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
105641 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
105642 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
105643 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
105644 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
105645 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
105646 +msg_print_text_34889 msg_print_text 0 34889 NULL
105647 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
105648 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
105649 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
105650 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
105651 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
105652 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
105653 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
105654 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
105655 +Realloc_34961 Realloc 2 34961 NULL
105656 +mq_lookup_34990 mq_lookup 2 34990 NULL
105657 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
105658 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
105659 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
105660 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
105661 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
105662 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
105663 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
105664 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
105665 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
105666 +store_ifalias_35088 store_ifalias 4 35088 NULL
105667 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
105668 +capi_write_35104 capi_write 3 35104 NULL nohasharray
105669 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
105670 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
105671 +pointer_35138 pointer 0 35138 NULL
105672 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
105673 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
105674 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
105675 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
105676 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
105677 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
105678 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
105679 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
105680 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
105681 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
105682 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
105683 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
105684 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
105685 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
105686 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
105687 +set_fd_set_35249 set_fd_set 1 35249 NULL
105688 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
105689 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
105690 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
105691 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
105692 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
105693 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
105694 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
105695 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
105696 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
105697 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
105698 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
105699 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
105700 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
105701 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
105702 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
105703 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
105704 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
105705 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
105706 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
105707 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
105708 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
105709 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
105710 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
105711 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
105712 +async_setkey_35521 async_setkey 3 35521 NULL
105713 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
105714 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
105715 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
105716 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
105717 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
105718 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
105719 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
105720 +ReadZReg_35604 ReadZReg 0 35604 NULL
105721 +kernel_readv_35617 kernel_readv 3 35617 NULL
105722 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
105723 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
105724 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
105725 +store_debug_level_35652 store_debug_level 3 35652 NULL
105726 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
105727 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
105728 +dm_table_create_35687 dm_table_create 3 35687 NULL
105729 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
105730 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
105731 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
105732 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
105733 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
105734 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
105735 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
105736 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
105737 +fls64_35862 fls64 0 35862 NULL
105738 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
105739 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
105740 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
105741 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
105742 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
105743 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
105744 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
105745 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
105746 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
105747 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
105748 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
105749 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
105750 +acl_alloc_35979 acl_alloc 1 35979 NULL
105751 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
105752 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
105753 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
105754 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
105755 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
105756 +account_shadowed_36048 account_shadowed 2 36048 NULL
105757 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
105758 +write_emulate_36065 write_emulate 2-4 36065 NULL
105759 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
105760 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
105761 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
105762 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
105763 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
105764 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
105765 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
105766 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
105767 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
105768 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
105769 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
105770 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
105771 +twl_set_36154 twl_set 2 36154 NULL
105772 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
105773 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
105774 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
105775 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
105776 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
105777 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
105778 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
105779 +is_dirty_36223 is_dirty 2 36223 NULL
105780 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
105781 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
105782 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
105783 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
105784 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
105785 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
105786 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
105787 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
105788 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
105789 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
105790 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
105791 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
105792 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
105793 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
105794 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
105795 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
105796 +lc_create_36332 lc_create 4 36332 NULL
105797 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
105798 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
105799 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
105800 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
105801 +to_sector_36361 to_sector 0-1 36361 NULL
105802 +tunables_read_36385 tunables_read 3 36385 NULL
105803 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
105804 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
105805 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
105806 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
105807 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
105808 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
105809 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
105810 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
105811 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
105812 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
105813 +get_param_l_36518 get_param_l 0 36518 NULL
105814 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
105815 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
105816 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
105817 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
105818 +get_entry_len_36549 get_entry_len 0 36549 NULL
105819 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
105820 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
105821 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
105822 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
105823 +__erst_read_36579 __erst_read 0 36579 NULL
105824 +put_cmsg_36589 put_cmsg 4 36589 NULL
105825 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
105826 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
105827 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
105828 +format_decode_36638 format_decode 0 36638 NULL
105829 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
105830 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
105831 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
105832 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
105833 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
105834 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
105835 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
105836 +sched_clock_36717 sched_clock 0 36717 NULL
105837 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
105838 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
105839 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
105840 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
105841 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
105842 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
105843 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
105844 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
105845 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
105846 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
105847 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
105848 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
105849 +cm_write_36858 cm_write 3 36858 NULL
105850 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
105851 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
105852 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
105853 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
105854 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
105855 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
105856 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
105857 +build_key_36931 build_key 1 36931 NULL
105858 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
105859 +write_leb_36957 write_leb 5 36957 NULL
105860 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
105861 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
105862 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
105863 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
105864 +setxattr_37006 setxattr 4 37006 NULL
105865 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
105866 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
105867 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105868 +parse_command_37079 parse_command 2 37079 NULL
105869 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105870 +tun_get_user_37094 tun_get_user 5 37094 NULL
105871 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105872 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105873 +msg_word_37164 msg_word 0 37164 NULL
105874 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105875 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105876 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105877 +__do_replace_37227 __do_replace 5 37227 NULL
105878 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105879 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105880 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105881 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105882 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105883 +c101_run_37279 c101_run 2 37279 NULL
105884 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105885 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105886 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105887 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105888 +send_msg_37323 send_msg 4 37323 NULL
105889 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105890 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105891 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105892 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105893 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105894 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105895 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105896 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105897 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105898 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105899 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105900 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105901 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105902 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105903 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105904 +__remove_37457 __remove 2 37457 NULL
105905 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105906 +get_est_timing_37484 get_est_timing 0 37484 NULL
105907 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105908 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105909 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105910 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105911 +hdr_size_37536 hdr_size 0 37536 NULL
105912 +a2p_37544 a2p 0-1 37544 NULL
105913 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105914 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105915 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105916 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105917 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105918 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105919 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105920 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105921 +check_pt_base_37635 check_pt_base 3 37635 NULL
105922 +alloc_fd_37637 alloc_fd 1 37637 NULL
105923 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105924 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105925 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105926 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105927 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105928 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105929 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105930 +nametbl_header_37698 nametbl_header 2 37698 NULL
105931 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105932 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105933 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105934 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105935 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105936 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105937 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105938 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105939 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105940 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105941 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105942 +deny_write_access_37813 deny_write_access 0 37813 NULL
105943 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105944 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105945 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105946 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105947 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105948 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105949 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105950 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105951 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105952 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105953 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105954 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105955 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105956 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105957 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105958 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105959 +vfs_readv_38011 vfs_readv 3 38011 NULL
105960 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105961 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105962 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105963 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105964 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105965 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105966 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105967 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105968 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105969 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105970 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105971 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105972 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105973 +ep0_read_38095 ep0_read 3 38095 NULL
105974 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105975 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105976 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105977 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105978 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105979 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105980 +cdev_add_38176 cdev_add 2-3 38176 NULL
105981 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105982 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105983 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105984 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105985 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105986 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105987 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105988 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105989 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105990 +from_dblock_38256 from_dblock 0-1 38256 NULL
105991 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105992 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105993 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105994 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105995 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105996 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105997 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105998 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105999 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
106000 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
106001 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
106002 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
106003 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
106004 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
106005 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
106006 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
106007 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
106008 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
106009 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
106010 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
106011 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
106012 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
106013 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
106014 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
106015 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
106016 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
106017 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
106018 +dev_names_read_38509 dev_names_read 3 38509 NULL
106019 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
106020 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
106021 +set_queue_count_38519 set_queue_count 0 38519 NULL
106022 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
106023 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
106024 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
106025 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
106026 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
106027 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
106028 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
106029 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
106030 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
106031 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
106032 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
106033 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
106034 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
106035 +cma_create_area_38642 cma_create_area 2 38642 NULL
106036 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
106037 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
106038 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
106039 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
106040 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
106041 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
106042 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
106043 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
106044 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
106045 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
106046 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
106047 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
106048 +udf_readpages_38761 udf_readpages 4 38761 NULL
106049 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
106050 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
106051 +err_decode_38804 err_decode 2 38804 NULL
106052 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
106053 +sys_select_38827 sys_select 1 38827 NULL
106054 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
106055 +direct_entry_38836 direct_entry 3 38836 NULL
106056 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
106057 +interfaces_38859 interfaces 2 38859 NULL
106058 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
106059 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
106060 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
106061 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
106062 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
106063 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
106064 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
106065 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
106066 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
106067 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
106068 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
106069 +udf_new_block_38999 udf_new_block 4 38999 NULL
106070 +get_nodes_39012 get_nodes 3 39012 NULL
106071 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
106072 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
106073 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
106074 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
106075 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
106076 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
106077 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
106078 +ea_foreach_39133 ea_foreach 0 39133 NULL
106079 +generic_permission_39150 generic_permission 0 39150 NULL
106080 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
106081 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
106082 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
106083 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
106084 +init_list_set_39188 init_list_set 2-3 39188 NULL
106085 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
106086 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
106087 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
106088 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
106089 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
106090 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
106091 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
106092 +drm_order_39244 drm_order 0 39244 NULL
106093 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
106094 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
106095 +__skb_cow_39254 __skb_cow 2 39254 NULL
106096 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
106097 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
106098 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
106099 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
106100 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
106101 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
106102 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
106103 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
106104 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
106105 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
106106 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
106107 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
106108 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
106109 +__send_to_port_39386 __send_to_port 3 39386 NULL
106110 +user_power_read_39414 user_power_read 3 39414 NULL
106111 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
106112 +sys_semop_39457 sys_semop 3 39457 NULL
106113 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
106114 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
106115 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
106116 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
106117 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
106118 +int_proc_write_39542 int_proc_write 3 39542 NULL
106119 +pp_write_39554 pp_write 3 39554 NULL
106120 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
106121 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
106122 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
106123 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
106124 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
106125 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
106126 +ext_depth_39607 ext_depth 0 39607 NULL
106127 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
106128 +sdio_readb_39618 sdio_readb 0 39618 NULL
106129 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
106130 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
106131 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
106132 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
106133 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
106134 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
106135 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
106136 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
106137 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
106138 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
106139 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
106140 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
106141 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
106142 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
106143 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
106144 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
106145 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
106146 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
106147 +pkt_add_39897 pkt_add 3 39897 NULL
106148 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
106149 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
106150 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
106151 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
106152 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
106153 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
106154 +__spi_async_39932 __spi_async 0 39932 NULL
106155 +__get_order_39935 __get_order 0 39935 NULL
106156 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
106157 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
106158 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
106159 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
106160 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
106161 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
106162 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
106163 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
106164 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
106165 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
106166 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
106167 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
106168 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
106169 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
106170 +add_tty_40055 add_tty 1 40055 NULL nohasharray
106171 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
106172 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
106173 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
106174 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
106175 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
106176 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
106177 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
106178 +pt_write_40159 pt_write 3 40159 NULL
106179 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
106180 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
106181 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
106182 +allocate_probes_40204 allocate_probes 1 40204 NULL
106183 +compat_put_long_40214 compat_put_long 1 40214 NULL
106184 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
106185 +osst_read_40237 osst_read 3 40237 NULL
106186 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
106187 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
106188 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
106189 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
106190 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
106191 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
106192 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
106193 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
106194 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
106195 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
106196 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
106197 +mmio_read_40348 mmio_read 4 40348 NULL
106198 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
106199 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
106200 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
106201 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
106202 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
106203 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
106204 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
106205 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
106206 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
106207 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
106208 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
106209 +tty_write_room_40495 tty_write_room 0 40495 NULL
106210 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
106211 +sg_phys_40507 sg_phys 0 40507 NULL
106212 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
106213 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
106214 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
106215 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
106216 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
106217 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
106218 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
106219 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
106220 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
106221 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
106222 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
106223 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
106224 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
106225 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
106226 +fops_read_40672 fops_read 3 40672 NULL
106227 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
106228 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
106229 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
106230 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
106231 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
106232 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
106233 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
106234 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
106235 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
106236 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
106237 +card_send_command_40757 card_send_command 3 40757 NULL
106238 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
106239 +pg_write_40766 pg_write 3 40766 NULL
106240 +show_list_40775 show_list 3 40775 NULL
106241 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
106242 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
106243 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
106244 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
106245 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
106246 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
106247 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
106248 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
106249 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
106250 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
106251 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
106252 +read_file_queue_40895 read_file_queue 3 40895 NULL
106253 +waiters_read_40902 waiters_read 3 40902 NULL
106254 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
106255 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
106256 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
106257 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
106258 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
106259 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
106260 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
106261 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
106262 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
106263 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
106264 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
106265 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
106266 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
106267 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
106268 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
106269 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
106270 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
106271 +dma_attach_41094 dma_attach 5-6 41094 NULL
106272 +provide_user_output_41105 provide_user_output 3 41105 NULL
106273 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
106274 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
106275 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
106276 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
106277 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
106278 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
106279 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
106280 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
106281 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
106282 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
106283 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
106284 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
106285 +erst_read_41260 erst_read 0 41260 NULL
106286 +__fprog_create_41263 __fprog_create 2 41263 NULL
106287 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
106288 +alloc_context_41283 alloc_context 1 41283 NULL
106289 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
106290 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
106291 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
106292 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
106293 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
106294 +kmp_init_41373 kmp_init 2 41373 NULL
106295 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
106296 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
106297 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
106298 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
106299 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
106300 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
106301 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
106302 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
106303 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
106304 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
106305 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
106306 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
106307 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
106308 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
106309 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
106310 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
106311 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
106312 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
106313 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
106314 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
106315 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
106316 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
106317 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
106318 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
106319 +vga_io_r_41609 vga_io_r 0 41609 NULL
106320 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
106321 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
106322 +a2mp_send_41615 a2mp_send 4 41615 NULL
106323 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
106324 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
106325 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
106326 +get_std_timing_41654 get_std_timing 0 41654 NULL
106327 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
106328 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
106329 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
106330 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
106331 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
106332 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
106333 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
106334 +fillonedir_41746 fillonedir 3 41746 NULL
106335 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
106336 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
106337 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
106338 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
106339 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
106340 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
106341 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
106342 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
106343 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
106344 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
106345 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
106346 +get_packet_41914 get_packet 3 41914 NULL
106347 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
106348 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
106349 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
106350 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
106351 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
106352 +read_gssp_41947 read_gssp 3 41947 NULL
106353 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
106354 +portnames_read_41958 portnames_read 3 41958 NULL
106355 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
106356 +dst_mtu_41969 dst_mtu 0 41969 NULL
106357 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
106358 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
106359 +lguest_map_42008 lguest_map 1-2 42008 NULL
106360 +pool_allocate_42012 pool_allocate 3 42012 NULL
106361 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
106362 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
106363 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
106364 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
106365 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
106366 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
106367 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
106368 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
106369 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
106370 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
106371 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
106372 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
106373 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
106374 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
106375 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
106376 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
106377 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
106378 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
106379 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
106380 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
106381 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
106382 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
106383 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
106384 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
106385 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
106386 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
106387 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
106388 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
106389 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
106390 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
106391 +free_cblock_42318 free_cblock 2 42318 NULL
106392 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
106393 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
106394 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
106395 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
106396 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
106397 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
106398 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
106399 +krng_get_random_42420 krng_get_random 3 42420 NULL
106400 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
106401 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
106402 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
106403 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
106404 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
106405 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
106406 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
106407 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
106408 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
106409 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
106410 +bypass_write_42498 bypass_write 3 42498 NULL
106411 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
106412 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
106413 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
106414 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
106415 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
106416 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
106417 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
106418 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
106419 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
106420 +map_state_42602 map_state 1 42602 NULL nohasharray
106421 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
106422 +nd_get_link_42603 nd_get_link 0 42603 NULL
106423 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
106424 +resp_write_42628 resp_write 2 42628 NULL
106425 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
106426 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
106427 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
106428 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
106429 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
106430 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
106431 +vb2_read_42703 vb2_read 3 42703 NULL
106432 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
106433 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
106434 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
106435 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
106436 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
106437 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
106438 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
106439 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
106440 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
106441 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
106442 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
106443 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
106444 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
106445 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
106446 +set_arg_42824 set_arg 3 42824 NULL
106447 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
106448 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
106449 +prandom_u32_42853 prandom_u32 0 42853 NULL
106450 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
106451 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
106452 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
106453 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
106454 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
106455 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
106456 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
106457 +hd_end_request_42904 hd_end_request 2 42904 NULL
106458 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
106459 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
106460 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
106461 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
106462 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
106463 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
106464 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
106465 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
106466 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
106467 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
106468 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
106469 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
106470 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
106471 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
106472 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
106473 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
106474 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
106475 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
106476 +uuid_string_43154 uuid_string 0 43154 NULL
106477 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
106478 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
106479 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
106480 +process_measurement_43190 process_measurement 0 43190 NULL
106481 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
106482 +uio_write_43202 uio_write 3 43202 NULL
106483 +iso_callback_43208 iso_callback 3 43208 NULL
106484 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
106485 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
106486 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
106487 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
106488 +fixup_leb_43256 fixup_leb 3 43256 NULL
106489 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
106490 +evtchn_write_43278 evtchn_write 3 43278 NULL
106491 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
106492 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
106493 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
106494 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
106495 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
106496 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
106497 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
106498 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
106499 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
106500 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
106501 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
106502 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
106503 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
106504 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
106505 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
106506 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
106507 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
106508 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
106509 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
106510 +do_readlink_43518 do_readlink 2 43518 NULL
106511 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
106512 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
106513 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
106514 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
106515 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
106516 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
106517 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
106518 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
106519 +proc_read_43614 proc_read 3 43614 NULL
106520 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
106521 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
106522 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
106523 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
106524 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
106525 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
106526 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
106527 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
106528 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
106529 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
106530 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
106531 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
106532 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
106533 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
106534 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
106535 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
106536 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
106537 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
106538 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
106539 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
106540 +read_flush_43851 read_flush 3 43851 NULL
106541 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
106542 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
106543 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
106544 +SendString_43928 SendString 3 43928 NULL
106545 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
106546 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
106547 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
106548 +nla_reserve_43984 nla_reserve 3 43984 NULL
106549 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
106550 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
106551 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
106552 +emit_flags_44006 emit_flags 4-3 44006 NULL
106553 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
106554 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
106555 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
106556 +load_discard_44083 load_discard 3 44083 NULL
106557 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
106558 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
106559 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
106560 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
106561 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
106562 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
106563 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
106564 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
106565 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
106566 +__set_free_44211 __set_free 2 44211 NULL
106567 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
106568 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
106569 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
106570 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
106571 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
106572 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
106573 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
106574 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
106575 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
106576 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
106577 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
106578 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
106579 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
106580 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
106581 +__is_discarded_44359 __is_discarded 2 44359 NULL
106582 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
106583 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
106584 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
106585 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
106586 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
106587 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
106588 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
106589 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
106590 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
106591 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
106592 +bio_advance_44496 bio_advance 2 44496 NULL
106593 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
106594 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
106595 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
106596 +spidev_write_44510 spidev_write 3 44510 NULL
106597 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
106598 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
106599 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
106600 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
106601 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
106602 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
106603 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
106604 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
106605 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
106606 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
106607 +mpi_resize_44674 mpi_resize 2 44674 NULL
106608 +ts_read_44687 ts_read 3 44687 NULL
106609 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
106610 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
106611 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
106612 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
106613 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
106614 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
106615 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
106616 +set_brk_44749 set_brk 1 44749 NULL
106617 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
106618 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
106619 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
106620 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
106621 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
106622 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
106623 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
106624 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
106625 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
106626 +sisusb_write_44834 sisusb_write 3 44834 NULL
106627 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
106628 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
106629 +cubic_root_44848 cubic_root 1 44848 NULL
106630 +copydesc_user_44855 copydesc_user 3 44855 NULL
106631 +skb_availroom_44883 skb_availroom 0 44883 NULL
106632 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
106633 +do_tty_write_44896 do_tty_write 5 44896 NULL
106634 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
106635 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
106636 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
106637 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
106638 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
106639 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
106640 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
106641 +sel_write_user_45060 sel_write_user 3 45060 NULL
106642 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
106643 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
106644 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
106645 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
106646 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
106647 +usbdev_read_45114 usbdev_read 3 45114 NULL
106648 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
106649 +send_to_tty_45141 send_to_tty 3 45141 NULL
106650 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
106651 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
106652 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
106653 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
106654 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
106655 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
106656 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
106657 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
106658 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
106659 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
106660 +add_child_45201 add_child 4 45201 NULL
106661 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
106662 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
106663 +__dirty_45228 __dirty 2 45228 NULL
106664 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
106665 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
106666 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
106667 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
106668 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
106669 +pte_val_45313 pte_val 0 45313 NULL
106670 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
106671 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
106672 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
106673 +keymap_store_45406 keymap_store 4 45406 NULL
106674 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
106675 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
106676 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
106677 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
106678 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
106679 +__node_remap_45458 __node_remap 4 45458 NULL
106680 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
106681 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
106682 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
106683 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
106684 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
106685 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
106686 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
106687 +copy_macs_45534 copy_macs 4 45534 NULL
106688 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
106689 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
106690 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
106691 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
106692 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
106693 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
106694 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
106695 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
106696 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
106697 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
106698 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
106699 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
106700 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
106701 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
106702 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
106703 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
106704 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
106705 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
106706 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
106707 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
106708 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
106709 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
106710 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
106711 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
106712 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
106713 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
106714 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
106715 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
106716 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
106717 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
106718 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
106719 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
106720 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
106721 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
106722 +isdn_write_45863 isdn_write 3 45863 NULL
106723 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
106724 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
106725 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
106726 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
106727 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
106728 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
106729 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
106730 +alloc_mr_45935 alloc_mr 1 45935 NULL
106731 +split_large_page_45941 split_large_page 2 45941 NULL
106732 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
106733 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
106734 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
106735 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
106736 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
106737 +get_free_entries_46030 get_free_entries 1 46030 NULL
106738 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
106739 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
106740 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
106741 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
106742 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
106743 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
106744 +slhc_toss_46066 slhc_toss 0 46066 NULL
106745 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
106746 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
106747 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
106748 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
106749 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
106750 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
106751 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
106752 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
106753 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
106754 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
106755 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
106756 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
106757 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
106758 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
106759 +add_conn_list_46197 add_conn_list 3 46197 NULL
106760 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
106761 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
106762 +dsp_write_46218 dsp_write 2 46218 NULL
106763 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
106764 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
106765 +ReadReg_46277 ReadReg 0 46277 NULL
106766 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
106767 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
106768 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
106769 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
106770 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
106771 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
106772 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
106773 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
106774 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
106775 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
106776 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
106777 +filldir64_46469 filldir64 3 46469 NULL
106778 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
106779 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
106780 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
106781 +kmsg_read_46514 kmsg_read 3 46514 NULL
106782 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
106783 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
106784 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
106785 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
106786 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
106787 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
106788 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
106789 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
106790 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
106791 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
106792 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
106793 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
106794 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
106795 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
106796 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
106797 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
106798 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
106799 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
106800 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
106801 +prepare_copy_46725 prepare_copy 2 46725 NULL
106802 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
106803 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
106804 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
106805 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
106806 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
106807 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
106808 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
106809 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
106810 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
106811 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
106812 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
106813 +spi_async_46857 spi_async 0 46857 NULL
106814 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
106815 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
106816 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
106817 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
106818 +rvmalloc_46873 rvmalloc 1 46873 NULL
106819 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
106820 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
106821 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
106822 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
106823 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
106824 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
106825 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
106826 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
106827 +fb_write_46924 fb_write 3 46924 NULL
106828 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
106829 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
106830 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
106831 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
106832 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
106833 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
106834 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
106835 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
106836 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
106837 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
106838 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
106839 +__map_single_47020 __map_single 3-4-7 47020 NULL
106840 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
106841 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
106842 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
106843 +fs_path_len_47060 fs_path_len 0 47060 NULL
106844 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
106845 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
106846 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
106847 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
106848 +mousedev_read_47123 mousedev_read 3 47123 NULL
106849 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
106850 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
106851 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
106852 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
106853 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
106854 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
106855 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
106856 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
106857 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
106858 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
106859 +l2headersize_47238 l2headersize 0 47238 NULL
106860 +options_write_47243 options_write 3 47243 NULL
106861 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
106862 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
106863 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
106864 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
106865 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
106866 +vsnprintf_47291 vsnprintf 0 47291 NULL
106867 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106868 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106869 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106870 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106871 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106872 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106873 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106874 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106875 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106876 +nametbl_list_47391 nametbl_list 2 47391 NULL
106877 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106878 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106879 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106880 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106881 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106882 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106883 +vzalloc_47421 vzalloc 1 47421 NULL
106884 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106885 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106886 +__load_mapping_47460 __load_mapping 2 47460 NULL
106887 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106888 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106889 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106890 +core_sys_select_47494 core_sys_select 1 47494 NULL
106891 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106892 +unlink_simple_47506 unlink_simple 3 47506 NULL
106893 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106894 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106895 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106896 +oz_events_read_47535 oz_events_read 3 47535 NULL
106897 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106898 +read_ldt_47570 read_ldt 2 47570 NULL
106899 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106900 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106901 +pci_iomap_47575 pci_iomap 3 47575 NULL
106902 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106903 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106904 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106905 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106906 +uea_request_47613 uea_request 4 47613 NULL
106907 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106908 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106909 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106910 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106911 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106912 +save_microcode_47717 save_microcode 3 47717 NULL
106913 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106914 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106915 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106916 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106917 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106918 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106919 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106920 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106921 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106922 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106923 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106924 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106925 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106926 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106927 +vhci_read_47878 vhci_read 3 47878 NULL
106928 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106929 +load_mapping_47904 load_mapping 3 47904 NULL
106930 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106931 +comedi_write_47926 comedi_write 3 47926 NULL
106932 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106933 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106934 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106935 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106936 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106937 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106938 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106939 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106940 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106941 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106942 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106943 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106944 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106945 +disc_write_48070 disc_write 3 48070 NULL
106946 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106947 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106948 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106949 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106950 +set_discoverable_48141 set_discoverable 4 48141 NULL
106951 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106952 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106953 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106954 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106955 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106956 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106957 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106958 +init_ipath_48187 init_ipath 1 48187 NULL
106959 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106960 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106961 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106962 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106963 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106964 +read_file_recv_48232 read_file_recv 3 48232 NULL
106965 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106966 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106967 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106968 +send_set_info_48288 send_set_info 7 48288 NULL
106969 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106970 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106971 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106972 +hash_setkey_48310 hash_setkey 3 48310 NULL
106973 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106974 +skb_add_data_48363 skb_add_data 3 48363 NULL
106975 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106976 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106977 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106978 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106979 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106980 +print_filtered_48442 print_filtered 2-0 48442 NULL
106981 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106982 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106983 +send_control_msg_48498 send_control_msg 6 48498 NULL
106984 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106985 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106986 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106987 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106988 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106989 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106990 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106991 +named_distribute_48544 named_distribute 4 48544 NULL
106992 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106993 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106994 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106995 +mtd_read_48655 mtd_read 0 48655 NULL
106996 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106997 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106998 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106999 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
107000 +altera_drscan_48698 altera_drscan 2 48698 NULL
107001 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
107002 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
107003 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
107004 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
107005 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
107006 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
107007 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
107008 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
107009 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
107010 +azx_get_position_48841 azx_get_position 0 48841 NULL
107011 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
107012 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
107013 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
107014 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
107015 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
107016 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
107017 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
107018 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
107019 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
107020 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
107021 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
107022 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
107023 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
107024 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
107025 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
107026 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
107027 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
107028 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
107029 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
107030 +transient_status_49027 transient_status 4 49027 NULL
107031 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
107032 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
107033 +ubi_read_49061 ubi_read 0 49061 NULL
107034 +scsi_register_49094 scsi_register 2 49094 NULL
107035 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
107036 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
107037 +check_exists_49119 check_exists 2 49119 NULL nohasharray
107038 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
107039 +pt_read_49136 pt_read 3 49136 NULL
107040 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
107041 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
107042 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
107043 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
107044 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
107045 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
107046 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
107047 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
107048 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
107049 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
107050 +resp_write_same_49217 resp_write_same 2 49217 NULL
107051 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
107052 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
107053 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
107054 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
107055 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
107056 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
107057 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
107058 +uio_read_49300 uio_read 3 49300 NULL
107059 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
107060 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
107061 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
107062 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
107063 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
107064 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
107065 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
107066 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
107067 +px_raw_event_49371 px_raw_event 4 49371 NULL
107068 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
107069 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
107070 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
107071 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
107072 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
107073 +md_domain_init_49432 md_domain_init 2 49432 NULL
107074 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
107075 +get_lru_size_49441 get_lru_size 0 49441 NULL
107076 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
107077 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
107078 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
107079 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
107080 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
107081 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
107082 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
107083 +smk_write_access_49561 smk_write_access 3 49561 NULL
107084 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
107085 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
107086 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
107087 +tap_write_49595 tap_write 3 49595 NULL
107088 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
107089 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
107090 +heap_init_49617 heap_init 2 49617 NULL
107091 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
107092 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
107093 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
107094 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
107095 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
107096 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
107097 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
107098 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
107099 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
107100 +check_frame_49741 check_frame 0 49741 NULL
107101 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
107102 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
107103 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
107104 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
107105 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
107106 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
107107 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
107108 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
107109 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
107110 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
107111 +add_uuid_49831 add_uuid 4 49831 NULL
107112 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
107113 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
107114 +twl4030_write_49846 twl4030_write 2 49846 NULL
107115 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
107116 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
107117 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
107118 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
107119 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
107120 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
107121 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
107122 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
107123 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
107124 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
107125 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
107126 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
107127 +__module_alloc_50004 __module_alloc 1 50004 NULL
107128 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
107129 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
107130 +isdn_read_50021 isdn_read 3 50021 NULL
107131 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
107132 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
107133 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
107134 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
107135 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
107136 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
107137 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
107138 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
107139 +read_file_slot_50111 read_file_slot 3 50111 NULL
107140 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
107141 +copy_items_50140 copy_items 6 50140 NULL
107142 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
107143 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
107144 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
107145 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
107146 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
107147 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
107148 +odev_update_50169 odev_update 2 50169 NULL
107149 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
107150 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
107151 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
107152 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
107153 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
107154 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
107155 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
107156 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
107157 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
107158 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
107159 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
107160 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
107161 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
107162 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
107163 +do_launder_page_50329 do_launder_page 0 50329 NULL
107164 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
107165 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
107166 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
107167 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
107168 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
107169 +tpm_read_50344 tpm_read 3 50344 NULL
107170 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
107171 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
107172 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
107173 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
107174 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
107175 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
107176 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
107177 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
107178 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
107179 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
107180 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
107181 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
107182 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
107183 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
107184 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
107185 +force_mapping_50464 force_mapping 2 50464 NULL
107186 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
107187 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
107188 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
107189 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
107190 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
107191 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
107192 +fat_readpages_50582 fat_readpages 4 50582 NULL
107193 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
107194 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
107195 +sge_rx_50594 sge_rx 3 50594 NULL
107196 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
107197 +__ffs_50625 __ffs 0 50625 NULL
107198 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
107199 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
107200 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
107201 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
107202 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
107203 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
107204 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
107205 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
107206 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
107207 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
107208 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
107209 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
107210 +skb_padto_50759 skb_padto 2 50759 NULL
107211 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
107212 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
107213 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
107214 +tpm_write_50798 tpm_write 3 50798 NULL
107215 +write_flush_50803 write_flush 3 50803 NULL
107216 +dvb_play_50814 dvb_play 3 50814 NULL
107217 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
107218 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
107219 +SetArea_50835 SetArea 4 50835 NULL nohasharray
107220 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
107221 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
107222 +self_check_write_50856 self_check_write 5 50856 NULL
107223 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
107224 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
107225 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
107226 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
107227 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
107228 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
107229 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
107230 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
107231 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
107232 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
107233 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
107234 +timeout_write_50991 timeout_write 3 50991 NULL
107235 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
107236 +proc_write_51003 proc_write 3 51003 NULL
107237 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
107238 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
107239 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
107240 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
107241 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
107242 +dump_midi_51040 dump_midi 3 51040 NULL
107243 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
107244 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
107245 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
107246 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
107247 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
107248 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
107249 +ti_recv_51110 ti_recv 3 51110 NULL
107250 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
107251 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
107252 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
107253 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
107254 +set_dirty_51144 set_dirty 3 51144 NULL
107255 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
107256 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
107257 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
107258 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
107259 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
107260 +tipc_send_51238 tipc_send 4 51238 NULL
107261 +drm_property_create_51239 drm_property_create 4 51239 NULL
107262 +st_read_51251 st_read 3 51251 NULL
107263 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
107264 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
107265 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
107266 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
107267 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
107268 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
107269 +get_cell_51316 get_cell 2 51316 NULL
107270 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
107271 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
107272 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
107273 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
107274 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
107275 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
107276 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
107277 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
107278 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
107279 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
107280 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
107281 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
107282 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
107283 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
107284 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
107285 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
107286 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
107287 +vaddr_51480 vaddr 0 51480 NULL
107288 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
107289 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
107290 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
107291 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
107292 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
107293 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
107294 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
107295 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
107296 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
107297 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
107298 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
107299 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
107300 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
107301 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
107302 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
107303 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
107304 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
107305 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
107306 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
107307 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
107308 +sel_write_access_51704 sel_write_access 3 51704 NULL
107309 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
107310 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
107311 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
107312 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
107313 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
107314 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
107315 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
107316 +if_write_51756 if_write 3 51756 NULL
107317 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
107318 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
107319 +to_ratio_51809 to_ratio 2-1 51809 NULL
107320 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
107321 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
107322 +ioread32_51847 ioread32 0 51847 NULL nohasharray
107323 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
107324 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
107325 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
107326 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
107327 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
107328 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
107329 +user_read_51881 user_read 3 51881 NULL
107330 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
107331 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
107332 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
107333 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
107334 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
107335 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
107336 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
107337 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
107338 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
107339 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
107340 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
107341 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
107342 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
107343 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
107344 +rdmalt_52022 rdmalt 0 52022 NULL
107345 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
107346 +override_release_52032 override_release 2 52032 NULL
107347 +end_port_52042 end_port 0 52042 NULL
107348 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
107349 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
107350 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
107351 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
107352 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
107353 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
107354 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
107355 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
107356 +retry_count_read_52129 retry_count_read 3 52129 NULL
107357 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
107358 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
107359 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
107360 +htable_size_52148 htable_size 0-1 52148 NULL
107361 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
107362 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
107363 +alix_present_52165 alix_present 1 52165 NULL
107364 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
107365 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
107366 +print_prefix_52176 print_prefix 0 52176 NULL
107367 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
107368 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
107369 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
107370 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
107371 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
107372 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
107373 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
107374 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
107375 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
107376 +atomic64_read_52300 atomic64_read 0 52300 NULL
107377 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
107378 +read_file_reset_52310 read_file_reset 3 52310 NULL
107379 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
107380 +hwflags_read_52318 hwflags_read 3 52318 NULL
107381 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
107382 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
107383 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
107384 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
107385 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
107386 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
107387 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
107388 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
107389 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
107390 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
107391 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
107392 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
107393 +delay_status_52431 delay_status 5 52431 NULL
107394 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
107395 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
107396 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
107397 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
107398 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
107399 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
107400 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
107401 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
107402 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
107403 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
107404 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
107405 +from_oblock_52546 from_oblock 0-1 52546 NULL
107406 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
107407 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
107408 +emit_code_52583 emit_code 0-3 52583 NULL
107409 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
107410 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
107411 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
107412 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
107413 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
107414 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
107415 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
107416 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
107417 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
107418 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
107419 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
107420 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
107421 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
107422 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
107423 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
107424 +twlreg_write_52880 twlreg_write 3 52880 NULL
107425 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
107426 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
107427 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
107428 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
107429 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
107430 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
107431 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
107432 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
107433 +send_packet_52960 send_packet 4 52960 NULL
107434 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
107435 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
107436 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
107437 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
107438 +num_node_state_52989 num_node_state 0 52989 NULL
107439 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
107440 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
107441 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
107442 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
107443 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
107444 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
107445 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
107446 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
107447 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
107448 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
107449 +verity_status_53120 verity_status 5 53120 NULL
107450 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
107451 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
107452 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
107453 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
107454 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
107455 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
107456 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
107457 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
107458 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
107459 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
107460 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
107461 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
107462 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
107463 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
107464 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
107465 +vm_mmap_53339 vm_mmap 0 53339 NULL
107466 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
107467 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
107468 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
107469 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
107470 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
107471 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
107472 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
107473 +n2_run_53459 n2_run 3 53459 NULL
107474 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
107475 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
107476 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
107477 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
107478 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
107479 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
107480 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
107481 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
107482 +check_acl_53512 check_acl 0 53512 NULL
107483 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
107484 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
107485 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
107486 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
107487 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
107488 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
107489 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
107490 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
107491 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
107492 +_preload_range_53676 _preload_range 2-3 53676 NULL
107493 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
107494 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
107495 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
107496 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
107497 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
107498 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
107499 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
107500 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
107501 +wdm_write_53735 wdm_write 3 53735 NULL
107502 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
107503 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
107504 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
107505 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
107506 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
107507 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
107508 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
107509 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
107510 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
107511 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
107512 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
107513 +pms_read_53873 pms_read 3 53873 NULL
107514 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
107515 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
107516 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
107517 +proc_file_read_53905 proc_file_read 3 53905 NULL
107518 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
107519 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
107520 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
107521 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
107522 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
107523 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
107524 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
107525 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
107526 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
107527 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
107528 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
107529 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
107530 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
107531 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
107532 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
107533 +_malloc_54077 _malloc 1 54077 NULL
107534 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
107535 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
107536 +create_xattr_54106 create_xattr 5 54106 NULL
107537 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
107538 +strn_len_54122 strn_len 0 54122 NULL
107539 +isku_receive_54130 isku_receive 4 54130 NULL
107540 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
107541 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
107542 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
107543 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
107544 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
107545 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
107546 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
107547 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
107548 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
107549 +reada_add_block_54247 reada_add_block 2 54247 NULL
107550 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
107551 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
107552 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
107553 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
107554 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
107555 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
107556 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
107557 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
107558 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
107559 +sprintf_54306 sprintf 0 54306 NULL
107560 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
107561 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
107562 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
107563 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
107564 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
107565 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
107566 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
107567 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
107568 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
107569 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
107570 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
107571 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
107572 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
107573 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
107574 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
107575 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
107576 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
107577 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
107578 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
107579 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
107580 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
107581 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
107582 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
107583 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
107584 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
107585 +viacam_read_54526 viacam_read 3 54526 NULL
107586 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
107587 +setsockopt_54539 setsockopt 5 54539 NULL
107588 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
107589 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
107590 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
107591 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
107592 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
107593 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
107594 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
107595 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
107596 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
107597 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
107598 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
107599 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
107600 +evm_read_key_54674 evm_read_key 3 54674 NULL
107601 +resource_string_54699 resource_string 0 54699 NULL
107602 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
107603 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
107604 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
107605 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
107606 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
107607 +kzalloc_54740 kzalloc 1 54740 NULL
107608 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
107609 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
107610 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
107611 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
107612 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
107613 +domain_init_54797 domain_init 2 54797 NULL
107614 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
107615 +get_dev_size_54807 get_dev_size 0 54807 NULL
107616 +nfsd_write_54809 nfsd_write 6 54809 NULL
107617 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
107618 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
107619 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
107620 +write_rio_54837 write_rio 3 54837 NULL
107621 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
107622 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
107623 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
107624 +printer_read_54851 printer_read 3 54851 NULL
107625 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
107626 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
107627 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
107628 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
107629 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
107630 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
107631 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
107632 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
107633 +add_port_54941 add_port 2 54941 NULL
107634 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
107635 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
107636 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
107637 +c4_add_card_54968 c4_add_card 3 54968 NULL
107638 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
107639 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
107640 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
107641 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
107642 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
107643 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
107644 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
107645 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
107646 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
107647 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
107648 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
107649 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
107650 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
107651 +corrupt_data_55120 corrupt_data 0 55120 NULL
107652 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
107653 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
107654 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
107655 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
107656 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
107657 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
107658 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
107659 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
107660 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
107661 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
107662 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
107663 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
107664 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
107665 +dump_command_55220 dump_command 1 55220 NULL
107666 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
107667 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
107668 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
107669 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
107670 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
107671 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
107672 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
107673 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
107674 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
107675 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
107676 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
107677 +do_shmat_55336 do_shmat 5 55336 NULL
107678 +vme_user_read_55338 vme_user_read 3 55338 NULL
107679 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
107680 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
107681 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
107682 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
107683 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
107684 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
107685 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
107686 +alloc_skb_55439 alloc_skb 1 55439 NULL
107687 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
107688 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
107689 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
107690 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
107691 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
107692 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
107693 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
107694 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
107695 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
107696 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
107697 +ea_get_55522 ea_get 0 55522 NULL
107698 +buffer_size_55534 buffer_size 0 55534 NULL
107699 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
107700 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
107701 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
107702 +add_partition_55588 add_partition 2 55588 NULL
107703 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
107704 +free_pages_55603 free_pages 1 55603 NULL
107705 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
107706 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
107707 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
107708 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
107709 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
107710 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
107711 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
107712 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
107713 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
107714 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
107715 +read_oldmem_55658 read_oldmem 3 55658 NULL
107716 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
107717 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
107718 +get_info_55681 get_info 3 55681 NULL
107719 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
107720 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
107721 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
107722 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
107723 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
107724 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
107725 +set_local_name_55757 set_local_name 4 55757 NULL
107726 +strlen_55778 strlen 0 55778 NULL
107727 +set_spte_55783 set_spte 5-4 55783 NULL
107728 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
107729 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
107730 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
107731 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
107732 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
107733 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
107734 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
107735 +hsc_write_55875 hsc_write 3 55875 NULL
107736 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
107737 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
107738 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
107739 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
107740 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
107741 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
107742 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
107743 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
107744 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
107745 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
107746 +__set_discard_56081 __set_discard 2 56081 NULL
107747 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
107748 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
107749 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
107750 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
107751 +map_addr_56144 map_addr 7 56144 NULL
107752 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
107753 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
107754 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
107755 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
107756 +skb_headroom_56200 skb_headroom 0 56200 NULL
107757 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
107758 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
107759 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
107760 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
107761 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
107762 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
107763 +fd_copyin_56247 fd_copyin 3 56247 NULL
107764 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
107765 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
107766 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
107767 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
107768 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
107769 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
107770 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
107771 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
107772 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
107773 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
107774 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
107775 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
107776 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
107777 +dev_read_56369 dev_read 3 56369 NULL
107778 +write_gssp_56404 write_gssp 3 56404 NULL
107779 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
107780 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
107781 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
107782 +store_msg_56417 store_msg 3 56417 NULL
107783 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
107784 +fl_create_56435 fl_create 5 56435 NULL
107785 +gnttab_map_56439 gnttab_map 2 56439 NULL
107786 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
107787 +set_connectable_56458 set_connectable 4 56458 NULL
107788 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
107789 +putused_user_56467 putused_user 3 56467 NULL
107790 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
107791 +global_rt_period_56476 global_rt_period 0 56476 NULL
107792 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
107793 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
107794 +init_map_ip_56508 init_map_ip 5 56508 NULL
107795 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
107796 +ip_options_get_56538 ip_options_get 4 56538 NULL
107797 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
107798 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
107799 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
107800 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
107801 +event_filter_write_56609 event_filter_write 3 56609 NULL
107802 +gather_array_56641 gather_array 3 56641 NULL
107803 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
107804 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
107805 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
107806 +build_map_info_56696 build_map_info 2 56696 NULL
107807 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
107808 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
107809 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
107810 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
107811 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
107812 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
107813 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
107814 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
107815 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
107816 +hash_lookup_56792 hash_lookup 2 56792 NULL
107817 +do_syslog_56807 do_syslog 3 56807 NULL
107818 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
107819 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
107820 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
107821 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
107822 +wb_lookup_56858 wb_lookup 2 56858 NULL
107823 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
107824 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
107825 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
107826 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
107827 +strcspn_56913 strcspn 0 56913 NULL
107828 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
107829 +check_header_56930 check_header 2 56930 NULL
107830 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
107831 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
107832 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
107833 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
107834 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
107835 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
107836 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
107837 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
107838 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
107839 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
107840 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
107841 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
107842 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
107843 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
107844 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
107845 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
107846 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
107847 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
107848 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
107849 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
107850 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
107851 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
107852 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
107853 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
107854 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
107855 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
107856 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
107857 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
107858 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
107859 +flush_space_57241 flush_space 3 57241 NULL
107860 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
107861 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
107862 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
107863 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
107864 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
107865 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
107866 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
107867 +fw_file_size_57307 fw_file_size 0 57307 NULL
107868 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107869 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107870 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107871 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107872 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107873 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107874 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107875 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107876 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107877 +read_file_blob_57406 read_file_blob 3 57406 NULL
107878 +enclosure_register_57412 enclosure_register 3 57412 NULL
107879 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107880 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107881 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107882 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107883 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107884 +ReadReg_57453 ReadReg 0 57453 NULL
107885 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107886 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107887 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107888 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107889 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107890 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107891 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107892 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107893 +skb_headlen_57501 skb_headlen 0 57501 NULL
107894 +copy_in_user_57502 copy_in_user 3 57502 NULL
107895 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107896 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107897 +init_tag_map_57515 init_tag_map 3 57515 NULL
107898 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107899 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107900 +inode_permission_57531 inode_permission 0 57531 NULL
107901 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107902 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107903 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107904 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107905 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107906 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107907 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107908 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107909 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107910 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107911 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107912 +mem_read_57631 mem_read 3 57631 NULL
107913 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107914 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107915 +r3964_write_57662 r3964_write 4 57662 NULL
107916 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107917 +__lgwrite_57669 __lgwrite 4 57669 NULL
107918 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107919 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107920 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107921 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107922 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107923 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107924 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107925 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107926 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107927 +ld2_57794 ld2 0 57794 NULL
107928 +ivtv_read_57796 ivtv_read 3 57796 NULL
107929 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107930 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107931 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107932 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107933 +copy_to_user_57835 copy_to_user 3 57835 NULL
107934 +flash_read_57843 flash_read 3 57843 NULL
107935 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107936 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107937 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107938 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107939 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107940 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107941 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107942 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107943 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107944 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107945 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107946 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107947 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107948 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107949 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107950 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107951 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107952 +mce_async_out_58056 mce_async_out 3 58056 NULL
107953 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107954 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107955 +cm4040_write_58079 cm4040_write 3 58079 NULL
107956 +udi_log_event_58105 udi_log_event 3 58105 NULL
107957 +savemem_58129 savemem 3 58129 NULL
107958 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107959 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107960 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107961 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107962 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107963 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107964 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107965 +read_file_debug_58256 read_file_debug 3 58256 NULL
107966 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107967 +profile_load_58267 profile_load 3 58267 NULL
107968 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107969 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107970 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107971 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107972 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107973 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107974 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107975 +next_pidmap_58347 next_pidmap 2 58347 NULL
107976 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107977 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107978 +save_hint_58359 save_hint 2 58359 NULL
107979 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107980 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107981 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107982 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107983 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107984 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107985 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107986 +capabilities_read_58457 capabilities_read 3 58457 NULL
107987 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107988 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107989 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107990 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107991 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107992 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107993 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107994 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107995 +__clear_discard_58546 __clear_discard 2 58546 NULL
107996 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107997 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107998 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107999 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
108000 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
108001 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
108002 +xip_file_read_58592 xip_file_read 3 58592 NULL
108003 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
108004 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
108005 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
108006 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
108007 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
108008 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
108009 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
108010 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
108011 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
108012 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
108013 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
108014 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
108015 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
108016 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
108017 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
108018 +acpi_map_58725 acpi_map 1-2 58725 NULL
108019 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
108020 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
108021 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
108022 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
108023 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
108024 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
108025 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
108026 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
108027 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
108028 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
108029 +ep_read_58813 ep_read 3 58813 NULL
108030 +command_write_58841 command_write 3 58841 NULL
108031 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
108032 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
108033 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
108034 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
108035 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
108036 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
108037 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
108038 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
108039 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
108040 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
108041 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
108042 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
108043 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
108044 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
108045 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
108046 +ep_write_59008 ep_write 3 59008 NULL
108047 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
108048 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
108049 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
108050 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
108051 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
108052 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
108053 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
108054 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
108055 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
108056 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
108057 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
108058 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
108059 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
108060 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
108061 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
108062 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
108063 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
108064 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
108065 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
108066 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
108067 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
108068 +dt3155_read_59226 dt3155_read 3 59226 NULL
108069 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
108070 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
108071 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
108072 +nla_len_59258 nla_len 0 59258 NULL
108073 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
108074 +fd_copyout_59323 fd_copyout 3 59323 NULL
108075 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
108076 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
108077 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
108078 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
108079 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
108080 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
108081 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
108082 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
108083 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
108084 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
108085 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
108086 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
108087 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
108088 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
108089 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
108090 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
108091 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
108092 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
108093 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
108094 +tunables_write_59563 tunables_write 3 59563 NULL
108095 +memdup_user_59590 memdup_user 2 59590 NULL
108096 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
108097 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
108098 +mtrr_write_59622 mtrr_write 3 59622 NULL
108099 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
108100 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
108101 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
108102 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
108103 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
108104 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
108105 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
108106 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
108107 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
108108 +sriov_enable_59689 sriov_enable 2 59689 NULL
108109 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
108110 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
108111 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
108112 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
108113 +strnlen_59746 strnlen 0 59746 NULL
108114 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
108115 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
108116 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
108117 +venus_remove_59781 venus_remove 4 59781 NULL
108118 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
108119 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
108120 +ipw_write_59807 ipw_write 3 59807 NULL
108121 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
108122 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
108123 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
108124 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
108125 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
108126 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
108127 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
108128 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
108129 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
108130 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
108131 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
108132 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
108133 +lookup_node_59953 lookup_node 2 59953 NULL
108134 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
108135 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
108136 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
108137 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
108138 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
108139 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
108140 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
108141 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
108142 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
108143 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
108144 +register_device_60015 register_device 2-3 60015 NULL
108145 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
108146 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
108147 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
108148 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
108149 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
108150 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
108151 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
108152 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
108153 +compat_writev_60063 compat_writev 3 60063 NULL
108154 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
108155 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
108156 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
108157 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
108158 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
108159 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
108160 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
108161 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
108162 +init_state_60165 init_state 2 60165 NULL
108163 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
108164 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
108165 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
108166 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
108167 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
108168 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
108169 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
108170 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
108171 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
108172 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
108173 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
108174 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
108175 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
108176 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
108177 +printer_write_60276 printer_write 3 60276 NULL
108178 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
108179 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
108180 +getDataLength_60301 getDataLength 0 60301 NULL
108181 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
108182 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
108183 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
108184 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
108185 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
108186 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
108187 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
108188 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
108189 +driver_names_read_60399 driver_names_read 3 60399 NULL
108190 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
108191 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
108192 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
108193 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
108194 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
108195 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
108196 +rx_data_60442 rx_data 4 60442 NULL nohasharray
108197 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
108198 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
108199 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
108200 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
108201 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
108202 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
108203 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
108204 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
108205 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
108206 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
108207 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
108208 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
108209 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
108210 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
108211 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
108212 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
108213 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
108214 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
108215 +init_data_container_60709 init_data_container 1 60709 NULL
108216 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
108217 +raid_status_60755 raid_status 5 60755 NULL
108218 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
108219 +opticon_write_60775 opticon_write 4 60775 NULL
108220 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
108221 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
108222 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
108223 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
108224 +generic_writepages_60871 generic_writepages 0 60871 NULL
108225 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
108226 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
108227 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
108228 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
108229 +sys_mlock_60932 sys_mlock 1 60932 NULL
108230 +pti_char_write_60960 pti_char_write 3 60960 NULL
108231 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
108232 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
108233 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
108234 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
108235 +symtab_init_61050 symtab_init 2 61050 NULL
108236 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
108237 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
108238 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
108239 +get_derived_key_61100 get_derived_key 4 61100 NULL
108240 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
108241 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
108242 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
108243 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
108244 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
108245 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
108246 +__vmalloc_61168 __vmalloc 1 61168 NULL
108247 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
108248 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
108249 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
108250 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
108251 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
108252 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
108253 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
108254 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
108255 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
108256 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
108257 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
108258 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
108259 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
108260 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
108261 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
108262 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
108263 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
108264 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
108265 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
108266 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
108267 +change_xattr_61390 change_xattr 5 61390 NULL
108268 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
108269 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
108270 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
108271 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
108272 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
108273 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
108274 +erst_errno_61526 erst_errno 0 61526 NULL
108275 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
108276 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
108277 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
108278 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
108279 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
108280 +seq_open_private_61589 seq_open_private 3 61589 NULL
108281 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
108282 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
108283 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
108284 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
108285 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
108286 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
108287 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
108288 +resize_stripes_61650 resize_stripes 2 61650 NULL
108289 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
108290 +insert_one_name_61668 insert_one_name 7 61668 NULL
108291 +lock_loop_61681 lock_loop 1 61681 NULL
108292 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
108293 +filter_read_61692 filter_read 3 61692 NULL
108294 +iov_length_61716 iov_length 0 61716 NULL
108295 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
108296 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
108297 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
108298 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
108299 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
108300 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
108301 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
108302 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
108303 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
108304 +get_fw_name_61874 get_fw_name 3 61874 NULL
108305 +free_init_pages_61875 free_init_pages 2 61875 NULL
108306 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
108307 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
108308 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
108309 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
108310 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
108311 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
108312 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
108313 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
108314 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
108315 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
108316 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
108317 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
108318 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
108319 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
108320 +cow_file_range_61979 cow_file_range 3 61979 NULL
108321 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
108322 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
108323 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
108324 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
108325 +SYSC_select_62024 SYSC_select 1 62024 NULL
108326 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
108327 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
108328 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
108329 +do_pselect_62061 do_pselect 1 62061 NULL
108330 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
108331 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
108332 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
108333 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
108334 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
108335 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
108336 +ql_status_62135 ql_status 5 62135 NULL
108337 +video_usercopy_62151 video_usercopy 2 62151 NULL
108338 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
108339 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
108340 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
108341 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
108342 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
108343 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
108344 +allocate_partition_62245 allocate_partition 4 62245 NULL
108345 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
108346 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
108347 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
108348 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
108349 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
108350 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
108351 +subseq_list_62332 subseq_list 3-0 62332 NULL
108352 +flash_write_62354 flash_write 3 62354 NULL
108353 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
108354 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
108355 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
108356 +altera_irscan_62396 altera_irscan 2 62396 NULL
108357 +set_ssp_62411 set_ssp 4 62411 NULL
108358 +unmap_single_62423 unmap_single 2 62423 NULL
108359 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
108360 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
108361 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
108362 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
108363 +remove_mapping_62491 remove_mapping 2 62491 NULL
108364 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
108365 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
108366 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
108367 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
108368 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
108369 +debugfs_read_62535 debugfs_read 3 62535 NULL
108370 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
108371 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
108372 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
108373 +get_subdir_62581 get_subdir 3 62581 NULL
108374 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
108375 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
108376 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
108377 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
108378 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
108379 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
108380 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
108381 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
108382 +write_62671 write 3 62671 NULL
108383 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
108384 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
108385 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
108386 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
108387 +rdm_62719 rdm 0 62719 NULL
108388 +key_replays_read_62746 key_replays_read 3 62746 NULL
108389 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
108390 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
108391 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
108392 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
108393 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
108394 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
108395 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
108396 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
108397 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
108398 +set_swbp_62853 set_swbp 3 62853 NULL
108399 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
108400 +aoechr_write_62883 aoechr_write 3 62883 NULL
108401 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
108402 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
108403 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
108404 +getdqbuf_62908 getdqbuf 1 62908 NULL
108405 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
108406 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
108407 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
108408 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
108409 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
108410 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
108411 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
108412 +unlink1_63059 unlink1 3 63059 NULL
108413 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
108414 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
108415 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
108416 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
108417 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
108418 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
108419 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
108420 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
108421 +vme_master_read_63221 vme_master_read 0 63221 NULL
108422 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
108423 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
108424 +ptp_read_63251 ptp_read 4 63251 NULL
108425 +raid5_resize_63306 raid5_resize 2 63306 NULL
108426 +proc_info_read_63344 proc_info_read 3 63344 NULL
108427 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
108428 +idmouse_read_63374 idmouse_read 3 63374 NULL
108429 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
108430 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
108431 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
108432 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
108433 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
108434 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
108435 +kone_send_63435 kone_send 4 63435 NULL
108436 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
108437 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
108438 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
108439 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
108440 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
108441 +read_kcore_63488 read_kcore 3 63488 NULL
108442 +save_hint_63497 save_hint 2 63497 NULL
108443 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
108444 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
108445 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
108446 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
108447 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
108448 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
108449 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
108450 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
108451 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
108452 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
108453 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
108454 +module_alloc_63630 module_alloc 1 63630 NULL
108455 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
108456 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
108457 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
108458 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
108459 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
108460 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
108461 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
108462 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
108463 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
108464 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
108465 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
108466 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
108467 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
108468 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
108469 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
108470 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
108471 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
108472 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
108473 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
108474 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
108475 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
108476 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
108477 +prepare_copy_63826 prepare_copy 2 63826 NULL
108478 +sel_write_load_63830 sel_write_load 3 63830 NULL
108479 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
108480 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
108481 +divas_write_63901 divas_write 3 63901 NULL
108482 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
108483 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
108484 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
108485 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
108486 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
108487 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
108488 +__team_options_register_63941 __team_options_register 3 63941 NULL
108489 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
108490 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
108491 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
108492 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
108493 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
108494 +kmemdup_64015 kmemdup 2 64015 NULL
108495 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
108496 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
108497 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
108498 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
108499 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
108500 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
108501 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
108502 +get_u8_64076 get_u8 0 64076 NULL
108503 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
108504 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
108505 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
108506 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
108507 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
108508 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
108509 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
108510 +init_bch_64130 init_bch 1-2 64130 NULL
108511 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
108512 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
108513 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
108514 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
108515 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
108516 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
108517 +read_pulse_64227 read_pulse 0-3 64227 NULL
108518 +header_len_64232 header_len 0 64232 NULL
108519 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
108520 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
108521 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
108522 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
108523 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
108524 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
108525 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
108526 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
108527 +ffz_64324 ffz 0 64324 NULL
108528 +map_region_64328 map_region 1 64328 NULL
108529 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
108530 +ts_write_64336 ts_write 3 64336 NULL
108531 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
108532 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
108533 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
108534 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
108535 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
108536 +ilo_write_64378 ilo_write 3 64378 NULL
108537 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
108538 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
108539 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
108540 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
108541 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
108542 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
108543 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
108544 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
108545 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
108546 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
108547 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
108548 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
108549 +cap_capable_64462 cap_capable 0 64462 NULL
108550 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
108551 +single_open_size_64483 single_open_size 4 64483 NULL
108552 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
108553 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
108554 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
108555 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
108556 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
108557 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
108558 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
108559 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
108560 +SyS_bind_64544 SyS_bind 3 64544 NULL
108561 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
108562 +__spi_sync_64561 __spi_sync 0 64561 NULL
108563 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
108564 +fanotify_write_64623 fanotify_write 3 64623 NULL
108565 +to_dblock_64655 to_dblock 0-1 64655 NULL
108566 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
108567 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
108568 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
108569 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
108570 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
108571 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
108572 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
108573 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
108574 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
108575 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
108576 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
108577 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
108578 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
108579 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
108580 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
108581 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
108582 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
108583 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
108584 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
108585 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
108586 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
108587 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
108588 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
108589 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
108590 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
108591 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
108592 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
108593 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
108594 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
108595 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
108596 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
108597 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
108598 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
108599 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
108600 +pskb_pull_65005 pskb_pull 2 65005 NULL
108601 +unifi_write_65012 unifi_write 3 65012 NULL
108602 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
108603 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
108604 +insert_dent_65034 insert_dent 7 65034 NULL
108605 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
108606 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
108607 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
108608 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
108609 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
108610 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
108611 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
108612 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
108613 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
108614 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
108615 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
108616 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
108617 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
108618 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
108619 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
108620 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
108621 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
108622 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
108623 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
108624 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
108625 +get_var_len_65304 get_var_len 0 65304 NULL
108626 +unpack_array_65318 unpack_array 0 65318 NULL
108627 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
108628 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
108629 +init_list_set_65351 init_list_set 2-3 65351 NULL
108630 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
108631 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
108632 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
108633 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
108634 +strchr_65372 strchr 0 65372 NULL nohasharray
108635 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
108636 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
108637 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
108638 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
108639 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
108640 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
108641 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
108642 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
108643 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
108644 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
108645 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
108646 +alloc_dr_65495 alloc_dr 2 65495 NULL
108647 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
108648 new file mode 100644
108649 index 0000000..03d0c84
108650 --- /dev/null
108651 +++ b/tools/gcc/size_overflow_plugin.c
108652 @@ -0,0 +1,2113 @@
108653 +/*
108654 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
108655 + * Licensed under the GPL v2, or (at your option) v3
108656 + *
108657 + * Homepage:
108658 + * http://www.grsecurity.net/~ephox/overflow_plugin/
108659 + *
108660 + * Documentation:
108661 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
108662 + *
108663 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
108664 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
108665 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
108666 + *
108667 + * Usage:
108668 + * $ 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
108669 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
108670 + */
108671 +
108672 +#include "gcc-plugin.h"
108673 +#include "config.h"
108674 +#include "system.h"
108675 +#include "coretypes.h"
108676 +#include "tree.h"
108677 +#include "tree-pass.h"
108678 +#include "intl.h"
108679 +#include "plugin-version.h"
108680 +#include "tm.h"
108681 +#include "toplev.h"
108682 +#include "function.h"
108683 +#include "tree-flow.h"
108684 +#include "plugin.h"
108685 +#include "gimple.h"
108686 +#include "diagnostic.h"
108687 +#include "cfgloop.h"
108688 +
108689 +#if BUILDING_GCC_VERSION >= 4008
108690 +#define TODO_dump_func 0
108691 +#endif
108692 +
108693 +struct size_overflow_hash {
108694 + const struct size_overflow_hash * const next;
108695 + const char * const name;
108696 + const unsigned int param;
108697 +};
108698 +
108699 +#include "size_overflow_hash.h"
108700 +
108701 +enum mark {
108702 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
108703 +};
108704 +
108705 +enum err_code_conditions {
108706 + CAST_ONLY, FROM_CONST
108707 +};
108708 +
108709 +static unsigned int call_count = 0;
108710 +
108711 +#define __unused __attribute__((__unused__))
108712 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108713 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
108714 +#define BEFORE_STMT true
108715 +#define AFTER_STMT false
108716 +#define CREATE_NEW_VAR NULL_TREE
108717 +#define CODES_LIMIT 32
108718 +#define MAX_PARAM 31
108719 +#define MY_STMT GF_PLF_1
108720 +#define NO_CAST_CHECK GF_PLF_2
108721 +#define FROM_ARG true
108722 +#define FROM_RET false
108723 +
108724 +#if BUILDING_GCC_VERSION == 4005
108725 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
108726 +#endif
108727 +
108728 +int plugin_is_GPL_compatible;
108729 +void debug_gimple_stmt(gimple gs);
108730 +
108731 +static tree expand(struct pointer_set_t *visited, tree lhs);
108732 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
108733 +static tree report_size_overflow_decl;
108734 +static const_tree const_char_ptr_type_node;
108735 +static unsigned int handle_function(void);
108736 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
108737 +static tree get_size_overflow_type(gimple stmt, const_tree node);
108738 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
108739 +static void print_missing_msg(tree func, unsigned int argnum);
108740 +
108741 +static struct plugin_info size_overflow_plugin_info = {
108742 + .version = "20130822beta",
108743 + .help = "no-size-overflow\tturn off size overflow checking\n",
108744 +};
108745 +
108746 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108747 +{
108748 + unsigned int arg_count;
108749 + enum tree_code code = TREE_CODE(*node);
108750 +
108751 + switch (code) {
108752 + case FUNCTION_DECL:
108753 + arg_count = type_num_arguments(TREE_TYPE(*node));
108754 + break;
108755 + case FUNCTION_TYPE:
108756 + case METHOD_TYPE:
108757 + arg_count = type_num_arguments(*node);
108758 + break;
108759 + default:
108760 + *no_add_attrs = true;
108761 + error("%s: %qE attribute only applies to functions", __func__, name);
108762 + return NULL_TREE;
108763 + }
108764 +
108765 + for (; args; args = TREE_CHAIN(args)) {
108766 + tree position = TREE_VALUE(args);
108767 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108768 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108769 + *no_add_attrs = true;
108770 + }
108771 + }
108772 + return NULL_TREE;
108773 +}
108774 +
108775 +static const char* get_asm_name(tree node)
108776 +{
108777 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
108778 +}
108779 +
108780 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108781 +{
108782 + unsigned int arg_count, arg_num;
108783 + enum tree_code code = TREE_CODE(*node);
108784 +
108785 + switch (code) {
108786 + case FUNCTION_DECL:
108787 + arg_count = type_num_arguments(TREE_TYPE(*node));
108788 + break;
108789 + case FUNCTION_TYPE:
108790 + case METHOD_TYPE:
108791 + arg_count = type_num_arguments(*node);
108792 + break;
108793 + case FIELD_DECL:
108794 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
108795 + if (arg_num != 0) {
108796 + *no_add_attrs = true;
108797 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
108798 + }
108799 + return NULL_TREE;
108800 + default:
108801 + *no_add_attrs = true;
108802 + error("%qE attribute only applies to functions", name);
108803 + return NULL_TREE;
108804 + }
108805 +
108806 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
108807 + return NULL_TREE;
108808 +
108809 + for (; args; args = TREE_CHAIN(args)) {
108810 + tree position = TREE_VALUE(args);
108811 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108812 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108813 + *no_add_attrs = true;
108814 + }
108815 + }
108816 + return NULL_TREE;
108817 +}
108818 +
108819 +static struct attribute_spec size_overflow_attr = {
108820 + .name = "size_overflow",
108821 + .min_length = 1,
108822 + .max_length = -1,
108823 + .decl_required = true,
108824 + .type_required = false,
108825 + .function_type_required = false,
108826 + .handler = handle_size_overflow_attribute,
108827 +#if BUILDING_GCC_VERSION >= 4007
108828 + .affects_type_identity = false
108829 +#endif
108830 +};
108831 +
108832 +static struct attribute_spec intentional_overflow_attr = {
108833 + .name = "intentional_overflow",
108834 + .min_length = 1,
108835 + .max_length = -1,
108836 + .decl_required = true,
108837 + .type_required = false,
108838 + .function_type_required = false,
108839 + .handler = handle_intentional_overflow_attribute,
108840 +#if BUILDING_GCC_VERSION >= 4007
108841 + .affects_type_identity = false
108842 +#endif
108843 +};
108844 +
108845 +static void register_attributes(void __unused *event_data, void __unused *data)
108846 +{
108847 + register_attribute(&size_overflow_attr);
108848 + register_attribute(&intentional_overflow_attr);
108849 +}
108850 +
108851 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
108852 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
108853 +{
108854 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
108855 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
108856 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
108857 +
108858 + unsigned int m = 0x57559429;
108859 + unsigned int n = 0x5052acdb;
108860 + const unsigned int *key4 = (const unsigned int *)key;
108861 + unsigned int h = len;
108862 + unsigned int k = len + seed + n;
108863 + unsigned long long p;
108864 +
108865 + while (len >= 8) {
108866 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
108867 + len -= 8;
108868 + }
108869 + if (len >= 4) {
108870 + cwmixb(key4[0]) key4 += 1;
108871 + len -= 4;
108872 + }
108873 + if (len)
108874 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108875 + cwmixb(h ^ (k + n));
108876 + return k ^ h;
108877 +
108878 +#undef cwfold
108879 +#undef cwmixa
108880 +#undef cwmixb
108881 +}
108882 +
108883 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108884 +{
108885 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108886 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108887 + return fn ^ codes;
108888 +}
108889 +
108890 +static inline tree get_original_function_decl(tree fndecl)
108891 +{
108892 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108893 + return DECL_ABSTRACT_ORIGIN(fndecl);
108894 + return fndecl;
108895 +}
108896 +
108897 +static inline gimple get_def_stmt(const_tree node)
108898 +{
108899 + gcc_assert(node != NULL_TREE);
108900 + if (TREE_CODE(node) != SSA_NAME)
108901 + return NULL;
108902 + return SSA_NAME_DEF_STMT(node);
108903 +}
108904 +
108905 +static unsigned char get_tree_code(const_tree type)
108906 +{
108907 + switch (TREE_CODE(type)) {
108908 + case ARRAY_TYPE:
108909 + return 0;
108910 + case BOOLEAN_TYPE:
108911 + return 1;
108912 + case ENUMERAL_TYPE:
108913 + return 2;
108914 + case FUNCTION_TYPE:
108915 + return 3;
108916 + case INTEGER_TYPE:
108917 + return 4;
108918 + case POINTER_TYPE:
108919 + return 5;
108920 + case RECORD_TYPE:
108921 + return 6;
108922 + case UNION_TYPE:
108923 + return 7;
108924 + case VOID_TYPE:
108925 + return 8;
108926 + case REAL_TYPE:
108927 + return 9;
108928 + case VECTOR_TYPE:
108929 + return 10;
108930 + case REFERENCE_TYPE:
108931 + return 11;
108932 + case OFFSET_TYPE:
108933 + return 12;
108934 + case COMPLEX_TYPE:
108935 + return 13;
108936 + default:
108937 + debug_tree((tree)type);
108938 + gcc_unreachable();
108939 + }
108940 +}
108941 +
108942 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108943 +{
108944 + gcc_assert(type != NULL_TREE);
108945 +
108946 + while (type && len < CODES_LIMIT) {
108947 + tree_codes[len] = get_tree_code(type);
108948 + len++;
108949 + type = TREE_TYPE(type);
108950 + }
108951 + return len;
108952 +}
108953 +
108954 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108955 +{
108956 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108957 + enum tree_code code = TREE_CODE(type);
108958 + size_t len = 0;
108959 +
108960 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108961 +
108962 + arg = TYPE_ARG_TYPES(type);
108963 + // skip builtins __builtin_constant_p
108964 + if (!arg && DECL_BUILT_IN(fndecl))
108965 + return 0;
108966 +
108967 + if (TREE_CODE_CLASS(code) == tcc_type)
108968 + result = type;
108969 + else
108970 + result = DECL_RESULT(fndecl);
108971 +
108972 + gcc_assert(result != NULL_TREE);
108973 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108974 +
108975 + if (arg == NULL_TREE) {
108976 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108977 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108978 + if (arg_field == NULL_TREE)
108979 + return 0;
108980 + arg = TREE_TYPE(arg_field);
108981 + len = add_type_codes(arg, tree_codes, len);
108982 + gcc_assert(len != 0);
108983 + return len;
108984 + }
108985 +
108986 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108987 + while (arg && len < CODES_LIMIT) {
108988 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108989 + arg = TREE_CHAIN(arg);
108990 + }
108991 +
108992 + gcc_assert(len != 0);
108993 + return len;
108994 +}
108995 +
108996 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108997 +{
108998 + unsigned int hash;
108999 + const struct size_overflow_hash *entry;
109000 + unsigned char tree_codes[CODES_LIMIT];
109001 + size_t len;
109002 + const char *func_name;
109003 +
109004 + fndecl = get_original_function_decl(fndecl);
109005 + len = get_function_decl(fndecl, tree_codes);
109006 + if (len == 0)
109007 + return NULL;
109008 +
109009 + func_name = get_asm_name(fndecl);
109010 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
109011 +
109012 + entry = size_overflow_hash[hash];
109013 + while (entry) {
109014 + if (!strcmp(entry->name, func_name))
109015 + return entry;
109016 + entry = entry->next;
109017 + }
109018 +
109019 + return NULL;
109020 +}
109021 +
109022 +static bool is_bool(const_tree node)
109023 +{
109024 + const_tree type;
109025 +
109026 + if (node == NULL_TREE)
109027 + return false;
109028 +
109029 + type = TREE_TYPE(node);
109030 + if (!INTEGRAL_TYPE_P(type))
109031 + return false;
109032 + if (TREE_CODE(type) == BOOLEAN_TYPE)
109033 + return true;
109034 + if (TYPE_PRECISION(type) == 1)
109035 + return true;
109036 + return false;
109037 +}
109038 +
109039 +static bool skip_types(const_tree var)
109040 +{
109041 + tree type;
109042 +
109043 + if (is_gimple_constant(var))
109044 + return true;
109045 +
109046 + switch (TREE_CODE(var)) {
109047 + case ADDR_EXPR:
109048 +#if BUILDING_GCC_VERSION >= 4006
109049 + case MEM_REF:
109050 +#endif
109051 + case ARRAY_REF:
109052 + case BIT_FIELD_REF:
109053 + case INDIRECT_REF:
109054 + case TARGET_MEM_REF:
109055 + return true;
109056 + case PARM_DECL:
109057 + case VAR_DECL:
109058 + case COMPONENT_REF:
109059 + return false;
109060 + default:
109061 + break;
109062 + }
109063 +
109064 + gcc_assert(TREE_CODE(var) == SSA_NAME);
109065 +
109066 + type = TREE_TYPE(var);
109067 + switch (TREE_CODE(type)) {
109068 + case INTEGER_TYPE:
109069 + case ENUMERAL_TYPE:
109070 + return false;
109071 + case BOOLEAN_TYPE:
109072 + return is_bool(var);
109073 + default:
109074 + break;
109075 + }
109076 +
109077 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
109078 +
109079 + type = TREE_TYPE(type);
109080 + gcc_assert(type != NULL_TREE);
109081 + switch (TREE_CODE(type)) {
109082 + case RECORD_TYPE:
109083 + case POINTER_TYPE:
109084 + case ARRAY_TYPE:
109085 + return true;
109086 + case VOID_TYPE:
109087 + case INTEGER_TYPE:
109088 + case UNION_TYPE:
109089 + return false;
109090 + default:
109091 + break;
109092 + }
109093 +
109094 + debug_tree((tree)var);
109095 + gcc_unreachable();
109096 +}
109097 +
109098 +static unsigned int find_arg_number(const_tree arg, tree func)
109099 +{
109100 + tree var;
109101 + unsigned int argnum = 1;
109102 +
109103 + if (TREE_CODE(arg) == SSA_NAME)
109104 + arg = SSA_NAME_VAR(arg);
109105 +
109106 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
109107 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
109108 + continue;
109109 + if (!skip_types(var))
109110 + return argnum;
109111 + }
109112 +
109113 + return 0;
109114 +}
109115 +
109116 +static tree create_new_var(tree type)
109117 +{
109118 + tree new_var = create_tmp_var(type, "cicus");
109119 +
109120 +#if BUILDING_GCC_VERSION <= 4007
109121 + add_referenced_var(new_var);
109122 +#endif
109123 + return new_var;
109124 +}
109125 +
109126 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
109127 +{
109128 + gimple assign;
109129 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109130 + tree type = TREE_TYPE(rhs1);
109131 + tree lhs = create_new_var(type);
109132 +
109133 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
109134 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
109135 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
109136 +
109137 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
109138 + update_stmt(assign);
109139 + gimple_set_plf(assign, MY_STMT, true);
109140 + return assign;
109141 +}
109142 +
109143 +static tree cast_a_tree(tree type, tree var)
109144 +{
109145 + gcc_assert(type != NULL_TREE);
109146 + gcc_assert(var != NULL_TREE);
109147 + gcc_assert(fold_convertible_p(type, var));
109148 +
109149 + return fold_convert(type, var);
109150 +}
109151 +
109152 +static tree get_lhs(const_gimple stmt)
109153 +{
109154 + switch (gimple_code(stmt)) {
109155 + case GIMPLE_ASSIGN:
109156 + return gimple_get_lhs(stmt);
109157 + case GIMPLE_PHI:
109158 + return gimple_phi_result(stmt);
109159 + case GIMPLE_CALL:
109160 + return gimple_call_lhs(stmt);
109161 + default:
109162 + return NULL_TREE;
109163 + }
109164 +}
109165 +
109166 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
109167 +{
109168 + const_gimple def_stmt = get_def_stmt(rhs);
109169 +
109170 + if (force)
109171 + return false;
109172 +
109173 + if (is_gimple_constant(rhs))
109174 + return false;
109175 +
109176 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109177 + return false;
109178 +
109179 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
109180 + return false;
109181 +
109182 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
109183 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109184 + return false;
109185 +
109186 + return true;
109187 +}
109188 +
109189 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
109190 +{
109191 + gimple assign, def_stmt;
109192 +
109193 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
109194 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
109195 + gcc_unreachable();
109196 +
109197 + def_stmt = get_def_stmt(rhs);
109198 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
109199 + return def_stmt;
109200 +
109201 + if (lhs == CREATE_NEW_VAR)
109202 + lhs = create_new_var(dst_type);
109203 +
109204 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
109205 +
109206 + if (!gsi_end_p(*gsi)) {
109207 + location_t loc = gimple_location(gsi_stmt(*gsi));
109208 + gimple_set_location(assign, loc);
109209 + }
109210 +
109211 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
109212 +
109213 + if (before)
109214 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
109215 + else
109216 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
109217 + update_stmt(assign);
109218 + gimple_set_plf(assign, MY_STMT, true);
109219 +
109220 + return assign;
109221 +}
109222 +
109223 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
109224 +{
109225 + gimple_stmt_iterator gsi;
109226 + tree lhs;
109227 + const_gimple new_stmt;
109228 +
109229 + if (rhs == NULL_TREE)
109230 + return NULL_TREE;
109231 +
109232 + gsi = gsi_for_stmt(stmt);
109233 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
109234 +
109235 + lhs = get_lhs(new_stmt);
109236 + gcc_assert(lhs != NULL_TREE);
109237 + return lhs;
109238 +}
109239 +
109240 +static tree cast_to_TI_type(gimple stmt, tree node)
109241 +{
109242 + gimple_stmt_iterator gsi;
109243 + gimple cast_stmt;
109244 + tree type = TREE_TYPE(node);
109245 +
109246 + if (types_compatible_p(type, intTI_type_node))
109247 + return node;
109248 +
109249 + gsi = gsi_for_stmt(stmt);
109250 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109251 + return gimple_get_lhs(cast_stmt);
109252 +}
109253 +
109254 +static void check_function_hash(const_gimple stmt)
109255 +{
109256 + tree func;
109257 + const struct size_overflow_hash *hash;
109258 +
109259 + if (gimple_code(stmt) != GIMPLE_CALL)
109260 + return;
109261 +
109262 + func = gimple_call_fndecl(stmt);
109263 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
109264 + if (func == NULL_TREE)
109265 + return;
109266 +
109267 + hash = get_function_hash(func);
109268 + if (!hash)
109269 + print_missing_msg(func, 0);
109270 +}
109271 +
109272 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
109273 +{
109274 + tree lhs, new_lhs;
109275 + gimple_stmt_iterator gsi;
109276 +
109277 + if (rhs1 == NULL_TREE) {
109278 + debug_gimple_stmt(oldstmt);
109279 + error("%s: rhs1 is NULL_TREE", __func__);
109280 + gcc_unreachable();
109281 + }
109282 +
109283 + switch (gimple_code(oldstmt)) {
109284 + case GIMPLE_ASM:
109285 + lhs = rhs1;
109286 + break;
109287 + case GIMPLE_CALL:
109288 + lhs = gimple_call_lhs(oldstmt);
109289 + break;
109290 + case GIMPLE_ASSIGN:
109291 + lhs = gimple_get_lhs(oldstmt);
109292 + break;
109293 + default:
109294 + debug_gimple_stmt(oldstmt);
109295 + gcc_unreachable();
109296 + }
109297 +
109298 + gsi = gsi_for_stmt(oldstmt);
109299 + pointer_set_insert(visited, oldstmt);
109300 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
109301 + basic_block next_bb, cur_bb;
109302 + const_edge e;
109303 +
109304 + gcc_assert(before == false);
109305 + gcc_assert(stmt_can_throw_internal(oldstmt));
109306 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
109307 + gcc_assert(!gsi_end_p(gsi));
109308 +
109309 + cur_bb = gimple_bb(oldstmt);
109310 + next_bb = cur_bb->next_bb;
109311 + e = find_edge(cur_bb, next_bb);
109312 + gcc_assert(e != NULL);
109313 + gcc_assert(e->flags & EDGE_FALLTHRU);
109314 +
109315 + gsi = gsi_after_labels(next_bb);
109316 + gcc_assert(!gsi_end_p(gsi));
109317 +
109318 + before = true;
109319 + oldstmt = gsi_stmt(gsi);
109320 + }
109321 +
109322 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
109323 + return new_lhs;
109324 +}
109325 +
109326 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
109327 +{
109328 + gimple stmt;
109329 + gimple_stmt_iterator gsi;
109330 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
109331 +
109332 + if (gimple_plf(oldstmt, MY_STMT))
109333 + return lhs;
109334 +
109335 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
109336 + rhs1 = gimple_assign_rhs1(oldstmt);
109337 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
109338 + }
109339 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
109340 + rhs2 = gimple_assign_rhs2(oldstmt);
109341 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
109342 + }
109343 +
109344 + stmt = gimple_copy(oldstmt);
109345 + gimple_set_location(stmt, gimple_location(oldstmt));
109346 + gimple_set_plf(stmt, MY_STMT, true);
109347 +
109348 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
109349 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
109350 +
109351 + size_overflow_type = get_size_overflow_type(oldstmt, node);
109352 +
109353 + new_var = create_new_var(size_overflow_type);
109354 + new_var = make_ssa_name(new_var, stmt);
109355 + gimple_set_lhs(stmt, new_var);
109356 +
109357 + if (rhs1 != NULL_TREE)
109358 + gimple_assign_set_rhs1(stmt, rhs1);
109359 +
109360 + if (rhs2 != NULL_TREE)
109361 + gimple_assign_set_rhs2(stmt, rhs2);
109362 +#if BUILDING_GCC_VERSION >= 4007
109363 + if (rhs3 != NULL_TREE)
109364 + gimple_assign_set_rhs3(stmt, rhs3);
109365 +#endif
109366 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
109367 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
109368 +
109369 + gsi = gsi_for_stmt(oldstmt);
109370 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
109371 + update_stmt(stmt);
109372 + pointer_set_insert(visited, oldstmt);
109373 + return gimple_get_lhs(stmt);
109374 +}
109375 +
109376 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
109377 +{
109378 + basic_block first_bb;
109379 + gimple assign;
109380 + gimple_stmt_iterator gsi;
109381 +
109382 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
109383 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109384 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
109385 +
109386 + gsi = gsi_start_bb(first_bb);
109387 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109388 + return gimple_get_lhs(assign);
109389 +}
109390 +
109391 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
109392 +{
109393 + gimple_stmt_iterator gsi;
109394 + const_gimple assign;
109395 + gimple def_stmt = get_def_stmt(new_arg);
109396 +
109397 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
109398 + gsi = gsi_after_labels(gimple_bb(def_stmt));
109399 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
109400 + } else {
109401 + gsi = gsi_for_stmt(def_stmt);
109402 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
109403 + }
109404 +
109405 + return gimple_get_lhs(assign);
109406 +}
109407 +
109408 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
109409 +{
109410 + basic_block bb;
109411 + gimple_stmt_iterator gsi;
109412 + const_gimple assign, def_stmt;
109413 +
109414 + def_stmt = get_def_stmt(arg);
109415 + bb = gimple_bb(def_stmt);
109416 + gcc_assert(bb->index != 0);
109417 + gsi = gsi_after_labels(bb);
109418 +
109419 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109420 + return gimple_get_lhs(assign);
109421 +}
109422 +
109423 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
109424 +{
109425 + tree size_overflow_type;
109426 + const_gimple def_stmt = get_def_stmt(arg);
109427 +
109428 + if (phi_ssa_name != NULL_TREE)
109429 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
109430 +
109431 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
109432 +
109433 + if (new_arg != NULL_TREE) {
109434 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
109435 + return use_phi_ssa_name(phi_ssa_name, new_arg);
109436 + }
109437 +
109438 + switch(gimple_code(def_stmt)) {
109439 + case GIMPLE_PHI:
109440 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
109441 + case GIMPLE_NOP:
109442 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
109443 + default:
109444 + debug_gimple_stmt((gimple)def_stmt);
109445 + gcc_unreachable();
109446 + }
109447 +}
109448 +
109449 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
109450 +{
109451 + basic_block bb;
109452 + gimple phi;
109453 + gimple_seq seq;
109454 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
109455 +
109456 + bb = gsi_bb(gsi);
109457 +
109458 + phi = create_phi_node(result, bb);
109459 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
109460 + seq = phi_nodes(bb);
109461 + gsi = gsi_last(seq);
109462 + gsi_remove(&gsi, false);
109463 +
109464 + gsi = gsi_for_stmt(oldstmt);
109465 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
109466 + gimple_set_bb(phi, bb);
109467 + gimple_set_plf(phi, MY_STMT, true);
109468 + return phi;
109469 +}
109470 +
109471 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
109472 +{
109473 + gimple new_phi = NULL;
109474 + gimple oldstmt = get_def_stmt(orig_result);
109475 + tree phi_ssa_name = NULL_TREE;
109476 + unsigned int i;
109477 +
109478 + pointer_set_insert(visited, oldstmt);
109479 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
109480 + tree arg, new_arg;
109481 +
109482 + arg = gimple_phi_arg_def(oldstmt, i);
109483 +
109484 + new_arg = expand(visited, arg);
109485 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
109486 + if (i == 0) {
109487 + phi_ssa_name = new_arg;
109488 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
109489 + }
109490 +
109491 + gcc_assert(new_phi != NULL);
109492 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
109493 + }
109494 +
109495 + gcc_assert(new_phi != NULL);
109496 + update_stmt(new_phi);
109497 + return gimple_phi_result(new_phi);
109498 +}
109499 +
109500 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
109501 +{
109502 + const_gimple assign;
109503 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109504 + tree origtype = TREE_TYPE(orig_rhs);
109505 +
109506 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
109507 +
109508 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109509 + return gimple_get_lhs(assign);
109510 +}
109511 +
109512 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
109513 +{
109514 + const_tree rhs1, lhs, rhs1_type, lhs_type;
109515 + enum machine_mode lhs_mode, rhs_mode;
109516 + gimple def_stmt = get_def_stmt(no_const_rhs);
109517 +
109518 + if (!gimple_assign_cast_p(def_stmt))
109519 + return false;
109520 +
109521 + rhs1 = gimple_assign_rhs1(def_stmt);
109522 + lhs = gimple_get_lhs(def_stmt);
109523 + rhs1_type = TREE_TYPE(rhs1);
109524 + lhs_type = TREE_TYPE(lhs);
109525 + rhs_mode = TYPE_MODE(rhs1_type);
109526 + lhs_mode = TYPE_MODE(lhs_type);
109527 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
109528 + return false;
109529 +
109530 + return true;
109531 +}
109532 +
109533 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
109534 +{
109535 + tree rhs1 = gimple_assign_rhs1(stmt);
109536 + tree lhs = gimple_get_lhs(stmt);
109537 + const_tree rhs1_type = TREE_TYPE(rhs1);
109538 + const_tree lhs_type = TREE_TYPE(lhs);
109539 +
109540 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
109541 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109542 +
109543 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
109544 +}
109545 +
109546 +static bool no_uses(tree node)
109547 +{
109548 + imm_use_iterator imm_iter;
109549 + use_operand_p use_p;
109550 +
109551 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
109552 + const_gimple use_stmt = USE_STMT(use_p);
109553 + if (use_stmt == NULL)
109554 + return true;
109555 + if (is_gimple_debug(use_stmt))
109556 + continue;
109557 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
109558 + continue;
109559 + return false;
109560 + }
109561 + return true;
109562 +}
109563 +
109564 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
109565 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
109566 +{
109567 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
109568 + gimple def_stmt = get_def_stmt(lhs);
109569 +
109570 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109571 + return false;
109572 +
109573 + rhs1 = gimple_assign_rhs1(def_stmt);
109574 + rhs_type = TREE_TYPE(rhs1);
109575 + lhs_type = TREE_TYPE(lhs);
109576 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
109577 + return false;
109578 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
109579 + return false;
109580 +
109581 + def_stmt = get_def_stmt(rhs1);
109582 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
109583 + return false;
109584 +
109585 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
109586 + return false;
109587 +
109588 + rhs1 = gimple_assign_rhs1(def_stmt);
109589 + rhs2 = gimple_assign_rhs2(def_stmt);
109590 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
109591 + return false;
109592 +
109593 + if (is_gimple_constant(rhs2))
109594 + not_const_rhs = rhs1;
109595 + else
109596 + not_const_rhs = rhs2;
109597 +
109598 + return no_uses(not_const_rhs);
109599 +}
109600 +
109601 +static bool skip_lhs_cast_check(const_gimple stmt)
109602 +{
109603 + const_tree rhs = gimple_assign_rhs1(stmt);
109604 + const_gimple def_stmt = get_def_stmt(rhs);
109605 +
109606 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
109607 + if (gimple_code(def_stmt) == GIMPLE_ASM)
109608 + return true;
109609 +
109610 + if (is_const_plus_unsigned_signed_truncation(rhs))
109611 + return true;
109612 +
109613 + return false;
109614 +}
109615 +
109616 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
109617 +{
109618 + bool cast_lhs, cast_rhs;
109619 + tree lhs = gimple_get_lhs(stmt);
109620 + tree rhs = gimple_assign_rhs1(stmt);
109621 + const_tree lhs_type = TREE_TYPE(lhs);
109622 + const_tree rhs_type = TREE_TYPE(rhs);
109623 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
109624 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
109625 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
109626 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
109627 +
109628 + static bool check_lhs[3][4] = {
109629 + // ss su us uu
109630 + { false, true, true, false }, // lhs > rhs
109631 + { false, false, false, false }, // lhs = rhs
109632 + { true, true, true, true }, // lhs < rhs
109633 + };
109634 +
109635 + static bool check_rhs[3][4] = {
109636 + // ss su us uu
109637 + { true, false, true, true }, // lhs > rhs
109638 + { true, false, true, true }, // lhs = rhs
109639 + { true, false, true, true }, // lhs < rhs
109640 + };
109641 +
109642 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
109643 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
109644 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109645 +
109646 + if (lhs_size > rhs_size) {
109647 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109648 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109649 + } else if (lhs_size == rhs_size) {
109650 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109651 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109652 + } else {
109653 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109654 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109655 + }
109656 +
109657 + if (!cast_lhs && !cast_rhs)
109658 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109659 +
109660 + if (cast_lhs && !skip_lhs_cast_check(stmt))
109661 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
109662 +
109663 + if (cast_rhs)
109664 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
109665 +
109666 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109667 +}
109668 +
109669 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
109670 +{
109671 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
109672 +
109673 + if (gimple_plf(stmt, MY_STMT))
109674 + return lhs;
109675 +
109676 + rhs1 = gimple_assign_rhs1(stmt);
109677 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
109678 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109679 +
109680 + new_rhs1 = expand(visited, rhs1);
109681 +
109682 + if (new_rhs1 == NULL_TREE)
109683 + return create_cast_assign(visited, stmt);
109684 +
109685 + if (gimple_plf(stmt, NO_CAST_CHECK))
109686 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109687 +
109688 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
109689 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
109690 +
109691 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
109692 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
109693 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109694 + }
109695 +
109696 + if (!gimple_assign_cast_p(stmt))
109697 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109698 +
109699 + return create_cast_overflow_check(visited, new_rhs1, stmt);
109700 +}
109701 +
109702 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
109703 +{
109704 + tree rhs1, lhs = gimple_get_lhs(stmt);
109705 + gimple def_stmt = get_def_stmt(lhs);
109706 +
109707 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
109708 + rhs1 = gimple_assign_rhs1(def_stmt);
109709 +
109710 + if (is_gimple_constant(rhs1))
109711 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109712 +
109713 + switch (TREE_CODE(rhs1)) {
109714 + case SSA_NAME:
109715 + return handle_unary_rhs(visited, def_stmt);
109716 + case ARRAY_REF:
109717 + case BIT_FIELD_REF:
109718 + case ADDR_EXPR:
109719 + case COMPONENT_REF:
109720 + case INDIRECT_REF:
109721 +#if BUILDING_GCC_VERSION >= 4006
109722 + case MEM_REF:
109723 +#endif
109724 + case TARGET_MEM_REF:
109725 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109726 + case PARM_DECL:
109727 + case VAR_DECL:
109728 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109729 +
109730 + default:
109731 + debug_gimple_stmt(def_stmt);
109732 + debug_tree(rhs1);
109733 + gcc_unreachable();
109734 + }
109735 +}
109736 +
109737 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
109738 +{
109739 + gimple cond_stmt;
109740 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
109741 +
109742 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
109743 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
109744 + update_stmt(cond_stmt);
109745 +}
109746 +
109747 +static tree create_string_param(tree string)
109748 +{
109749 + tree i_type, a_type;
109750 + const int length = TREE_STRING_LENGTH(string);
109751 +
109752 + gcc_assert(length > 0);
109753 +
109754 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
109755 + a_type = build_array_type(char_type_node, i_type);
109756 +
109757 + TREE_TYPE(string) = a_type;
109758 + TREE_CONSTANT(string) = 1;
109759 + TREE_READONLY(string) = 1;
109760 +
109761 + return build1(ADDR_EXPR, ptr_type_node, string);
109762 +}
109763 +
109764 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
109765 +{
109766 + gimple func_stmt;
109767 + const_gimple def_stmt;
109768 + const_tree loc_line;
109769 + tree loc_file, ssa_name, current_func;
109770 + expanded_location xloc;
109771 + char *ssa_name_buf;
109772 + int len;
109773 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
109774 +
109775 + def_stmt = get_def_stmt(arg);
109776 + xloc = expand_location(gimple_location(def_stmt));
109777 +
109778 + if (!gimple_has_location(def_stmt)) {
109779 + xloc = expand_location(gimple_location(stmt));
109780 + if (!gimple_has_location(stmt))
109781 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
109782 + }
109783 +
109784 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
109785 +
109786 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
109787 + loc_file = create_string_param(loc_file);
109788 +
109789 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
109790 + current_func = create_string_param(current_func);
109791 +
109792 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
109793 + call_count++;
109794 + 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);
109795 + gcc_assert(len > 0);
109796 + ssa_name = build_string(len + 1, ssa_name_buf);
109797 + free(ssa_name_buf);
109798 + ssa_name = create_string_param(ssa_name);
109799 +
109800 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
109801 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
109802 +
109803 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
109804 +}
109805 +
109806 +static void __unused print_the_code_insertions(const_gimple stmt)
109807 +{
109808 + location_t loc = gimple_location(stmt);
109809 +
109810 + inform(loc, "Integer size_overflow check applied here.");
109811 +}
109812 +
109813 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
109814 +{
109815 + basic_block cond_bb, join_bb, bb_true;
109816 + edge e;
109817 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109818 +
109819 + cond_bb = gimple_bb(stmt);
109820 + if (before)
109821 + gsi_prev(&gsi);
109822 + if (gsi_end_p(gsi))
109823 + e = split_block_after_labels(cond_bb);
109824 + else
109825 + e = split_block(cond_bb, gsi_stmt(gsi));
109826 + cond_bb = e->src;
109827 + join_bb = e->dest;
109828 + e->flags = EDGE_FALSE_VALUE;
109829 + e->probability = REG_BR_PROB_BASE;
109830 +
109831 + bb_true = create_empty_bb(cond_bb);
109832 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
109833 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
109834 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
109835 +
109836 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109837 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
109838 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
109839 +
109840 + if (current_loops != NULL) {
109841 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
109842 + add_bb_to_loop(bb_true, cond_bb->loop_father);
109843 + }
109844 +
109845 + insert_cond(cond_bb, arg, cond_code, type_value);
109846 + insert_cond_result(bb_true, stmt, arg, min);
109847 +
109848 +// print_the_code_insertions(stmt);
109849 +}
109850 +
109851 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
109852 +{
109853 + const_tree rhs_type = TREE_TYPE(rhs);
109854 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
109855 +
109856 + gcc_assert(rhs_type != NULL_TREE);
109857 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
109858 + return;
109859 +
109860 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
109861 +
109862 + if (is_const_plus_unsigned_signed_truncation(rhs))
109863 + return;
109864 +
109865 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
109866 + // typemax (-1) < typemin (0)
109867 + if (TREE_OVERFLOW(type_max))
109868 + return;
109869 +
109870 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109871 +
109872 + cast_rhs_type = TREE_TYPE(cast_rhs);
109873 + type_max_type = TREE_TYPE(type_max);
109874 + type_min_type = TREE_TYPE(type_min);
109875 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109876 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109877 +
109878 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109879 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109880 +}
109881 +
109882 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109883 +{
109884 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109885 + return false;
109886 + if (!is_gimple_constant(rhs))
109887 + return false;
109888 + return true;
109889 +}
109890 +
109891 +static tree get_def_stmt_rhs(const_tree var)
109892 +{
109893 + tree rhs1, def_stmt_rhs1;
109894 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109895 +
109896 + def_stmt = get_def_stmt(var);
109897 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109898 +
109899 + rhs1 = gimple_assign_rhs1(def_stmt);
109900 + rhs1_def_stmt = get_def_stmt(rhs1);
109901 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109902 + return rhs1;
109903 +
109904 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109905 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109906 +
109907 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109908 + case GIMPLE_CALL:
109909 + case GIMPLE_NOP:
109910 + case GIMPLE_ASM:
109911 + case GIMPLE_PHI:
109912 + return def_stmt_rhs1;
109913 + case GIMPLE_ASSIGN:
109914 + return rhs1;
109915 + default:
109916 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109917 + gcc_unreachable();
109918 + }
109919 +}
109920 +
109921 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109922 +{
109923 + tree new_rhs, orig_rhs;
109924 + void (*gimple_assign_set_rhs)(gimple, tree);
109925 + tree rhs1 = gimple_assign_rhs1(stmt);
109926 + tree rhs2 = gimple_assign_rhs2(stmt);
109927 + tree lhs = gimple_get_lhs(stmt);
109928 +
109929 + if (!check_overflow)
109930 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109931 +
109932 + if (change_rhs == NULL_TREE)
109933 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109934 +
109935 + if (new_rhs2 == NULL_TREE) {
109936 + orig_rhs = rhs1;
109937 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109938 + } else {
109939 + orig_rhs = rhs2;
109940 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109941 + }
109942 +
109943 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109944 +
109945 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109946 + gimple_assign_set_rhs(stmt, new_rhs);
109947 + update_stmt(stmt);
109948 +
109949 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109950 +}
109951 +
109952 +static bool is_subtraction_special(const_gimple stmt)
109953 +{
109954 + gimple rhs1_def_stmt, rhs2_def_stmt;
109955 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109956 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109957 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109958 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109959 +
109960 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109961 + return false;
109962 +
109963 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109964 +
109965 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109966 + return false;
109967 +
109968 + rhs1_def_stmt = get_def_stmt(rhs1);
109969 + rhs2_def_stmt = get_def_stmt(rhs2);
109970 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109971 + return false;
109972 +
109973 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109974 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109975 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109976 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109977 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109978 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109979 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109980 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109981 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109982 + return false;
109983 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109984 + return false;
109985 +
109986 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109987 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109988 + return true;
109989 +}
109990 +
109991 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109992 +{
109993 + tree new_rhs1, new_rhs2;
109994 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109995 + gimple assign, stmt = get_def_stmt(lhs);
109996 + tree rhs1 = gimple_assign_rhs1(stmt);
109997 + tree rhs2 = gimple_assign_rhs2(stmt);
109998 +
109999 + if (!is_subtraction_special(stmt))
110000 + return NULL_TREE;
110001 +
110002 + new_rhs1 = expand(visited, rhs1);
110003 + new_rhs2 = expand(visited, rhs2);
110004 +
110005 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
110006 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
110007 +
110008 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
110009 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
110010 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
110011 + }
110012 +
110013 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
110014 + new_lhs = gimple_get_lhs(assign);
110015 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
110016 +
110017 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
110018 +}
110019 +
110020 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
110021 +{
110022 + const_gimple def_stmt;
110023 +
110024 + if (TREE_CODE(rhs) != SSA_NAME)
110025 + return false;
110026 +
110027 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
110028 + return false;
110029 +
110030 + def_stmt = get_def_stmt(rhs);
110031 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
110032 + return false;
110033 +
110034 + return true;
110035 +}
110036 +
110037 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
110038 +{
110039 + tree rhs1, rhs2, new_lhs;
110040 + gimple def_stmt = get_def_stmt(lhs);
110041 + tree new_rhs1 = NULL_TREE;
110042 + tree new_rhs2 = NULL_TREE;
110043 +
110044 + rhs1 = gimple_assign_rhs1(def_stmt);
110045 + rhs2 = gimple_assign_rhs2(def_stmt);
110046 +
110047 + /* no DImode/TImode division in the 32/64 bit kernel */
110048 + switch (gimple_assign_rhs_code(def_stmt)) {
110049 + case RDIV_EXPR:
110050 + case TRUNC_DIV_EXPR:
110051 + case CEIL_DIV_EXPR:
110052 + case FLOOR_DIV_EXPR:
110053 + case ROUND_DIV_EXPR:
110054 + case TRUNC_MOD_EXPR:
110055 + case CEIL_MOD_EXPR:
110056 + case FLOOR_MOD_EXPR:
110057 + case ROUND_MOD_EXPR:
110058 + case EXACT_DIV_EXPR:
110059 + case POINTER_PLUS_EXPR:
110060 + case BIT_AND_EXPR:
110061 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110062 + default:
110063 + break;
110064 + }
110065 +
110066 + new_lhs = handle_integer_truncation(visited, lhs);
110067 + if (new_lhs != NULL_TREE)
110068 + return new_lhs;
110069 +
110070 + if (TREE_CODE(rhs1) == SSA_NAME)
110071 + new_rhs1 = expand(visited, rhs1);
110072 + if (TREE_CODE(rhs2) == SSA_NAME)
110073 + new_rhs2 = expand(visited, rhs2);
110074 +
110075 + if (is_a_neg_overflow(def_stmt, rhs2))
110076 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
110077 + if (is_a_neg_overflow(def_stmt, rhs1))
110078 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
110079 +
110080 +
110081 + if (is_a_constant_overflow(def_stmt, rhs2))
110082 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
110083 + if (is_a_constant_overflow(def_stmt, rhs1))
110084 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
110085 +
110086 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
110087 +}
110088 +
110089 +#if BUILDING_GCC_VERSION >= 4007
110090 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
110091 +{
110092 + if (is_gimple_constant(rhs))
110093 + return cast_a_tree(size_overflow_type, rhs);
110094 + if (TREE_CODE(rhs) != SSA_NAME)
110095 + return NULL_TREE;
110096 + return expand(visited, rhs);
110097 +}
110098 +
110099 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
110100 +{
110101 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
110102 + gimple def_stmt = get_def_stmt(lhs);
110103 +
110104 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
110105 +
110106 + rhs1 = gimple_assign_rhs1(def_stmt);
110107 + rhs2 = gimple_assign_rhs2(def_stmt);
110108 + rhs3 = gimple_assign_rhs3(def_stmt);
110109 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
110110 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
110111 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
110112 +
110113 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
110114 +}
110115 +#endif
110116 +
110117 +static tree get_size_overflow_type(gimple stmt, const_tree node)
110118 +{
110119 + const_tree type;
110120 + tree new_type;
110121 +
110122 + gcc_assert(node != NULL_TREE);
110123 +
110124 + type = TREE_TYPE(node);
110125 +
110126 + if (gimple_plf(stmt, MY_STMT))
110127 + return TREE_TYPE(node);
110128 +
110129 + switch (TYPE_MODE(type)) {
110130 + case QImode:
110131 + new_type = intHI_type_node;
110132 + break;
110133 + case HImode:
110134 + new_type = intSI_type_node;
110135 + break;
110136 + case SImode:
110137 + new_type = intDI_type_node;
110138 + break;
110139 + case DImode:
110140 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110141 + new_type = intDI_type_node;
110142 + else
110143 + new_type = intTI_type_node;
110144 + break;
110145 + default:
110146 + debug_tree((tree)node);
110147 + error("%s: unsupported gcc configuration.", __func__);
110148 + gcc_unreachable();
110149 + }
110150 +
110151 + if (TYPE_QUALS(type) != 0)
110152 + return build_qualified_type(new_type, TYPE_QUALS(type));
110153 + return new_type;
110154 +}
110155 +
110156 +static tree expand_visited(gimple def_stmt)
110157 +{
110158 + const_gimple next_stmt;
110159 + gimple_stmt_iterator gsi;
110160 + enum gimple_code code = gimple_code(def_stmt);
110161 +
110162 + if (code == GIMPLE_ASM)
110163 + return NULL_TREE;
110164 +
110165 + gsi = gsi_for_stmt(def_stmt);
110166 + gsi_next(&gsi);
110167 +
110168 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
110169 + return NULL_TREE;
110170 + gcc_assert(!gsi_end_p(gsi));
110171 + next_stmt = gsi_stmt(gsi);
110172 +
110173 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
110174 + return NULL_TREE;
110175 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
110176 +
110177 + return get_lhs(next_stmt);
110178 +}
110179 +
110180 +static tree expand(struct pointer_set_t *visited, tree lhs)
110181 +{
110182 + gimple def_stmt;
110183 +
110184 + if (skip_types(lhs))
110185 + return NULL_TREE;
110186 +
110187 + def_stmt = get_def_stmt(lhs);
110188 +
110189 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110190 + return NULL_TREE;
110191 +
110192 + if (gimple_plf(def_stmt, MY_STMT))
110193 + return lhs;
110194 +
110195 + if (pointer_set_contains(visited, def_stmt))
110196 + return expand_visited(def_stmt);
110197 +
110198 + switch (gimple_code(def_stmt)) {
110199 + case GIMPLE_PHI:
110200 + return handle_phi(visited, lhs);
110201 + case GIMPLE_CALL:
110202 + case GIMPLE_ASM:
110203 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110204 + case GIMPLE_ASSIGN:
110205 + switch (gimple_num_ops(def_stmt)) {
110206 + case 2:
110207 + return handle_unary_ops(visited, def_stmt);
110208 + case 3:
110209 + return handle_binary_ops(visited, lhs);
110210 +#if BUILDING_GCC_VERSION >= 4007
110211 + case 4:
110212 + return handle_ternary_ops(visited, lhs);
110213 +#endif
110214 + }
110215 + default:
110216 + debug_gimple_stmt(def_stmt);
110217 + error("%s: unknown gimple code", __func__);
110218 + gcc_unreachable();
110219 + }
110220 +}
110221 +
110222 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
110223 +{
110224 + const_gimple assign;
110225 + tree orig_type = TREE_TYPE(orig_node);
110226 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110227 +
110228 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110229 + return gimple_get_lhs(assign);
110230 +}
110231 +
110232 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
110233 +{
110234 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
110235 + update_stmt(stmt);
110236 +}
110237 +
110238 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
110239 +{
110240 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
110241 + update_stmt(stmt);
110242 +}
110243 +
110244 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
110245 +{
110246 + tree arg;
110247 + const_tree origarg;
110248 +
110249 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
110250 + return true;
110251 +
110252 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
110253 + while (origarg && *argnum) {
110254 + (*argnum)--;
110255 + origarg = TREE_CHAIN(origarg);
110256 + }
110257 +
110258 + gcc_assert(*argnum == 0);
110259 +
110260 + gcc_assert(origarg != NULL_TREE);
110261 + *argnum = 0;
110262 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
110263 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
110264 + return true;
110265 + return false;
110266 +}
110267 +
110268 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
110269 +{
110270 + gimple phi = get_def_stmt(result);
110271 + unsigned int i, n = gimple_phi_num_args(phi);
110272 +
110273 + if (!phi)
110274 + return MARK_NO;
110275 +
110276 + pointer_set_insert(visited, phi);
110277 + for (i = 0; i < n; i++) {
110278 + enum mark marked;
110279 + const_tree arg = gimple_phi_arg_def(phi, i);
110280 + marked = pre_expand(visited, search_err_code, arg);
110281 + if (marked != MARK_NO)
110282 + return marked;
110283 + }
110284 + return MARK_NO;
110285 +}
110286 +
110287 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110288 +{
110289 + gimple def_stmt = get_def_stmt(lhs);
110290 + const_tree rhs;
110291 +
110292 + if (!def_stmt)
110293 + return MARK_NO;
110294 +
110295 + rhs = gimple_assign_rhs1(def_stmt);
110296 +
110297 + def_stmt = get_def_stmt(rhs);
110298 + if (is_gimple_constant(rhs))
110299 + search_err_code[FROM_CONST] = true;
110300 +
110301 + return pre_expand(visited, search_err_code, rhs);
110302 +}
110303 +
110304 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110305 +{
110306 + gimple def_stmt = get_def_stmt(lhs);
110307 + const_tree rhs1, rhs2;
110308 + enum mark marked;
110309 +
110310 + if (!def_stmt)
110311 + return MARK_NO;
110312 +
110313 + search_err_code[CAST_ONLY] = false;
110314 +
110315 + rhs1 = gimple_assign_rhs1(def_stmt);
110316 + rhs2 = gimple_assign_rhs2(def_stmt);
110317 + marked = pre_expand(visited, search_err_code, rhs1);
110318 + if (marked != MARK_NO)
110319 + return marked;
110320 + return pre_expand(visited, search_err_code, rhs2);
110321 +}
110322 +
110323 +static const_tree search_field_decl(const_tree comp_ref)
110324 +{
110325 + const_tree field = NULL_TREE;
110326 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
110327 +
110328 + for (i = 0; i < len; i++) {
110329 + field = TREE_OPERAND(comp_ref, i);
110330 + if (TREE_CODE(field) == FIELD_DECL)
110331 + break;
110332 + }
110333 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
110334 + return field;
110335 +}
110336 +
110337 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
110338 +{
110339 + const_tree attr, p;
110340 +
110341 + // 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);
110342 + if (fndecl == NULL_TREE)
110343 + return MARK_NO;
110344 +
110345 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
110346 + if (!attr || !TREE_VALUE(attr))
110347 + return MARK_NO;
110348 +
110349 + p = TREE_VALUE(attr);
110350 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
110351 + return MARK_TURN_OFF;
110352 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
110353 + return MARK_NOT_INTENTIONAL;
110354 + if (argnum == 0) {
110355 + gcc_assert(current_function_decl == fndecl);
110356 + return MARK_NO;
110357 + }
110358 +
110359 + do {
110360 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
110361 + return MARK_YES;
110362 + p = TREE_CHAIN(p);
110363 + } while (p);
110364 +
110365 + return MARK_NO;
110366 +}
110367 +
110368 +static void print_missing_msg(tree func, unsigned int argnum)
110369 +{
110370 + unsigned int new_hash;
110371 + size_t len;
110372 + unsigned char tree_codes[CODES_LIMIT];
110373 + location_t loc;
110374 + const char *curfunc;
110375 +
110376 + func = get_original_function_decl(func);
110377 + loc = DECL_SOURCE_LOCATION(func);
110378 + curfunc = get_asm_name(func);
110379 +
110380 + len = get_function_decl(func, tree_codes);
110381 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
110382 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
110383 +}
110384 +
110385 +static unsigned int search_missing_attribute(const_tree arg)
110386 +{
110387 + unsigned int argnum;
110388 + const struct size_overflow_hash *hash;
110389 + const_tree type = TREE_TYPE(arg);
110390 + tree func = get_original_function_decl(current_function_decl);
110391 +
110392 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
110393 +
110394 + if (TREE_CODE(type) == POINTER_TYPE)
110395 + return 0;
110396 +
110397 + argnum = find_arg_number(arg, func);
110398 + if (argnum == 0)
110399 + return 0;
110400 +
110401 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
110402 + return argnum;
110403 +
110404 + hash = get_function_hash(func);
110405 + if (!hash || !(hash->param & (1U << argnum))) {
110406 + print_missing_msg(func, argnum);
110407 + return 0;
110408 + }
110409 + return argnum;
110410 +}
110411 +
110412 +static enum mark is_already_marked(const_tree lhs)
110413 +{
110414 + unsigned int argnum;
110415 + const_tree fndecl;
110416 +
110417 + argnum = search_missing_attribute(lhs);
110418 + fndecl = get_original_function_decl(current_function_decl);
110419 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
110420 + return MARK_YES;
110421 + return MARK_NO;
110422 +}
110423 +
110424 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110425 +{
110426 + const_gimple def_stmt;
110427 +
110428 + if (skip_types(lhs))
110429 + return MARK_NO;
110430 +
110431 + if (TREE_CODE(lhs) == PARM_DECL)
110432 + return is_already_marked(lhs);
110433 +
110434 + if (TREE_CODE(lhs) == COMPONENT_REF) {
110435 + const_tree field, attr;
110436 +
110437 + field = search_field_decl(lhs);
110438 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
110439 + if (!attr || !TREE_VALUE(attr))
110440 + return MARK_NO;
110441 + return MARK_YES;
110442 + }
110443 +
110444 + def_stmt = get_def_stmt(lhs);
110445 +
110446 + if (!def_stmt)
110447 + return MARK_NO;
110448 +
110449 + if (pointer_set_contains(visited, def_stmt))
110450 + return MARK_NO;
110451 +
110452 + switch (gimple_code(def_stmt)) {
110453 + case GIMPLE_NOP:
110454 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
110455 + return is_already_marked(lhs);
110456 + return MARK_NO;
110457 + case GIMPLE_PHI:
110458 + return walk_phi(visited, search_err_code, lhs);
110459 + case GIMPLE_CALL:
110460 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
110461 + return MARK_TURN_OFF;
110462 + check_function_hash(def_stmt);
110463 + return MARK_NO;
110464 + case GIMPLE_ASM:
110465 + search_err_code[CAST_ONLY] = false;
110466 + return MARK_NO;
110467 + case GIMPLE_ASSIGN:
110468 + switch (gimple_num_ops(def_stmt)) {
110469 + case 2:
110470 + return walk_unary_ops(visited, search_err_code, lhs);
110471 + case 3:
110472 + return walk_binary_ops(visited, search_err_code, lhs);
110473 + }
110474 + default:
110475 + debug_gimple_stmt((gimple)def_stmt);
110476 + error("%s: unknown gimple code", __func__);
110477 + gcc_unreachable();
110478 + }
110479 +}
110480 +
110481 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
110482 +static bool skip_asm(const_tree arg)
110483 +{
110484 + gimple def_stmt = get_def_stmt(arg);
110485 +
110486 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110487 + return false;
110488 +
110489 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
110490 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
110491 +}
110492 +
110493 +/*
110494 +0</MARK_YES: no dup, search attributes (so, int)
110495 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
110496 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
110497 +*/
110498 +
110499 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
110500 +{
110501 + struct pointer_set_t *visited;
110502 + enum mark is_marked, is_found;
110503 + location_t loc;
110504 + bool search_err_code[2] = {true, false};
110505 +
110506 + is_marked = mark_status(current_function_decl, 0);
110507 + if (is_marked == MARK_TURN_OFF)
110508 + return true;
110509 +
110510 + is_marked = mark_status(fndecl, argnum + 1);
110511 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
110512 + return true;
110513 +
110514 + visited = pointer_set_create();
110515 + is_found = pre_expand(visited, search_err_code, arg);
110516 + pointer_set_destroy(visited);
110517 +
110518 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
110519 + return true;
110520 +
110521 + if (where == FROM_ARG && skip_asm(arg))
110522 + return true;
110523 +
110524 + if (is_found == MARK_TURN_OFF)
110525 + return true;
110526 +
110527 + if ((is_found == MARK_YES && is_marked == MARK_YES))
110528 + return true;
110529 +
110530 + if (is_found == MARK_YES) {
110531 + loc = DECL_SOURCE_LOCATION(fndecl);
110532 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
110533 + return true;
110534 + }
110535 + return false;
110536 +}
110537 +
110538 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
110539 +{
110540 + struct pointer_set_t *visited;
110541 + tree arg, new_arg;
110542 + bool match;
110543 +
110544 + if (argnum == 0)
110545 + return;
110546 +
110547 + argnum--;
110548 +
110549 + match = get_function_arg(&argnum, fndecl);
110550 + if (!match)
110551 + return;
110552 + gcc_assert(gimple_call_num_args(stmt) > argnum);
110553 + arg = gimple_call_arg(stmt, argnum);
110554 + if (arg == NULL_TREE)
110555 + return;
110556 +
110557 + if (skip_types(arg))
110558 + return;
110559 +
110560 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
110561 + return;
110562 +
110563 + visited = pointer_set_create();
110564 + new_arg = expand(visited, arg);
110565 + pointer_set_destroy(visited);
110566 +
110567 + if (new_arg == NULL_TREE)
110568 + return;
110569 +
110570 + change_function_arg(stmt, arg, argnum, new_arg);
110571 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
110572 +}
110573 +
110574 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
110575 +{
110576 + tree p = TREE_VALUE(attr);
110577 + do {
110578 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
110579 + p = TREE_CHAIN(p);
110580 + } while (p);
110581 +}
110582 +
110583 +static void handle_function_by_hash(gimple stmt, tree fndecl)
110584 +{
110585 + unsigned int num;
110586 + const struct size_overflow_hash *hash;
110587 +
110588 + hash = get_function_hash(fndecl);
110589 + if (!hash)
110590 + return;
110591 +
110592 + for (num = 0; num <= MAX_PARAM; num++)
110593 + if (hash->param & (1U << num))
110594 + handle_function_arg(stmt, fndecl, num);
110595 +}
110596 +
110597 +static bool check_return_value(void)
110598 +{
110599 + const struct size_overflow_hash *hash;
110600 +
110601 + hash = get_function_hash(current_function_decl);
110602 + if (!hash || !(hash->param & 1U << 0))
110603 + return false;
110604 +
110605 + return true;
110606 +}
110607 +
110608 +static void handle_return_value(gimple ret_stmt)
110609 +{
110610 + struct pointer_set_t *visited;
110611 + tree ret, new_ret;
110612 +
110613 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
110614 + return;
110615 +
110616 + ret = gimple_return_retval(ret_stmt);
110617 +
110618 + if (skip_types(ret))
110619 + return;
110620 +
110621 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
110622 + return;
110623 +
110624 + visited = pointer_set_create();
110625 + new_ret = expand(visited, ret);
110626 + pointer_set_destroy(visited);
110627 +
110628 + change_function_return(ret_stmt, ret, new_ret);
110629 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
110630 +}
110631 +
110632 +static void set_plf_false(void)
110633 +{
110634 + basic_block bb;
110635 +
110636 + FOR_ALL_BB(bb) {
110637 + gimple_stmt_iterator si;
110638 +
110639 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
110640 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110641 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
110642 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110643 + }
110644 +}
110645 +
110646 +static unsigned int handle_function(void)
110647 +{
110648 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
110649 + bool check_ret;
110650 +
110651 + set_plf_false();
110652 +
110653 + check_ret = check_return_value();
110654 +
110655 + do {
110656 + gimple_stmt_iterator gsi;
110657 + next = bb->next_bb;
110658 +
110659 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110660 + tree fndecl, attr;
110661 + gimple stmt = gsi_stmt(gsi);
110662 +
110663 + if (check_ret)
110664 + handle_return_value(stmt);
110665 +
110666 + if (!(is_gimple_call(stmt)))
110667 + continue;
110668 + fndecl = gimple_call_fndecl(stmt);
110669 + if (fndecl == NULL_TREE)
110670 + continue;
110671 + if (gimple_call_num_args(stmt) == 0)
110672 + continue;
110673 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
110674 + if (!attr || !TREE_VALUE(attr))
110675 + handle_function_by_hash(stmt, fndecl);
110676 + else
110677 + handle_function_by_attribute(stmt, attr, fndecl);
110678 + gsi = gsi_for_stmt(stmt);
110679 + next = gimple_bb(stmt)->next_bb;
110680 + }
110681 + bb = next;
110682 + } while (bb);
110683 + return 0;
110684 +}
110685 +
110686 +static struct gimple_opt_pass size_overflow_pass = {
110687 + .pass = {
110688 + .type = GIMPLE_PASS,
110689 + .name = "size_overflow",
110690 +#if BUILDING_GCC_VERSION >= 4008
110691 + .optinfo_flags = OPTGROUP_NONE,
110692 +#endif
110693 + .gate = NULL,
110694 + .execute = handle_function,
110695 + .sub = NULL,
110696 + .next = NULL,
110697 + .static_pass_number = 0,
110698 + .tv_id = TV_NONE,
110699 + .properties_required = PROP_cfg,
110700 + .properties_provided = 0,
110701 + .properties_destroyed = 0,
110702 + .todo_flags_start = 0,
110703 + .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
110704 + }
110705 +};
110706 +
110707 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
110708 +{
110709 + tree fntype;
110710 +
110711 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
110712 +
110713 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
110714 + fntype = build_function_type_list(void_type_node,
110715 + const_char_ptr_type_node,
110716 + unsigned_type_node,
110717 + const_char_ptr_type_node,
110718 + const_char_ptr_type_node,
110719 + NULL_TREE);
110720 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
110721 +
110722 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
110723 + TREE_PUBLIC(report_size_overflow_decl) = 1;
110724 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
110725 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
110726 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
110727 +}
110728 +
110729 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110730 +{
110731 + int i;
110732 + const char * const plugin_name = plugin_info->base_name;
110733 + const int argc = plugin_info->argc;
110734 + const struct plugin_argument * const argv = plugin_info->argv;
110735 + bool enable = true;
110736 +
110737 + struct register_pass_info size_overflow_pass_info = {
110738 + .pass = &size_overflow_pass.pass,
110739 + .reference_pass_name = "ssa",
110740 + .ref_pass_instance_number = 1,
110741 + .pos_op = PASS_POS_INSERT_AFTER
110742 + };
110743 +
110744 + if (!plugin_default_version_check(version, &gcc_version)) {
110745 + error(G_("incompatible gcc/plugin versions"));
110746 + return 1;
110747 + }
110748 +
110749 + for (i = 0; i < argc; ++i) {
110750 + if (!strcmp(argv[i].key, "no-size-overflow")) {
110751 + enable = false;
110752 + continue;
110753 + }
110754 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110755 + }
110756 +
110757 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
110758 + if (enable) {
110759 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
110760 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
110761 + }
110762 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110763 +
110764 + return 0;
110765 +}
110766 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
110767 new file mode 100644
110768 index 0000000..ac2901e
110769 --- /dev/null
110770 +++ b/tools/gcc/stackleak_plugin.c
110771 @@ -0,0 +1,327 @@
110772 +/*
110773 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
110774 + * Licensed under the GPL v2
110775 + *
110776 + * Note: the choice of the license means that the compilation process is
110777 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110778 + * but for the kernel it doesn't matter since it doesn't link against
110779 + * any of the gcc libraries
110780 + *
110781 + * gcc plugin to help implement various PaX features
110782 + *
110783 + * - track lowest stack pointer
110784 + *
110785 + * TODO:
110786 + * - initialize all local variables
110787 + *
110788 + * BUGS:
110789 + * - none known
110790 + */
110791 +#include "gcc-plugin.h"
110792 +#include "config.h"
110793 +#include "system.h"
110794 +#include "coretypes.h"
110795 +#include "tree.h"
110796 +#include "tree-pass.h"
110797 +#include "flags.h"
110798 +#include "intl.h"
110799 +#include "toplev.h"
110800 +#include "plugin.h"
110801 +//#include "expr.h" where are you...
110802 +#include "diagnostic.h"
110803 +#include "plugin-version.h"
110804 +#include "tm.h"
110805 +#include "function.h"
110806 +#include "basic-block.h"
110807 +#include "gimple.h"
110808 +#include "rtl.h"
110809 +#include "emit-rtl.h"
110810 +
110811 +#if BUILDING_GCC_VERSION >= 4008
110812 +#define TODO_dump_func 0
110813 +#endif
110814 +
110815 +extern void print_gimple_stmt(FILE *, gimple, int, int);
110816 +
110817 +int plugin_is_GPL_compatible;
110818 +
110819 +static int track_frame_size = -1;
110820 +static const char track_function[] = "pax_track_stack";
110821 +static const char check_function[] = "pax_check_alloca";
110822 +static bool init_locals;
110823 +
110824 +static struct plugin_info stackleak_plugin_info = {
110825 + .version = "201302112000",
110826 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
110827 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
110828 +};
110829 +
110830 +static bool gate_stackleak_track_stack(void);
110831 +static unsigned int execute_stackleak_tree_instrument(void);
110832 +static unsigned int execute_stackleak_final(void);
110833 +
110834 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
110835 + .pass = {
110836 + .type = GIMPLE_PASS,
110837 + .name = "stackleak_tree_instrument",
110838 +#if BUILDING_GCC_VERSION >= 4008
110839 + .optinfo_flags = OPTGROUP_NONE,
110840 +#endif
110841 + .gate = gate_stackleak_track_stack,
110842 + .execute = execute_stackleak_tree_instrument,
110843 + .sub = NULL,
110844 + .next = NULL,
110845 + .static_pass_number = 0,
110846 + .tv_id = TV_NONE,
110847 + .properties_required = PROP_gimple_leh | PROP_cfg,
110848 + .properties_provided = 0,
110849 + .properties_destroyed = 0,
110850 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
110851 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
110852 + }
110853 +};
110854 +
110855 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
110856 + .pass = {
110857 + .type = RTL_PASS,
110858 + .name = "stackleak_final",
110859 +#if BUILDING_GCC_VERSION >= 4008
110860 + .optinfo_flags = OPTGROUP_NONE,
110861 +#endif
110862 + .gate = gate_stackleak_track_stack,
110863 + .execute = execute_stackleak_final,
110864 + .sub = NULL,
110865 + .next = NULL,
110866 + .static_pass_number = 0,
110867 + .tv_id = TV_NONE,
110868 + .properties_required = 0,
110869 + .properties_provided = 0,
110870 + .properties_destroyed = 0,
110871 + .todo_flags_start = 0,
110872 + .todo_flags_finish = TODO_dump_func
110873 + }
110874 +};
110875 +
110876 +static bool gate_stackleak_track_stack(void)
110877 +{
110878 + return track_frame_size >= 0;
110879 +}
110880 +
110881 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110882 +{
110883 + gimple check_alloca;
110884 + tree fntype, fndecl, alloca_size;
110885 +
110886 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110887 + fndecl = build_fn_decl(check_function, fntype);
110888 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110889 +
110890 + // insert call to void pax_check_alloca(unsigned long size)
110891 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110892 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110893 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110894 +}
110895 +
110896 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110897 +{
110898 + gimple track_stack;
110899 + tree fntype, fndecl;
110900 +
110901 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110902 + fndecl = build_fn_decl(track_function, fntype);
110903 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110904 +
110905 + // insert call to void pax_track_stack(void)
110906 + track_stack = gimple_build_call(fndecl, 0);
110907 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110908 +}
110909 +
110910 +#if BUILDING_GCC_VERSION == 4005
110911 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110912 +{
110913 + tree fndecl;
110914 +
110915 + if (!is_gimple_call(stmt))
110916 + return false;
110917 + fndecl = gimple_call_fndecl(stmt);
110918 + if (!fndecl)
110919 + return false;
110920 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110921 + return false;
110922 +// print_node(stderr, "pax", fndecl, 4);
110923 + return DECL_FUNCTION_CODE(fndecl) == code;
110924 +}
110925 +#endif
110926 +
110927 +static bool is_alloca(gimple stmt)
110928 +{
110929 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110930 + return true;
110931 +
110932 +#if BUILDING_GCC_VERSION >= 4007
110933 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110934 + return true;
110935 +#endif
110936 +
110937 + return false;
110938 +}
110939 +
110940 +static unsigned int execute_stackleak_tree_instrument(void)
110941 +{
110942 + basic_block bb, entry_bb;
110943 + bool prologue_instrumented = false, is_leaf = true;
110944 +
110945 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110946 +
110947 + // 1. loop through BBs and GIMPLE statements
110948 + FOR_EACH_BB(bb) {
110949 + gimple_stmt_iterator gsi;
110950 +
110951 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110952 + gimple stmt;
110953 +
110954 + stmt = gsi_stmt(gsi);
110955 +
110956 + if (is_gimple_call(stmt))
110957 + is_leaf = false;
110958 +
110959 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110960 + if (!is_alloca(stmt))
110961 + continue;
110962 +
110963 + // 2. insert stack overflow check before each __builtin_alloca call
110964 + stackleak_check_alloca(&gsi);
110965 +
110966 + // 3. insert track call after each __builtin_alloca call
110967 + stackleak_add_instrumentation(&gsi);
110968 + if (bb == entry_bb)
110969 + prologue_instrumented = true;
110970 + }
110971 + }
110972 +
110973 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110974 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110975 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110976 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110977 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110978 + return 0;
110979 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110980 + return 0;
110981 +
110982 + // 4. insert track call at the beginning
110983 + if (!prologue_instrumented) {
110984 + gimple_stmt_iterator gsi;
110985 +
110986 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110987 + if (dom_info_available_p(CDI_DOMINATORS))
110988 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110989 + gsi = gsi_start_bb(bb);
110990 + stackleak_add_instrumentation(&gsi);
110991 + }
110992 +
110993 + return 0;
110994 +}
110995 +
110996 +static unsigned int execute_stackleak_final(void)
110997 +{
110998 + rtx insn, next;
110999 +
111000 + if (cfun->calls_alloca)
111001 + return 0;
111002 +
111003 + // keep calls only if function frame is big enough
111004 + if (get_frame_size() >= track_frame_size)
111005 + return 0;
111006 +
111007 + // 1. find pax_track_stack calls
111008 + for (insn = get_insns(); insn; insn = next) {
111009 + // 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))
111010 + rtx body;
111011 +
111012 + next = NEXT_INSN(insn);
111013 + if (!CALL_P(insn))
111014 + continue;
111015 + body = PATTERN(insn);
111016 + if (GET_CODE(body) != CALL)
111017 + continue;
111018 + body = XEXP(body, 0);
111019 + if (GET_CODE(body) != MEM)
111020 + continue;
111021 + body = XEXP(body, 0);
111022 + if (GET_CODE(body) != SYMBOL_REF)
111023 + continue;
111024 + if (strcmp(XSTR(body, 0), track_function))
111025 + continue;
111026 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
111027 + // 2. delete call
111028 + delete_insn_and_edges(insn);
111029 +#if BUILDING_GCC_VERSION >= 4007
111030 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
111031 + insn = next;
111032 + next = NEXT_INSN(insn);
111033 + delete_insn_and_edges(insn);
111034 + }
111035 +#endif
111036 + }
111037 +
111038 +// print_simple_rtl(stderr, get_insns());
111039 +// print_rtl(stderr, get_insns());
111040 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
111041 +
111042 + return 0;
111043 +}
111044 +
111045 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
111046 +{
111047 + const char * const plugin_name = plugin_info->base_name;
111048 + const int argc = plugin_info->argc;
111049 + const struct plugin_argument * const argv = plugin_info->argv;
111050 + int i;
111051 + struct register_pass_info stackleak_tree_instrument_pass_info = {
111052 + .pass = &stackleak_tree_instrument_pass.pass,
111053 +// .reference_pass_name = "tree_profile",
111054 + .reference_pass_name = "optimized",
111055 + .ref_pass_instance_number = 1,
111056 + .pos_op = PASS_POS_INSERT_BEFORE
111057 + };
111058 + struct register_pass_info stackleak_final_pass_info = {
111059 + .pass = &stackleak_final_rtl_opt_pass.pass,
111060 + .reference_pass_name = "final",
111061 + .ref_pass_instance_number = 1,
111062 + .pos_op = PASS_POS_INSERT_BEFORE
111063 + };
111064 +
111065 + if (!plugin_default_version_check(version, &gcc_version)) {
111066 + error(G_("incompatible gcc/plugin versions"));
111067 + return 1;
111068 + }
111069 +
111070 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
111071 +
111072 + for (i = 0; i < argc; ++i) {
111073 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
111074 + if (!argv[i].value) {
111075 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111076 + continue;
111077 + }
111078 + track_frame_size = atoi(argv[i].value);
111079 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
111080 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
111081 + continue;
111082 + }
111083 + if (!strcmp(argv[i].key, "initialize-locals")) {
111084 + if (argv[i].value) {
111085 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
111086 + continue;
111087 + }
111088 + init_locals = true;
111089 + continue;
111090 + }
111091 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111092 + }
111093 +
111094 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
111095 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
111096 +
111097 + return 0;
111098 +}
111099 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
111100 new file mode 100644
111101 index 0000000..4fae911
111102 --- /dev/null
111103 +++ b/tools/gcc/structleak_plugin.c
111104 @@ -0,0 +1,277 @@
111105 +/*
111106 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
111107 + * Licensed under the GPL v2
111108 + *
111109 + * Note: the choice of the license means that the compilation process is
111110 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
111111 + * but for the kernel it doesn't matter since it doesn't link against
111112 + * any of the gcc libraries
111113 + *
111114 + * gcc plugin to forcibly initialize certain local variables that could
111115 + * otherwise leak kernel stack to userland if they aren't properly initialized
111116 + * by later code
111117 + *
111118 + * Homepage: http://pax.grsecurity.net/
111119 + *
111120 + * Usage:
111121 + * $ # for 4.5/4.6/C based 4.7
111122 + * $ 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
111123 + * $ # for C++ based 4.7/4.8+
111124 + * $ 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
111125 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
111126 + *
111127 + * TODO: eliminate redundant initializers
111128 + * increase type coverage
111129 + */
111130 +
111131 +#include "gcc-plugin.h"
111132 +#include "config.h"
111133 +#include "system.h"
111134 +#include "coretypes.h"
111135 +#include "tree.h"
111136 +#include "tree-pass.h"
111137 +#include "intl.h"
111138 +#include "plugin-version.h"
111139 +#include "tm.h"
111140 +#include "toplev.h"
111141 +#include "function.h"
111142 +#include "tree-flow.h"
111143 +#include "plugin.h"
111144 +#include "gimple.h"
111145 +#include "diagnostic.h"
111146 +#include "cfgloop.h"
111147 +#include "langhooks.h"
111148 +
111149 +#if BUILDING_GCC_VERSION >= 4008
111150 +#define TODO_dump_func 0
111151 +#endif
111152 +
111153 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
111154 +
111155 +// unused type flag in all versions 4.5-4.8
111156 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
111157 +
111158 +int plugin_is_GPL_compatible;
111159 +void debug_gimple_stmt(gimple gs);
111160 +
111161 +static struct plugin_info structleak_plugin_info = {
111162 + .version = "201304082245",
111163 + .help = "disable\tdo not activate plugin\n",
111164 +};
111165 +
111166 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
111167 +{
111168 + *no_add_attrs = true;
111169 +
111170 + // check for types? for now accept everything linux has to offer
111171 + if (TREE_CODE(*node) != FIELD_DECL)
111172 + return NULL_TREE;
111173 +
111174 + *no_add_attrs = false;
111175 + return NULL_TREE;
111176 +}
111177 +
111178 +static struct attribute_spec user_attr = {
111179 + .name = "user",
111180 + .min_length = 0,
111181 + .max_length = 0,
111182 + .decl_required = false,
111183 + .type_required = false,
111184 + .function_type_required = false,
111185 + .handler = handle_user_attribute,
111186 +#if BUILDING_GCC_VERSION >= 4007
111187 + .affects_type_identity = true
111188 +#endif
111189 +};
111190 +
111191 +static void register_attributes(void *event_data, void *data)
111192 +{
111193 + register_attribute(&user_attr);
111194 +// register_attribute(&force_attr);
111195 +}
111196 +
111197 +static tree get_field_type(tree field)
111198 +{
111199 + return strip_array_types(TREE_TYPE(field));
111200 +}
111201 +
111202 +static bool is_userspace_type(tree type)
111203 +{
111204 + tree field;
111205 +
111206 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
111207 + tree fieldtype = get_field_type(field);
111208 + enum tree_code code = TREE_CODE(fieldtype);
111209 +
111210 + if (code == RECORD_TYPE || code == UNION_TYPE)
111211 + if (is_userspace_type(fieldtype))
111212 + return true;
111213 +
111214 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
111215 + return true;
111216 + }
111217 + return false;
111218 +}
111219 +
111220 +static void finish_type(void *event_data, void *data)
111221 +{
111222 + tree type = (tree)event_data;
111223 +
111224 + if (TYPE_USERSPACE(type))
111225 + return;
111226 +
111227 + if (is_userspace_type(type))
111228 + TYPE_USERSPACE(type) = 1;
111229 +}
111230 +
111231 +static void initialize(tree var)
111232 +{
111233 + basic_block bb;
111234 + gimple_stmt_iterator gsi;
111235 + tree initializer;
111236 + gimple init_stmt;
111237 +
111238 + // this is the original entry bb before the forced split
111239 + // TODO: check further BBs in case more splits occured before us
111240 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
111241 +
111242 + // first check if the variable is already initialized, warn otherwise
111243 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
111244 + gimple stmt = gsi_stmt(gsi);
111245 + tree rhs1;
111246 +
111247 + // we're looking for an assignment of a single rhs...
111248 + if (!gimple_assign_single_p(stmt))
111249 + continue;
111250 + rhs1 = gimple_assign_rhs1(stmt);
111251 +#if BUILDING_GCC_VERSION >= 4007
111252 + // ... of a non-clobbering expression...
111253 + if (TREE_CLOBBER_P(rhs1))
111254 + continue;
111255 +#endif
111256 + // ... to our variable...
111257 + if (gimple_get_lhs(stmt) != var)
111258 + continue;
111259 + // if it's an initializer then we're good
111260 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
111261 + return;
111262 + }
111263 +
111264 + // these aren't the 0days you're looking for
111265 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
111266 +
111267 + // build the initializer expression
111268 + initializer = build_constructor(TREE_TYPE(var), NULL);
111269 +
111270 + // build the initializer stmt
111271 + init_stmt = gimple_build_assign(var, initializer);
111272 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
111273 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
111274 + update_stmt(init_stmt);
111275 +}
111276 +
111277 +static unsigned int handle_function(void)
111278 +{
111279 + basic_block bb;
111280 + unsigned int ret = 0;
111281 + tree var;
111282 +
111283 +#if BUILDING_GCC_VERSION == 4005
111284 + tree vars;
111285 +#else
111286 + unsigned int i;
111287 +#endif
111288 +
111289 + // split the first bb where we can put the forced initializers
111290 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
111291 + if (dom_info_available_p(CDI_DOMINATORS))
111292 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
111293 +
111294 + // enumarate all local variables and forcibly initialize our targets
111295 +#if BUILDING_GCC_VERSION == 4005
111296 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
111297 + var = TREE_VALUE(vars);
111298 +#else
111299 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
111300 +#endif
111301 + tree type = TREE_TYPE(var);
111302 +
111303 + gcc_assert(DECL_P(var));
111304 + if (!auto_var_in_fn_p(var, current_function_decl))
111305 + continue;
111306 +
111307 + // only care about structure types
111308 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
111309 + continue;
111310 +
111311 + // if the type is of interest, examine the variable
111312 + if (TYPE_USERSPACE(type))
111313 + initialize(var);
111314 + }
111315 +
111316 + return ret;
111317 +}
111318 +
111319 +static struct gimple_opt_pass structleak_pass = {
111320 + .pass = {
111321 + .type = GIMPLE_PASS,
111322 + .name = "structleak",
111323 +#if BUILDING_GCC_VERSION >= 4008
111324 + .optinfo_flags = OPTGROUP_NONE,
111325 +#endif
111326 + .gate = NULL,
111327 + .execute = handle_function,
111328 + .sub = NULL,
111329 + .next = NULL,
111330 + .static_pass_number = 0,
111331 + .tv_id = TV_NONE,
111332 + .properties_required = PROP_cfg,
111333 + .properties_provided = 0,
111334 + .properties_destroyed = 0,
111335 + .todo_flags_start = 0,
111336 + .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
111337 + }
111338 +};
111339 +
111340 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
111341 +{
111342 + int i;
111343 + const char * const plugin_name = plugin_info->base_name;
111344 + const int argc = plugin_info->argc;
111345 + const struct plugin_argument * const argv = plugin_info->argv;
111346 + bool enable = true;
111347 +
111348 + struct register_pass_info structleak_pass_info = {
111349 + .pass = &structleak_pass.pass,
111350 + .reference_pass_name = "ssa",
111351 + .ref_pass_instance_number = 1,
111352 + .pos_op = PASS_POS_INSERT_AFTER
111353 + };
111354 +
111355 + if (!plugin_default_version_check(version, &gcc_version)) {
111356 + error(G_("incompatible gcc/plugin versions"));
111357 + return 1;
111358 + }
111359 +
111360 + if (strcmp(lang_hooks.name, "GNU C")) {
111361 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
111362 + enable = false;
111363 + }
111364 +
111365 + for (i = 0; i < argc; ++i) {
111366 + if (!strcmp(argv[i].key, "disable")) {
111367 + enable = false;
111368 + continue;
111369 + }
111370 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111371 + }
111372 +
111373 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
111374 + if (enable) {
111375 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
111376 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
111377 + }
111378 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
111379 +
111380 + return 0;
111381 +}
111382 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
111383 index 280dd82..077b427 100644
111384 --- a/tools/lib/lk/Makefile
111385 +++ b/tools/lib/lk/Makefile
111386 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
111387
111388 LIBFILE = liblk.a
111389
111390 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111391 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111392 EXTLIBS = -lelf -lpthread -lrt -lm
111393 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
111394 ALL_LDFLAGS = $(LDFLAGS)
111395 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
111396 index 6789d78..4afd019e 100644
111397 --- a/tools/perf/util/include/asm/alternative-asm.h
111398 +++ b/tools/perf/util/include/asm/alternative-asm.h
111399 @@ -5,4 +5,7 @@
111400
111401 #define altinstruction_entry #
111402
111403 + .macro pax_force_retaddr rip=0, reload=0
111404 + .endm
111405 +
111406 #endif
111407 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
111408 index 96b919d..c49bb74 100644
111409 --- a/tools/perf/util/include/linux/compiler.h
111410 +++ b/tools/perf/util/include/linux/compiler.h
111411 @@ -18,4 +18,12 @@
111412 #define __force
111413 #endif
111414
111415 +#ifndef __size_overflow
111416 +# define __size_overflow(...)
111417 +#endif
111418 +
111419 +#ifndef __intentional_overflow
111420 +# define __intentional_overflow(...)
111421 +#endif
111422 +
111423 #endif
111424 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
111425 index 1580dd4..5627b5b 100644
111426 --- a/virt/kvm/kvm_main.c
111427 +++ b/virt/kvm/kvm_main.c
111428 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
111429
111430 static cpumask_var_t cpus_hardware_enabled;
111431 static int kvm_usage_count = 0;
111432 -static atomic_t hardware_enable_failed;
111433 +static atomic_unchecked_t hardware_enable_failed;
111434
111435 struct kmem_cache *kvm_vcpu_cache;
111436 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
111437
111438 -static __read_mostly struct preempt_ops kvm_preempt_ops;
111439 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
111440 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
111441 +static struct preempt_ops kvm_preempt_ops = {
111442 + .sched_in = kvm_sched_in,
111443 + .sched_out = kvm_sched_out,
111444 +};
111445
111446 struct dentry *kvm_debugfs_dir;
111447
111448 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
111449 /* We can read the guest memory with __xxx_user() later on. */
111450 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
111451 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
111452 - !access_ok(VERIFY_WRITE,
111453 + !__access_ok(VERIFY_WRITE,
111454 (void __user *)(unsigned long)mem->userspace_addr,
111455 mem->memory_size)))
111456 goto out;
111457 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
111458 return 0;
111459 }
111460
111461 -static struct file_operations kvm_vcpu_fops = {
111462 +static file_operations_no_const kvm_vcpu_fops __read_only = {
111463 .release = kvm_vcpu_release,
111464 .unlocked_ioctl = kvm_vcpu_ioctl,
111465 #ifdef CONFIG_COMPAT
111466 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
111467 return 0;
111468 }
111469
111470 -static struct file_operations kvm_vm_fops = {
111471 +static file_operations_no_const kvm_vm_fops __read_only = {
111472 .release = kvm_vm_release,
111473 .unlocked_ioctl = kvm_vm_ioctl,
111474 #ifdef CONFIG_COMPAT
111475 @@ -2662,7 +2667,7 @@ out:
111476 return r;
111477 }
111478
111479 -static struct file_operations kvm_chardev_ops = {
111480 +static file_operations_no_const kvm_chardev_ops __read_only = {
111481 .unlocked_ioctl = kvm_dev_ioctl,
111482 .compat_ioctl = kvm_dev_ioctl,
111483 .llseek = noop_llseek,
111484 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
111485
111486 if (r) {
111487 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
111488 - atomic_inc(&hardware_enable_failed);
111489 + atomic_inc_unchecked(&hardware_enable_failed);
111490 printk(KERN_INFO "kvm: enabling virtualization on "
111491 "CPU%d failed\n", cpu);
111492 }
111493 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
111494
111495 kvm_usage_count++;
111496 if (kvm_usage_count == 1) {
111497 - atomic_set(&hardware_enable_failed, 0);
111498 + atomic_set_unchecked(&hardware_enable_failed, 0);
111499 on_each_cpu(hardware_enable_nolock, NULL, 1);
111500
111501 - if (atomic_read(&hardware_enable_failed)) {
111502 + if (atomic_read_unchecked(&hardware_enable_failed)) {
111503 hardware_disable_all_nolock();
111504 r = -EBUSY;
111505 }
111506 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
111507 kvm_arch_vcpu_put(vcpu);
111508 }
111509
111510 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111511 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111512 struct module *module)
111513 {
111514 int r;
111515 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111516 if (!vcpu_align)
111517 vcpu_align = __alignof__(struct kvm_vcpu);
111518 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
111519 - 0, NULL);
111520 + SLAB_USERCOPY, NULL);
111521 if (!kvm_vcpu_cache) {
111522 r = -ENOMEM;
111523 goto out_free_3;
111524 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111525 if (r)
111526 goto out_free;
111527
111528 + pax_open_kernel();
111529 kvm_chardev_ops.owner = module;
111530 kvm_vm_fops.owner = module;
111531 kvm_vcpu_fops.owner = module;
111532 + pax_close_kernel();
111533
111534 r = misc_register(&kvm_dev);
111535 if (r) {
111536 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111537
111538 register_syscore_ops(&kvm_syscore_ops);
111539
111540 - kvm_preempt_ops.sched_in = kvm_sched_in;
111541 - kvm_preempt_ops.sched_out = kvm_sched_out;
111542 -
111543 r = kvm_init_debug();
111544 if (r) {
111545 printk(KERN_ERR "kvm: create debugfs files failed\n");